A lib for accessing ST7626 based lcds. It provides a set_pixel function. It is only tested with one display.

Files at this revision

API Documentation at this revision

Comitter:
nullsub
Date:
Sun Jan 09 22:04:01 2011 +0000
Parent:
4:a4925df73101
Commit message:

Changed in this revision

font.c Show annotated file Show diff for this revision Revisions of this file
lcd.c Show annotated file Show diff for this revision Revisions of this file
lcd.h Show annotated file Show diff for this revision Revisions of this file
diff -r a4925df73101 -r 70dcbb284628 font.c
--- a/font.c	Sat Jan 08 23:13:52 2011 +0000
+++ b/font.c	Sun Jan 09 22:04:01 2011 +0000
@@ -1,7 +1,7 @@
 
 #include "lcd.h"
 
-#define BACKROUND_COLOR 0xFF
+#define BACKROUND_COLOR 0xFFFF
 
 
 void Display5x7Font(char letter, char x, char y, int16_t color) {
@@ -18,19 +18,16 @@
 
     int sign = (letter - 0x20) * 5;
     unsigned char pos = 0x01;
-    unsigned char ColorHigh, ColorLow;
     for (i = 0; i < 8 ; i++) {
         for (j = 0 ; j < 5 ; j++) { //FIXME: is this  aBUUUG?????
             char pixel = Font5x7[sign+j] & pos;
             if (pixel) {
-                ColorHigh = color;
-                ColorLow = color >> 8;
+                Write(DATA, (int8_t) color>>8);
+                Write(DATA, (int8_t) color);
             } else {
-                ColorHigh = BACKROUND_COLOR;
-                ColorLow = BACKROUND_COLOR;
+                Write(DATA,(int8_t) (BACKROUND_COLOR>>8));
+                Write(DATA,(int8_t) (BACKROUND_COLOR));
             }
-            Write(DATA, ColorHigh);
-            Write(DATA, ColorLow);
         }
         if (pos < 0x80) {
             pos = pos << 1;
@@ -56,19 +53,16 @@
 
     int sign = (letter - 0x20) * 5;
     unsigned char pos = 0x01;
-    unsigned char ColorHigh, ColorLow;
     for (i = 0; i < 8 ; i++) {
         for (j = 0 ; j < 5 ; j++) {
             char pixel = AnotherFont5x7[sign+j] & pos;
             if (pixel) {
-                ColorHigh = color;
-                ColorLow = color>>8 ;
+                Write(DATA, (int8_t) (color>>8));
+                Write(DATA, (int8_t) (color));
             } else {
-                ColorHigh = BACKROUND_COLOR;
-                ColorLow = BACKROUND_COLOR;
+                Write(DATA,(int8_t) (BACKROUND_COLOR>>8));
+                Write(DATA,(int8_t) (BACKROUND_COLOR));
             }
-            Write(DATA, ColorHigh);
-            Write(DATA, ColorLow);
         }
         if (pos < 0x80) {
             pos = pos << 1;
@@ -94,19 +88,16 @@
 
     int sign = (letter - 0x20) * 24;
     unsigned char pos = 0x01;
-    unsigned char ColorHigh, ColorLow;
     for (i = 0; i < 8 ; i++) {
         for (j = 0 ; j < 12 ; j++) {
             char pixel = Font12x16[sign+(j*2)] & pos;
             if (pixel) {
-                ColorHigh = color ;
-                ColorLow = color >>8;
+                Write(DATA, (int8_t) (color>>8));
+                Write(DATA, (int8_t) (color));
             } else {
-                ColorHigh = BACKROUND_COLOR;
-                ColorLow = BACKROUND_COLOR;
+                Write(DATA,(int8_t) (BACKROUND_COLOR>>8));
+                Write(DATA,(int8_t) (BACKROUND_COLOR));
             }
-            Write(DATA, ColorHigh);
-            Write(DATA, ColorLow);
         }
         if (pos < 0x80) {
             pos = pos << 1;
@@ -132,14 +123,12 @@
         for (j = 0 ; j < 12 ; j++) {
             char pixel = Font12x16[sign+(j*2)+1] & pos;
             if (pixel) {
-                ColorHigh = color;
-                ColorLow = color >> 8;
+                Write(DATA, (int8_t) (color>>8));
+                Write(DATA, (int8_t) (color));
             } else {
-                ColorHigh = BACKROUND_COLOR;
-                ColorLow = BACKROUND_COLOR;
+                Write(DATA,(int8_t) (BACKROUND_COLOR>>8));
+                Write(DATA,(int8_t) (BACKROUND_COLOR));
             }
-            Write(DATA, ColorHigh);
-            Write(DATA, ColorLow);
         }
         if (pos < 0x80) {
             pos = pos << 1;
diff -r a4925df73101 -r 70dcbb284628 lcd.c
--- a/lcd.c	Sat Jan 08 23:13:52 2011 +0000
+++ b/lcd.c	Sun Jan 09 22:04:01 2011 +0000
@@ -161,7 +161,7 @@
 }
 
 
-void lcd_putpixel( int x, int y, int16_t color){
+void lcd_putpixel( int x, int y, int16_t color) {
     Write(COMMAND, 0x30);                    // Ext = 0
     Write(COMMAND, 0x15);                    // Column address set
     Write(DATA, x);                          // From column address 0 to 97
@@ -171,15 +171,15 @@
     Write(DATA, y+1);
     Write(COMMAND, 0x5c);                     // Entry Memory Write Mode
 
-    Write(DATA, (int8_t)(color&0xFF));
-    Write(DATA, (int8_t)((color>>8)&0xFF));
+    Write(DATA, (int8_t) (color>>8));
+    Write(DATA, (int8_t) (color));
+
 }
 
 
 
 
-void LCD_clear(int16_t GroundColor) {
-    //Display schwarz malen f&#65533;r Schrift Vorbereitung
+void lcd_clear(int16_t GroundColor) {
     unsigned char i, j;
     Write(COMMAND, 0x30);                    // Ext = 0
     Write(COMMAND, 0x15);                    // Column address set
@@ -193,8 +193,9 @@
 
     for (j = 0; j < 68 ; j++) {
         for (i = 0 ; i < 98 ; i++) {
-            Write(DATA, GroundColor);
-            Write(DATA, GroundColor>>8);
+            Write(DATA, (int8_t) (GroundColor>>8));
+            Write(DATA, (int8_t) (GroundColor));
+            
         }
     }
 }
diff -r a4925df73101 -r 70dcbb284628 lcd.h
--- a/lcd.h	Sat Jan 08 23:13:52 2011 +0000
+++ b/lcd.h	Sun Jan 09 22:04:01 2011 +0000
@@ -1,5 +1,5 @@
-#ifndef lcd_h
-#define lcd_h lcd_h
+#ifndef LCD_H_
+#define LCD_H_ LCD_H_
 
 #include <mbed.h>
 
@@ -10,7 +10,7 @@
 #define COLOR_WHITE 0xFFFF
 #define COLOR_BLUE  0x0000
 #define COLOR_GREEN 0x0000
-#define COLOR_RED   0x0000
+#define COLOR_RED   0xF800
 
 
 #undef LCD_BACKLIGHT_LED
@@ -38,7 +38,7 @@
 void LoadEEPROM(void);
 void ST7626_Init(void);
 void lcd_putpixel( int x, int y, int16_t color);
-void LCD_clear(int16_t GroundColor);
+void lcd_clear(int16_t GroundColor);
 void Write(unsigned char , int8_t ); //mode (befehl oder daten) & die Daten.
 void resetdisp(void);
 void LcdLoop();