Hardware code is going to be available soon. But I need to focus on exactly the right stuff at the moment - so I am not putting up the WIP HW library until I am 100% done with it. I am so short on time.
Here is the init code for the display:
void Pokitto::lcdInit() {
initBacklight();
SET_RESET;
wait_ms(10);
CLR_RESET;
wait_ms(10);
SET_RESET;
wait_ms(10);
//************* Start Initial Sequence **********//
write_command(0x01); // driver output control, this also affects direction
write_data(0x11C); // originally: 0x11C 100011100 SS,NL4,NL3,NL2
// NL4…0 is the number of scan lines to drive the screen !!!
// so 11100 is 1c = 220 lines, correct
// test 1: 0x1C 11100 SS=0,NL4,NL3,NL2 -> no effect
// test 2: 0x31C 1100011100 GS=1,SS=1,NL4,NL3,NL2 -> no effect
// test 3: 0x51C 10100011100 SM=1,GS=0,SS=1,NL4,NL3,NL2 -> no effect
// test 4: 0x71C SM=1,GS=1,SS=1,NL4,NL3,NL2
// test 5: 0x
// seems to have no effect… is this perhaps only for RGB mode ?
write_command(0x02); // LCD driving control
write_data(0x0100); // INV = 1
write_command(0x03); // Entry mode... lets try if this affects the direction
write_data(0x1030); // originally 0x1030 1000000110000 BGR,ID1,ID0
// test 1: 0x1038 1000000111000 BGR,ID1,ID0,AM=1 ->drawing DRAM horizontally
// test 4: am=1, id0=0, id1=0, 1000000001000,0x1008 -> same as above, but flipped on long
// test 2: am=0, id0=0, 1000000100000, 0x1020 -> flipped on long axis
// test 3: am=0, id1=0, 1000000010000, 0x1010 -> picture flowed over back to screen
write_command(0x08); // Display control 2
write_data(0x0808); // 100000001000 FP2,BP2
write_command(0x0C); // RGB display interface
write_data(0x0000); // all off
write_command(0x0F); // Frame marker position
write_data(0x0001); // OSC_EN
write_command(0x20); // Horizontal DRAM Address
write_data(0x0000); // 0
write_command(0x21); // Vertical DRAM Address
write_data(0x0000); // 0
//*************Power On sequence ****************//
write_command(0x10);
write_data(0x0000);
write_command(0x11);
write_data(0x1000);
wait_ms(10);
//------------------------ Set GRAM area --------------------------------//
write_command(0x30); // Gate scan position
write_data(0x0000); // if GS=0, 00h=G1, else 00h=G220
write_command(0x31); // Vertical scroll control
write_data(0x00DB); // scroll start line 11011011 = 219
write_command(0x32); // Vertical scroll control
write_data(0x0000); // scroll end line 0
write_command(0x33); // Vertical scroll control
write_data(0x0000); // 0=vertical scroll disabled
write_command(0x34); // Partial screen driving control
write_data(0x00DB); // db = full screen (end)
write_command(0x35); // partial screen
write_data(0x0000); // 0 = start
write_command(0x36); // Horizontal and vertical RAM position
write_data(0x00AF); //end address 175
write_command(0x37);
write_data(0x0000); // start address 0
write_command(0x38);
write_data(0x00DB); //end address 219
write_command(0x39); // start address 0
write_data(0x0000);
wait_ms(10);
write_command(0xff); // start gamma register control
write_data(0x0003);
// ----------- Adjust the Gamma Curve ----------//
write_command(0x50);
write_data(0x0203);
write_command(0x051);
write_data(0x0A09);
write_command(0x52);
write_data(0x0005);
write_command(0x53);
write_data(0x1021);
write_command(0x54);
write_data(0x0602);
write_command(0x55);
write_data(0x0003);
write_command(0x56);
write_data(0x0703);
write_command(0x57);
write_data(0x0507);
write_command(0x58);
write_data(0x1021);
write_command(0x59);
write_data(0x0703);
write_command(0xB0);
write_data(0x2501);
write_command(0xFF);
write_data(0x0000);
write_command(0x07);
write_data(0x1017);
wait_ms(200);
write_command(0x22);
lcdClear();
}