Landtiger (LPC1768) graphics LCD demo.

Dependencies:   mbed

Revision:
2:43ede88fb5a3
Parent:
0:a8090b59eb05
Child:
3:2dccfa0121de
--- a/GLCD.h	Sun Nov 04 18:13:01 2012 +0000
+++ b/GLCD.h	Tue Nov 06 21:39:33 2012 +0000
@@ -39,13 +39,14 @@
 #define Yellow          0xFFE0      /* 255, 255, 0   */
 #define White           0xFFFF      /* 255, 255, 255 */
 
+// GLCD Controller IDs
+#define HX8347A_ID      0x0047
 #define HX8347D_ID      0x0047
-#define HX8347A_ID      0x0047
 #define ILI9320_ID      0x9320
 #define ILI9325_ID      0x9325
-//#define ILI9328_ID      0x9328
-#define testje 0x9328
-#define ILI9328_ID 0x9328
+#define ILI9325C_ID     0x9325
+#define ILI9325D_ID     0x9325
+#define ILI9328_ID      0x9328
 #define ILI9331_ID      0x9331
 #define LGDP4531_ID     0x4531
 #define LGDP4535_ID     0x4535
@@ -57,8 +58,8 @@
 #define SSD2119_ID      0x9919  
 #define ST7781_ID       0x7783
 
-// GLCD Controlled IDs
 
+#if(0)
 /* GLCD Exported functions   */   
 extern void GLCD_Init           (void);
 extern unsigned short GLCD_DriverCode ();
@@ -66,7 +67,7 @@
 extern void GLCD_PutPixel       (unsigned int x, unsigned int y);
 extern void GLCD_SetTextColor   (unsigned short color);
 extern void GLCD_SetBackColor   (unsigned short color);
-extern void GLCD_Clear          (unsigned short color);
+extern void GLCD_clearScreen    (unsigned short color);
 extern void GLCD_DrawChar       (unsigned int x, unsigned int y, unsigned short *c);
 extern void GLCD_DisplayChar    (unsigned int ln, unsigned int col, unsigned char  c);
 extern void GLCD_DisplayString  (unsigned int ln, unsigned int col, unsigned char *s);
@@ -78,5 +79,67 @@
 extern void GLCD_drawHLine      (int x, int y, int l);
 extern void GLCD_drawVLine      (int x, int y, int l);
 extern void GLCD_drawRect       (int x1, int y1, int x2, int y2);
+#endif
+
+
+class GLCD {
+  public:
+    GLCD(void);
+    void Init           (void);
+    void WindowMax      (void);
+    void Window         (int x1, int y1, int x2, int y2);    
+    void drawPixel      (unsigned int x, unsigned int y);
+    void drawPixel      (unsigned int x, unsigned int y, unsigned short color); 
+    void drawPixel      (unsigned int x, unsigned int y, uint8_t r, uint8_t g, uint8_t b); 
+    
+    void setColor       (unsigned short color);
+    void setColor       (uint8_t r, uint8_t g, uint8_t b);     
+    void setBackColor   (unsigned short color);
+    void setBackColor   (uint8_t r, uint8_t g, uint8_t b);     
+
+    void clearScreen    (unsigned short color);
+
+    void DrawChar       (unsigned int x, unsigned int y, unsigned short *c);
+    void DisplayChar    (unsigned int ln, unsigned int col, unsigned char  c);
+    void DisplayString  (unsigned int ln, unsigned int col, unsigned char *s);
+    void ClearLn        (unsigned int ln);
+    void Bargraph       (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val);
+    void Bitmap         (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap);
+    void Bmp            (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp);
+
+    void drawHLine      (int x, int y, int l);
+    void drawVLine      (int x, int y, int l);
+    void drawRect       (int x1, int y1, int x2, int y2);
+    void drawLine       (int x1, int y1, int x2, int y2);
+    void drawRoundRect  (int x1, int y1, int x2, int y2);
+    void fillRect       (int x1, int y1, int x2, int y2);
+    void fillRoundRect  (int x1, int y1, int x2, int y2);
+    void drawCircle     (int x, int y, int radius);
+    void fillCircle     (int x, int y, int radius);
+        
+    void lcdOff();
+    void lcdOn();
+    void setContrast(char c);
+    
+    int getDisplayXSize();
+    int getDisplayYSize();
+    unsigned short getDriverCode ();
+
+    unsigned short _textColor, _backColor;
+
+  private:
+    static __inline unsigned char lcd_send (unsigned short data);
+    static __inline unsigned short lcd_read (void);
+    static __inline void wr_cmd (unsigned char c);
+    static __inline void wr_dat (unsigned short c);
+    static __inline unsigned short rd_dat (void);
+    static __inline void wr_dat_start (void);
+    static __inline void wr_dat_stop (void);
+    static __inline void wr_dat_only (unsigned short c);
+    static __inline void wr_reg (unsigned char reg, unsigned short val);
+    static __inline unsigned short rd_reg (unsigned short reg); 
+
+    unsigned short _driverCode;
+};
 
 #endif /* _GLCD_H */