A lib for accessing ST7626 based lcds. It provides a set_pixel function. It is only tested with one display.
Diff: lcd.c
- Revision:
- 1:ae0b4880e9db
- Parent:
- 0:9b24f296bc0e
- Child:
- 2:04fb8af3ecb0
--- a/lcd.c Sun Dec 26 22:44:22 2010 +0000 +++ b/lcd.c Sat Jan 08 19:17:57 2011 +0000 @@ -2,7 +2,10 @@ #define lcd_c lcd_c #include "lcd.h" +#ifdef LCD_BACKLIGHT_LED DigitalOut lcd_led(LCD_LED); +#endif + DigitalOut lcd_a0(LCD_A0); DigitalOut lcd_cs(LCD_CS); DigitalOut lcd_wr(LCD_WR); @@ -103,10 +106,10 @@ void ST7626_Init(void) { lcd_cs = 1; -/* lcd_reset = 0; - wait_ms(10); - lcd_reset = 1; - wait_ms(50);*/ + /* lcd_reset = 0; + wait_ms(10); + lcd_reset = 1; + wait_ms(50);*/ resetdisp(); Write(COMMAND, 0x30); // Ext = 0 @@ -130,7 +133,7 @@ Write(DATA, 0x04); // Booster X 5 Write(COMMAND, 0x30); // Ext = 0 Write(COMMAND, 0x81); // Electronic Volume Control - Write(DATA, 0x2d); // EV:Vop[5:0]_6bit + Write(DATA, 0x1d); // EV:Vop[5:0]_6bit //previously Write(DATA,0x2D); Write(DATA, 0x02); // EV:Vop[8:6]_3bit // Vop is 10.52V under this condition for example Write( COMMAND, 0x20); // Power Control @@ -154,39 +157,30 @@ Write(DATA, 0x5f); // to column address 97 Write(COMMAND, 0xaf); // Display On Write(COMMAND, 0x30); // Ext = 0 - +#ifdef LCD_BACKLIGHT_LED lcd_led = 1; -} - -void Display1(void) { - unsigned char i, j; - Write(COMMAND, 0x30); // Ext = 0 - Write(COMMAND, 0x15); // Column address set - Write(DATA, 0); // From column address 0 to 97 - Write(DATA, 97 ); - Write(COMMAND, 0x75); // Page address set - Write(DATA, 0); // From page address 0 to 67 - Write(DATA, 67); - Write(COMMAND, 0x5c); // Entry Memory Write Mode - - for (j = 0; j < 68 ; j++) { - for (i = 0 ; i < 98 ; i++) { - if (j<=22) { - Write(DATA, 0xF8); - Write(DATA, 0x00); - } else if ((j>22)&&(j<44)) { - Write(DATA, 0x07); - Write(DATA, 0xE0); - } else { - Write(DATA, 0x00); - Write(DATA, 0x1F); - } - } - } +#endif } -void LCD_clear(unsigned int GroundColor) { +void lcd_putpixel(int16_t color, int x, int y) { + Write(COMMAND, 0x30); // Ext = 0 + Write(COMMAND, 0x15); // Column address set + Write(DATA, x); // From column address 0 to 97 + Write(DATA, x+1 ); + Write(COMMAND, 0x75); // Page address set + Write(DATA, y); // From page address 0 to 67 + Write(DATA, y+1); + Write(COMMAND, 0x5c); // Entry Memory Write Mode + + Write(DATA, (int8_t)(color&0xFF)); + Write(DATA, (int8_t)((color>>8)&0xFF)); +} + + + + +void LCD_clear(int16_t GroundColor) { //Display schwarz malen f�r Schrift Vorbereitung unsigned char i, j; Write(COMMAND, 0x30); // Ext = 0 @@ -202,17 +196,12 @@ for (j = 0; j < 68 ; j++) { for (i = 0 ; i < 98 ; i++) { Write(DATA, GroundColor); - Write(DATA, GroundColor); + Write(DATA, GroundColor>>8); } } } -void test_data(int data) { - lcd_data_l = data << 23; //low nibble - lcd_data_h = data >> 4; //high nibble -} - -void Write(unsigned char mode, unsigned char data) { +void Write(unsigned char mode, int8_t data) { if (mode) { lcd_a0 = 1; // LCD_PORT_COM |= (1<<LCD_A0);//A0=1; } else {