Behrooz Abdi
/
Tiger_LCD
Landtiger (LPC1768) graphics LCD demo.
Diff: GLCD.h
- Revision:
- 3:2dccfa0121de
- Parent:
- 2:43ede88fb5a3
- Child:
- 4:cdeea87f25d8
diff -r 43ede88fb5a3 -r 2dccfa0121de GLCD.h --- a/GLCD.h Tue Nov 06 21:39:33 2012 +0000 +++ b/GLCD.h Fri Oct 30 01:26:40 2015 +0000 @@ -13,7 +13,7 @@ /*------------------------------------------------------------------------------ Color coding - GLCD is coded: 15..11 red, 10..5 green, 4..0 blue (unsigned short) GLCD_R5, GLCD_G6, GLCD_B5 + GLCD is coded: 15..11 red, 10..5 green, 4..0 blue (uint16_t) GLCD_R5, GLCD_G6, GLCD_B5 original coding: 17..12 red, 11..6 green, 5..0 blue ORG_R6, ORG_G6, ORG_B6 ORG_R1..5 = GLCD_R0..4, ORG_R0 = GLCD_R4 @@ -59,53 +59,43 @@ #define ST7781_ID 0x7783 -#if(0) -/* GLCD Exported functions */ -extern void GLCD_Init (void); -extern unsigned short GLCD_DriverCode (); -extern void GLCD_WindowMax (void); -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_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); -extern void GLCD_ClearLn (unsigned int ln); -extern void GLCD_Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val); -extern void GLCD_Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap); -extern void GLCD_Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp); +class GLCD : public Stream { +//class GLCD { + public: + GLCD(void); + void init (void); + + // Stream implementation - provides printf() interface + // You would otherwise be forced to use writeChar() + virtual int _putc(int value) { writeChar(value); return 1;}; + virtual int _getc() { return -1; }; + + void setWindowMax (void); + void setWindow (int x1, int y1, int x2, int y2); + void drawPixel (unsigned int x, unsigned int y); + void drawPixel (unsigned int x, unsigned int y, uint16_t color); + void drawPixel (unsigned int x, unsigned int y, uint8_t r, uint8_t g, uint8_t b); + + void setColor (uint16_t color); + void setColor (uint8_t r, uint8_t g, uint8_t b); + void setBackColor (uint16_t color); + void setBackColor (uint8_t r, uint8_t g, uint8_t b); -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 + void clearScreen (uint16_t color); -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); +/** @brief Write single character to the display using the 8x8 fontable + * @brief Start at current cursor location + * @param char chr character to write +*/ + void writeChar (uint8_t chr); + void DrawChar (unsigned int x, unsigned int y, uint16_t *c); + void DisplayChar (uint16_t ln, uint16_t col, uint8_t c); + void DisplayString (uint16_t ln, uint16_t col, uint8_t *s); + void ClearLn (uint16_t 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 Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bitmap); + void Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, uint8_t *bmp); void drawHLine (int x, int y, int l); void drawVLine (int x, int y, int l); @@ -119,27 +109,28 @@ void lcdOff(); void lcdOn(); - void setContrast(char c); + void invertDisplay(bool i); + void setContrast(uint8_t c); int getDisplayXSize(); int getDisplayYSize(); - unsigned short getDriverCode (); - - unsigned short _textColor, _backColor; + uint16_t getDriverCode (); 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); + static __inline uint8_t _lcd_send (uint16_t data); + static __inline uint16_t _lcd_read (void); + static __inline void _wr_cmd (uint16_t c); + static __inline void _wr_dat (uint16_t c); + static __inline uint16_t _rd_dat (void); + static __inline void _wr_dat_start (void); + static __inline void _wr_dat_stop (void); + static __inline void _wr_dat_only (uint16_t c); + static __inline void _wr_reg (uint16_t reg, uint16_t val); + static __inline uint16_t _rd_reg (uint16_t reg); - unsigned short _driverCode; + uint16_t _driverCode; + uint16_t _textColor, _backColor; + uint16_t _col, _ln; }; #endif /* _GLCD_H */