output

Dependencies:   images mbed

Fork of display by madhu sudhana

Revision:
1:b64c81071d96
Parent:
0:c0be4e018a09
Child:
2:e7a5b9bc75b4
--- a/ili9163lcd.h	Sat Jun 14 02:27:06 2014 +0000
+++ b/ili9163lcd.h	Sat Feb 28 20:26:45 2015 +0000
@@ -32,6 +32,14 @@
 #ifndef ILI9163LCD_H_
 #define ILI9163LCD_H_
 
+#include "mbed.h"
+#include "font5x8.h"
+#include "font8x8.h"
+#include "font5x12.h"
+#include "font11x16.h"
+#include "font12x12.h"
+#include "font24x23.h"
+
 // Definitions for control lines (port C)
 #define LCD_WR      (1 << 2)
 #define LCD_RS      (1 << 4)
@@ -49,6 +57,30 @@
 #define LCD_ORIENTATION2    160
 #define LCD_ORIENTATION3    192
 
+// eine Farbe belegt 5 Bit, 
+// die Farbe Grün wird 6 bit nch links geshiftet 
+// die Farbe Blau wird 11 bit nach links geshiftet
+// some RGB color definitions      BLUE GREEN  RED                          
+#define Black           0x0000      /*  0, 0, 0 */
+#define Navy            0x000F      /*  0, 0,15 */
+#define DarkGreen       0x03C0      /*  0,15, 0 */
+#define DarkCyan        0x03EF                          /*   0, 128, 128 */
+#define Maroon          0x7800      /* 15, 0, 0 */
+#define Purple          0x780F                          /* 128,   0, 128 */
+#define Olive           0x7BE0                          /* 128, 128,   0 */
+#define LightGrey       0xC618                          /* 192, 192, 192 */
+#define DarkGrey        0x7BEF                          /* 128, 128, 128 */
+#define Red             0x001F      /*  0, 0,31 */
+#define Green           0x07C0      /*  0,31, 0 */
+#define Cyan            0x07DF      /*  0,31,31 */
+#define Blue            0xF800      /* 31, 0, 0 */
+#define Yellow          0xF81F      /* 31, 0,31 */
+#define Magenta         0xFFC0      /* 31,31, 0 */
+#define White           0xFFFF      /* 31,31,31 */
+#define Orange          0xFD20                          /* 255, 165,   0 */
+#define GreenYellow     0xAFE5                          /* 173, 255,  47 */
+#define LightBlue       0x04FF
+
 // ILI9163 LCD Controller Commands
 #define NOP                     0x00
 #define SOFT_RESET              0x01
@@ -112,39 +144,88 @@
 #define NEGATIVE_GAMMA_CORRECT  0xE1
 #define GAM_R_SEL               0xF2
 
-// Macros and in-lines:
+
+class ILI9163 {
+ public:
+
+  // Das ILI9163 Objekt anlegen
+  //
+  // @param D2 SCK_
+  // @param D3 SDA
+  // @param D4 A0_
+  // @param D5 RESET    pin connected to RESET of display 
+  // @param D6 CS       cs pin connected to CS of display 
+  //
+  // ILI9163 tft(D2,D3,D4,D5,D6);
+  //
+  ILI9163(PinName SCK, PinName SDA, PinName A0, PinName RESET, PinName CS);
 
-// Translates a 3 byte RGB value into a 2 byte value for the LCD (values should be 0-31)
-inline uint16_t decodeRgbValue(uint8_t r, uint8_t g, uint8_t b)
-{
+  DigitalOut SCK_;
+  DigitalOut SDA_;
+  DigitalOut A0_;
+  DigitalOut RESET_;
+  DigitalOut CS_;
+
+  uint8_t tm;
+  uint8_t R,G,B;
+  uint8_t RGB_state;
+    
+  // font Array
+  unsigned char* font;
+  uint8_t font_bp_char;      // Bytes pro Zeichen
+  uint8_t font_hor;          // Bytes Horizontal
+  uint8_t font_vert;         // Bytes Vertikal
+  uint8_t font_bp_line;      // Bytes pro Zeile
+  uint8_t font_size;         // Vergrößerung des Zeichens
+  // Macros and in-lines:
+
+  // Translates a 3 byte RGB value into a 2 byte value for the LCD (values should be 0-31)
+  inline uint16_t decodeRgbValue(uint8_t r, uint8_t g, uint8_t b)
+  {
     return (b << 11) | (g << 6) | (r);
-}   
-
-// This routine takes a row number from 0 to 20 and
-// returns the x coordinate on the screen (0-127) to make
-// it easy to place text
-inline uint8_t lcdTextX(uint8_t x) { return x*6; }
+  }   
 
-// This routine takes a column number from 0 to 20 and
-// returns the y coordinate on the screen (0-127) to make
-// it easy to place text
-inline uint8_t lcdTextY(uint8_t y) { return y*8; }
+  // This routine takes a row number from 0 to 20 and
+  // returns the x coordinate on the screen (0-127) to make
+  // it easy to place text
+  inline uint8_t lcdTextX(uint8_t x) { return x*font_vert; }
+
+  // This routine takes a column number from 0 to 20 and
+  // returns the y coordinate on the screen (0-127) to make
+  // it easy to place text
+  inline uint8_t lcdTextY(uint8_t y) { return y*font_hor; }
+
+  //  LCD function prototypes
+  void lcdReset(void);
+  void lcdWriteCommand(uint8_t address);
+  void lcdWriteParameter(uint8_t parameter);
+  void lcdWriteData(uint8_t dataByte1, uint8_t dataByte2);
+  void lcdInitialise(uint8_t orientation);
 
-//  LCD function prototypes
-void lcdReset(void);
-void lcdWriteCommand(uint8_t address);
-void lcdWriteParameter(uint8_t parameter);
-void lcdWriteData(uint8_t dataByte1, uint8_t dataByte2);
-void lcdInitialise(uint8_t orientation);
+  void lcdClearDisplay(uint16_t colour);
+  void lcdPlot(uint8_t x, uint8_t y, uint16_t colour);
+  void lcdLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour);
+  void lcdRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour);
+  void lcdFilledRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour);
+  void lcdCircle(int16_t xCentre, int16_t yCentre, int16_t radius, uint16_t colour);
 
-void lcdClearDisplay(uint16_t colour);
-void lcdPlot(uint8_t x, uint8_t y, uint16_t colour);
-void lcdLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour);
-void lcdRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour);
-void lcdFilledRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t colour);
-void lcdCircle(int16_t xCentre, int16_t yCentre, int16_t radius, uint16_t colour);
+  // select the font to use
+  //
+  // @param f pointer to font array 
+  //                                                                              
+  //   font array can created with GLCD Font Creator from http://www.mikroe.com
+  //   you have to add 4 parameter at the beginning of the font array to use: 
+  //   - the number of byte / char
+  //   - the vertial size in pixel
+  //   - the horizontal size in pixel
+  //   - the number of byte per vertical line
+  //   you also have to change the array to char[]
+  // 
+  void set_font(unsigned char* f);
+  
+  void lcdPutCh(unsigned char character, uint8_t x, uint8_t y, uint16_t fgColour, uint16_t bgColour);
+  void lcdPutS(const char *string, uint8_t x, uint8_t y, uint16_t fgColour, uint16_t bgColour);
 
-void lcdPutCh(unsigned char character, uint8_t x, uint8_t y, uint16_t fgColour, uint16_t bgColour);
-void lcdPutS(const char *string, uint8_t x, uint8_t y, uint16_t fgColour, uint16_t bgColour);
+};  // end class
 
 #endif /* ILI9163LCD_H_ */