Skip to content

Commit 4168ba6

Browse files
authored
Add GC9307 panel. (#645)
Tested the panel successfully using esp32c3
1 parent b3a39bb commit 4168ba6

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

src/lgfx/v1/panel/Panel_GC9A01.hpp

+89
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,95 @@ namespace lgfx
197197
}
198198
};
199199

200+
struct Panel_GC9307 : public Panel_GC9xxx
201+
{
202+
Panel_GC9307(void)
203+
{
204+
_cfg.panel_height = _cfg.memory_height = 320;
205+
_cfg.dummy_read_pixel = 16;
206+
}
207+
208+
void setWindow(uint_fast16_t xs, uint_fast16_t ys, uint_fast16_t xe, uint_fast16_t ye) override
209+
{
210+
if (_internal_rotation % 2 == 0) {
211+
_bus->writeCommand(CMD_CASET, 8);
212+
_bus->writeData((xs + 34) >> 8 | ((xs + 34) & 0xFF) << 8 | ((xe + 34) << 8 | (xe + 34) >> 8) << 16, 32);
213+
_bus->writeCommand(CMD_RASET, 8);
214+
_bus->writeData(ys >> 8 | (ys & 0xFF) << 8 | (ye << 8 | ye >> 8) << 16, 32);
215+
} else if (_internal_rotation % 2 == 1) {
216+
_bus->writeCommand(CMD_CASET, 8);
217+
_bus->writeData(xs >> 8 | (xs & 0xFF) << 8 | (xe << 8 | xe >> 8) << 16, 32);
218+
_bus->writeCommand(CMD_RASET, 8);
219+
_bus->writeData((ys + 34) >> 8 | ((ys + 34) & 0xFF) << 8 | ((ye + 34) << 8 | (ye + 34) >> 8) << 16, 32);
220+
}
221+
_bus->writeCommand(CMD_RAMWR, 8);
222+
}
223+
224+
protected:
225+
226+
const uint8_t* getInitCommands(uint8_t listno) const override {
227+
228+
static constexpr uint8_t list0[] = {
229+
0xfe, 0,
230+
0xef, 0,
231+
// 0x36, 1, 0x48,
232+
// 0x3a, 1, 0x05,
233+
0x85, 1, 0xc0,
234+
0x86, 1, 0x98,
235+
0x87, 1, 0x28,
236+
0x89, 1, 0x33,
237+
0x8B, 1, 0x84,
238+
0x8D, 1, 0x3B,
239+
0x8E, 1, 0x0f,
240+
0x8F, 1, 0x70,
241+
0xe8, 2, 0x13, 0x17,
242+
0xec, 3, 0x57, 0x07, 0xff,
243+
0xed, 2, 0x18, 0x09,
244+
0xc9, 1, 0x10,
245+
0xff, 1, 0x61,
246+
0x99, 1, 0x3A,
247+
0x9d, 1, 0x43,
248+
0x98, 1, 0x3e,
249+
0x9c, 1, 0x4b,
250+
0xF0, 6, 0x06, 0x08, 0x08, 0x06, 0x05, 0x1d,
251+
0xF2, 6, 0x00, 0x01, 0x09, 0x07, 0x04, 0x23,
252+
0xF1, 6, 0x3b, 0x68, 0x66, 0x36, 0x35, 0x2f,
253+
0xF3, 6, 0x37, 0x6a, 0x66, 0x37, 0x35, 0x35,
254+
0xFA, 2, 0x80, 0x0f,
255+
0xBE, 1, 0x11,
256+
0xCB, 1, 0x02,
257+
0xCD, 1, 0x22,
258+
0x9B, 1, 0xFF,
259+
0x35, 1, 0x00,
260+
0x44, 2, 0x00, 0x0a,
261+
0x11, 0+CMD_INIT_DELAY, 200,
262+
0x29, 0,
263+
0xFF,0xFF, // end
264+
};
265+
switch (listno) {
266+
case 0: return list0;
267+
default: return nullptr;
268+
}
269+
}
270+
uint8_t getMadCtl(uint8_t r) const override
271+
{
272+
static constexpr uint8_t madctl_table[] =
273+
{
274+
// 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
275+
// MAD_MY | MAD_MX | MAD_MV | MAD_ML | MAD_BGR | MAD_MH | 0 | 0,
276+
MAD_MX , // 0
277+
MAD_MV|MAD_ML |MAD_MH, // 1
278+
MAD_MY , // 2
279+
MAD_MY|MAD_MX|MAD_MV , // 3
280+
MAD_MY|MAD_MX , // 4
281+
MAD_MX|MAD_MV , // 5
282+
0 , // 6
283+
MAD_MY|MAD_MV , // 7
284+
};
285+
return madctl_table[r];
286+
}
287+
};
288+
200289
//----------------------------------------------------------------------------
201290
}
202291
}

0 commit comments

Comments
 (0)