// On this controller the back-light is controlled by the controllers internal PWM // which is why it is in this file rather than the board file. static inline void set_backlight(GDisplay* g, uint8_t percent) { uint8_t temp; //Work in progress: the RA8875 has a built-in PWM, its output can //be used by a Dynamic Background Control or by a host (user) // Enable PWM1 write_index(g, 0x8a); //MCLR setreadmode(g); temp = read_data(g); setwritemode(g); temp |= 1<<7 ; write_data(g, temp); // PWM1 function select write_index(g, 0x8a); //MCLR setreadmode(g); temp = read_data(g); setwritemode(g); temp &= ~(1<<4); write_data(g, temp); // PWM1 Clock ratio write_index(g, 0x8a); //MCLR setreadmode(g); temp = read_data(g); setwritemode(g); temp &= 0xf0; temp |= 0x0b & 0x0f; write_data(g, temp); // PWM1 Write duty cycle write_reg8(g, 0x8b, 54+percent); // PTNO: Also change percent to range from 0x00 to 0xFF }
LLDSPEC void gdisp_lld_read_start(GDisplay *g) { acquire_bus(g); //set_viewport(g); //write_index(g, 0x2E); setreadmode(g); //dummy_read(g); }
LLDSPEC void gdisp_lld_read_start(GDisplay *g) { acquire_bus(g); set_viewport(g); set_cursor(g); setreadmode(g); dummy_read(g); }
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { uint16_t cver; // No private area for this controller g->priv = 0; // Initialise the board interface init_board(g); /* Hardware reset */ setpin_reset(g, TRUE); gfxSleepMicroseconds(1000); setpin_reset(g, FALSE); gfxSleepMicroseconds(1000); acquire_bus(g); write_index(g, 0); // Get controller version setreadmode(g); dummy_read(g); cver = read_data(g); setwritemode(g); /* initializing funciton */ write_reg(g, 0xe5,0x8000); /* Set the internal vcore voltage */ write_reg(g, 0x00,0x0001); /* start OSC */ write_reg(g, 0x2b,0x0010); /* Set the frame rate as 80 when the internal resistor is used for oscillator circuit */ write_reg(g, 0x01,0x0100); /* s720 to s1 ; G1 to G320 */ write_reg(g, 0x02,0x0700); /* set the line inversion */ write_reg(g, 0x03,0x1018); /* 65536 colors */ write_reg(g, 0x04,0x0000); write_reg(g, 0x08,0x0202); /* specify the line number of front and back porch periods respectively */ write_reg(g, 0x09,0x0000); write_reg(g, 0x0a,0x0000); write_reg(g, 0x0c,0x0000); /* select internal system clock */ write_reg(g, 0x0d,0x0000); write_reg(g, 0x0f,0x0000); write_reg(g, 0x50,0x0000); /* set windows adress */ write_reg(g, 0x51,0x00ef); write_reg(g, 0x52,0x0000); write_reg(g, 0x53,0x013f); write_reg(g, 0x60,0x2700); write_reg(g, 0x61,0x0001); write_reg(g, 0x6a,0x0000); write_reg(g, 0x80,0x0000); write_reg(g, 0x81,0x0000); write_reg(g, 0x82,0x0000); write_reg(g, 0x83,0x0000); write_reg(g, 0x84,0x0000); write_reg(g, 0x85,0x0000); write_reg(g, 0x90,0x0010); write_reg(g, 0x92,0x0000); write_reg(g, 0x93,0x0003); write_reg(g, 0x95,0x0110); write_reg(g, 0x97,0x0000); write_reg(g, 0x98,0x0000); /* power setting function */ write_reg(g, 0x10,0x0000); write_reg(g, 0x11,0x0000); write_reg(g, 0x12,0x0000); write_reg(g, 0x13,0x0000); gfxSleepMicroseconds(100); write_reg(g, 0x10,0x17b0); write_reg(g, 0x11,0x0004); gfxSleepMicroseconds(50); write_reg(g, 0x12,0x013e); gfxSleepMicroseconds(50); write_reg(g, 0x13,0x1f00); write_reg(g, 0x29,0x000f); gfxSleepMicroseconds(50); write_reg(g, 0x20,0x0000); write_reg(g, 0x21,0x0000); /* initializing function */ write_reg(g, 0x30,0x0204); write_reg(g, 0x31,0x0001); write_reg(g, 0x32,0x0000); write_reg(g, 0x35,0x0206); write_reg(g, 0x36,0x0600); write_reg(g, 0x37,0x0500); write_reg(g, 0x38,0x0505); write_reg(g, 0x39,0x0407); write_reg(g, 0x3c,0x0500); write_reg(g, 0x3d,0x0503); /* display on */ write_reg(g, 0x07,0x0173); gfxSleepMicroseconds(50); // Finish Init post_init_board(g); // Release the bus release_bus(g); // Turn on the backlight set_backlight(g, GDISP_INITIAL_BACKLIGHT); /* Initialise the GDISP structure */ g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; g->g.Orientation = GDISP_ROTATE_0; g->g.Powermode = powerOn; g->g.Backlight = GDISP_INITIAL_BACKLIGHT; g->g.Contrast = GDISP_INITIAL_CONTRAST; return TRUE; }
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { unsigned short DeviceCode; // No private area for this controller g->priv = 0; // Initialise the board interface init_board(g); /* Hardware reset */ setpin_reset(g, TRUE); gfxSleepMilliseconds(1); setpin_reset(g, FALSE); gfxSleepMilliseconds(10); setpin_reset(g, TRUE); gfxSleepMilliseconds(50); acquire_bus(g); setreadmode(g); DeviceCode = read_reg(g, 0x00); setwritemode(g); if( DeviceCode == 0x9320 || DeviceCode == 0x9300 ) { write_reg(g, 0x00, 0x0000); write_reg(g, 0x01, 0x0100); /* Driver Output Contral */ write_reg(g, 0x02, 0x0700); /* LCD Driver Waveform Contral */ write_reg(g, 0x03, 0x1038); /* Set the scan mode */ write_reg(g, 0x04, 0x0000); /* Scalling Contral */ write_reg(g, 0x08, 0x0202); /* Display Contral 2 */ write_reg(g, 0x09, 0x0000); /* Display Contral 3 */ write_reg(g, 0x0a, 0x0000); /* Frame Cycle Contal */ write_reg(g, 0x0c, (1<<0)); /* Extern Display Interface Contral 1 */ write_reg(g, 0x0d, 0x0000); /* Frame Maker Position */ write_reg(g, 0x0f, 0x0000); /* Extern Display Interface Contral 2 */ gfxSleepMilliseconds(50); write_reg(g, 0x07, 0x0101); /* Display Contral */ gfxSleepMilliseconds(50); write_reg(g, 0x10, (1<<12)|(0<<8)|(1<<7)|(1<<6)|(0<<4)); /* Power Control 1 */ write_reg(g, 0x11, 0x0007); /* Power Control 2 */ write_reg(g, 0x12, (1<<8)|(1<<4)|(0<<0)); /* Power Control 3 */ write_reg(g, 0x13, 0x0b00); /* Power Control 4 */ write_reg(g, 0x29, 0x0000); /* Power Control 7 */ write_reg(g, 0x2b, (1<<14)|(1<<4)); write_reg(g, 0x50, 0); /* Set X Start */ write_reg(g, 0x51, 239); /* Set X End */ write_reg(g, 0x52, 0); /* Set Y Start */ write_reg(g, 0x53, 319); /* Set Y End */ gfxSleepMilliseconds(50); write_reg(g, 0x60, 0x2700); /* Driver Output Control */ write_reg(g, 0x61, 0x0001); /* Driver Output Control */ write_reg(g, 0x6a, 0x0000); /* Vertical Srcoll Control */ write_reg(g, 0x80, 0x0000); /* Display Position? Partial Display 1 */ write_reg(g, 0x81, 0x0000); /* RAM Address Start? Partial Display 1 */ write_reg(g, 0x82, 0x0000); /* RAM Address End-Partial Display 1 */ write_reg(g, 0x83, 0x0000); /* Displsy Position? Partial Display 2 */ write_reg(g, 0x84, 0x0000); /* RAM Address Start? Partial Display 2 */ write_reg(g, 0x85, 0x0000); /* RAM Address End? Partial Display 2 */ write_reg(g, 0x90, (0<<7)|(16<<0)); /* Frame Cycle Contral */ write_reg(g, 0x92, 0x0000); /* Panel Interface Contral 2 */ write_reg(g, 0x93, 0x0001); /* Panel Interface Contral 3 */ write_reg(g, 0x95, 0x0110); /* Frame Cycle Contral */ write_reg(g, 0x97, (0<<8)); write_reg(g, 0x98, 0x0000); /* Frame Cycle Contral */ write_reg(g, 0x07, 0x0133); } else if( DeviceCode == 0x9325 || DeviceCode == 0x9328) { write_reg(g, 0x00e7, 0x0010); write_reg(g, 0x0000, 0x0001); /* start internal osc */ write_reg(g, 0x0001, 0x0100); write_reg(g, 0x0002, 0x0700); /* power on sequence */ write_reg(g, 0x0003, (1<<12)|(1<<5)|(1<<4)|(0<<3) ); /* importance */ write_reg(g, 0x0004, 0x0000); write_reg(g, 0x0008, 0x0207); write_reg(g, 0x0009, 0x0000); write_reg(g, 0x000a, 0x0000); /* display setting */ write_reg(g, 0x000c, 0x0001); /* display setting */ write_reg(g, 0x000d, 0x0000); write_reg(g, 0x000f, 0x0000); /* Power On sequence */ write_reg(g, 0x0010, 0x0000); write_reg(g, 0x0011, 0x0007); write_reg(g, 0x0012, 0x0000); write_reg(g, 0x0013, 0x0000); gfxSleepMilliseconds(50); /* delay 50 ms */ write_reg(g, 0x0010, 0x1590); write_reg(g, 0x0011, 0x0227); gfxSleepMilliseconds(50); /* delay 50 ms */ write_reg(g, 0x0012, 0x009c); gfxSleepMilliseconds(50); /* delay 50 ms */ write_reg(g, 0x0013, 0x1900); write_reg(g, 0x0029, 0x0023); write_reg(g, 0x002b, 0x000e); gfxSleepMilliseconds(50); /* delay 50 ms */ write_reg(g, 0x0020, 0x0000); write_reg(g, 0x0021, 0x0000); gfxSleepMilliseconds(50); /* delay 50 ms */ write_reg(g, 0x0030, 0x0007); write_reg(g, 0x0031, 0x0707); write_reg(g, 0x0032, 0x0006); write_reg(g, 0x0035, 0x0704); write_reg(g, 0x0036, 0x1f04); write_reg(g, 0x0037, 0x0004); write_reg(g, 0x0038, 0x0000); write_reg(g, 0x0039, 0x0706); write_reg(g, 0x003c, 0x0701); write_reg(g, 0x003d, 0x000f); gfxSleepMilliseconds(50); /* delay 50 ms */ write_reg(g, 0x0050, 0x0000); write_reg(g, 0x0051, 0x00ef); write_reg(g, 0x0052, 0x0000); write_reg(g, 0x0053, 0x013f); write_reg(g, 0x0060, 0xa700); write_reg(g, 0x0061, 0x0001); write_reg(g, 0x006a, 0x0000); write_reg(g, 0x0080, 0x0000); write_reg(g, 0x0081, 0x0000); write_reg(g, 0x0082, 0x0000); write_reg(g, 0x0083, 0x0000); write_reg(g, 0x0084, 0x0000); write_reg(g, 0x0085, 0x0000); write_reg(g, 0x0090, 0x0010); write_reg(g, 0x0092, 0x0000); write_reg(g, 0x0093, 0x0003); write_reg(g, 0x0095, 0x0110); write_reg(g, 0x0097, 0x0000); write_reg(g, 0x0098, 0x0000); /* display on sequence */ write_reg(g, 0x0007, 0x0133); write_reg(g, 0x0020, 0x0000); write_reg(g, 0x0021, 0x0000); } gfxSleepMilliseconds(100); /* delay 50 ms */ // Finish Init post_init_board(g); // Release the bus release_bus(g); // Turn on the backlight set_backlight(g, GDISP_INITIAL_BACKLIGHT); /* Initialise the GDISP structure */ g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; g->g.Orientation = GDISP_ROTATE_0; g->g.Powermode = powerOn; g->g.Backlight = GDISP_INITIAL_BACKLIGHT; g->g.Contrast = GDISP_INITIAL_CONTRAST; return TRUE; }
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { uint16_t cver; // No private area for this controller g->priv = 0; // Initialise the board interface init_board(g); /* Hardware reset */ setpin_reset(g, TRUE); gfxSleepMicroseconds(1000); setpin_reset(g, FALSE); gfxSleepMicroseconds(1000); acquire_bus(g); write_index(g, 0); // Get controller version setreadmode(g); dummy_read(g); cver = read_data(g); setwritemode(g); // chinese code starts here write_reg(g, 0x00, 0x0001); gfxSleepMilliseconds(10); write_reg(g, 0x15, 0x0030); write_reg(g, 0x11, 0x0040); write_reg(g, 0x10, 0x1628); write_reg(g, 0x12, 0x0000); write_reg(g, 0x13, 0x104d); gfxSleepMilliseconds(10); write_reg(g, 0x12, 0x0010); gfxSleepMilliseconds(10); write_reg(g, 0x10, 0x2620); write_reg(g, 0x13, 0x344d); //304d gfxSleepMilliseconds(10); write_reg(g, 0x01, 0x0100); write_reg(g, 0x02, 0x0300); write_reg(g, 0x03, 0x1038);//0x1030 write_reg(g, 0x08, 0x0604); write_reg(g, 0x09, 0x0000); write_reg(g, 0x0A, 0x0008); write_reg(g, 0x41, 0x0002); write_reg(g, 0x60, 0x2700); write_reg(g, 0x61, 0x0001); write_reg(g, 0x90, 0x0182); write_reg(g, 0x93, 0x0001); write_reg(g, 0xa3, 0x0010); gfxSleepMilliseconds(10); //################# void Gamma_Set(void) ####################// write_reg(g, 0x30, 0x0000); write_reg(g, 0x31, 0x0502); write_reg(g, 0x32, 0x0307); write_reg(g, 0x33, 0x0305); write_reg(g, 0x34, 0x0004); write_reg(g, 0x35, 0x0402); write_reg(g, 0x36, 0x0707); write_reg(g, 0x37, 0x0503); write_reg(g, 0x38, 0x1505); write_reg(g, 0x39, 0x1505); gfxSleepMilliseconds(10); //################## void Display_ON(void) ####################// write_reg(g, 0x07, 0x0001); gfxSleepMilliseconds(10); write_reg(g, 0x07, 0x0021); write_reg(g, 0x07, 0x0023); gfxSleepMilliseconds(10); write_reg(g, 0x07, 0x0033); gfxSleepMilliseconds(10); write_reg(g, 0x07, 0x0133); // chinese code ends here // Finish Init post_init_board(g); // Release the bus release_bus(g); // Turn on the backlight set_backlight(g, GDISP_INITIAL_BACKLIGHT); /* Initialise the GDISP structure */ g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; g->g.Orientation = GDISP_ROTATE_0; g->g.Powermode = powerOn; g->g.Backlight = GDISP_INITIAL_BACKLIGHT; g->g.Contrast = GDISP_INITIAL_CONTRAST; return TRUE; }