write_data(g,0x3F);//duty = 1/64*,64 COMS are enabled
write_cmd(g,CMD_SET_DISPLAY_OFFSET);
write_data(g,0x00);
write_cmd(g,CMD_SET_DISPLAY_START_LINE);//set start line position
write_data(g,0x00);
write_cmd(g,CMD_SET_REMAP);
write_data(g,0x14);//Horizontal address increment,Disable Column Address Re-map,Enable Nibble Re-map,Scan from COM[N-1] to COM0,Disable COM Split Odd Even
write_data(g,0x11);//Enable Dual COM mode
write_cmd(g,0xB5);//GPIO
write_data(g,0x00);
//writeCommand(0x00);
write_cmd(g,CMD_SET_FUNCTION_SELECTION);
write_data(g,0x01);// selection external VDD
write_cmd(g,CMD_DISPLAY_ENHANCEMENT);
write_data(g,0xA0);// enables the external VSL
write_data(g,0xb5);// 0xfd,Enhanced low GS display quality;default is 0xb5(normal),
write_cmd(g,CMD_SET_CONTRAST_CURRENT);
write_data(g,0x7f);// 0xff default is 0x7f
write_cmd(g,CMD_MASTER_CURRENT_CONTROL);
write_data(g,0x0f);//default is 0x0f
write_cmd(g,0xB9);//GRAY TABLE,linear Gray Scale
write_cmd(g,CMD_SET_PHASE_LENGTH);
write_data(g,0xE2);// default is 0x74
write_cmd(g,CMD_DISPLAY_ENHANCEMENT_B);
write_data(g,0xA2);// Reserved;default is 0xa2(normal)
write_data(g,0x20);
write_cmd(g,CMD_SET_PRECHARGE_VOLTAGE);
write_data(g,0x1F);// 0.6xVcc
write_cmd(g,CMD_SET_SECOND_PRECHARGE_PERIOD);
write_data(g,0x08);// default
write_cmd(g,CMD_SET_VCOMH_VOLTAGE);
write_data(g,0x07);// 0.86xVcc;default is 0x04
write_cmd(g,CMD_SET_DISPLAY_MODE_NORMAL);
write_cmd(g,CMD_EXIT_PARTIAL_DISPLAY);
write_cmd(g,CMD_SET_DISPLAY_ON);
// Finish Init
post_init_board(g);
/* Initialise the GDISP structure */
g->g.Width=GDISP_SCREEN_WIDTH;
g->g.Height=GDISP_SCREEN_HEIGHT;
g->g.Orientation=GDISP_ROTATE_180;
g->g.Powermode=powerOn;
g->g.Backlight=GDISP_INITIAL_BACKLIGHT;
g->g.Contrast=GDISP_INITIAL_CONTRAST;
returnTRUE;
}
#if GDISP_HARDWARE_FLUSH
LLDSPECvoidgdisp_lld_flush(GDisplay*g){
uint8_t*ram;
unsignedcols,rows;
// Don't flush if we don't need it.
if(!(g->flags&GDISP_FLG_NEEDFLUSH))
return;
acquire_bus(g);
write_cmd(g,CMD_SET_COLUMN_ADDR);// range 28 to 91 for 256 pixels to x
write_data(g,28);
write_data(g,GDISP_SCREEN_WIDTH/4+28-1);
write_cmd(g,CMD_SET_ROW_ADDR);// range 0 to 63 for 64 pixels