ST7735 library, e.g. for Adafruit 1.8" TFT

Fork of ST7735_TFT by Jonne Valola

Fixed a few compiler warning and also some errors that were showing on my STM-F3 device.

Files at this revision

API Documentation at this revision

Comitter:
cbuss
Date:
Tue Aug 19 19:58:08 2014 +0000
Parent:
1:967235e6fd48
Commit message:
Resolved many small compiler warnings

Changed in this revision

ST7735_TFT.cpp Show annotated file Show diff for this revision Revisions of this file
ST7735_TFT.h Show annotated file Show diff for this revision Revisions of this file
diff -r 967235e6fd48 -r 264c52bc760c ST7735_TFT.cpp
--- a/ST7735_TFT.cpp	Sun Dec 11 21:18:21 2011 +0000
+++ b/ST7735_TFT.cpp	Tue Aug 19 19:58:08 2014 +0000
@@ -24,7 +24,7 @@
 #define BPP         16                  // Bits per pixel                
 
 ST7735_TFT::ST7735_TFT(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rs, PinName reset, const char *name)
-        : _spi(mosi, miso, sclk), _cs(cs), _rs(rs), _reset(reset),GraphicsDisplay(name) {
+        : GraphicsDisplay(name), _spi(mosi, miso, sclk), _cs(cs), _rs(rs), _reset(reset) {
     tft_reset();
     orientation = 2;
     char_x = 0;
@@ -172,11 +172,9 @@
 
 
 void ST7735_TFT::tft_reset() {
-    static unsigned short driverCode;
-    
     // init SPI
     _spi.format(8,3);                 // 8 bit spi mode 3
-    _spi.frequency(16000000);         // 16Mhz SPI clock ... 15Mhz is maximum for display, but it seems to work
+    _spi.frequency(8000000);         // 16Mhz SPI clock ... 15Mhz is maximum for display, but it seems to work
     
     // reset exactly like in Arduino version
     _cs = 0;
@@ -332,7 +330,7 @@
   _spi.format(8,3);
 }
 
-void ST7735_TFT::window (unsigned int x, unsigned int y, unsigned int w, unsigned int h) {
+void ST7735_TFT::window (int x, int y, int w, int h) {
   wr_cmd(ST7735_CASET);  // column addr set
   wr_dat(0x00);
   wr_dat(x+2);   // XSTART 
@@ -716,7 +714,7 @@
 
 
 void ST7735_TFT::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap) {
-    unsigned int    i,j,value;
+    unsigned int    i,j;
     unsigned short *bitmap_ptr = (unsigned short *)bitmap;
     window(x, y, w, h);
     wr_cmd(0x2C);
@@ -731,7 +729,7 @@
     wr_dat_stop();
 }
 
-
+/*
 int ST7735_TFT::BMP_16(unsigned int x, unsigned int y, const char *Name_BMP) {
 // BEWARE !
 // NOT TESTED
@@ -811,4 +809,4 @@
     free (line);
     fclose(Image);
     return(1);
-}
\ No newline at end of file
+}*/
diff -r 967235e6fd48 -r 264c52bc760c ST7735_TFT.h
--- a/ST7735_TFT.h	Sun Dec 11 21:18:21 2011 +0000
+++ b/ST7735_TFT.h	Tue Aug 19 19:58:08 2014 +0000
@@ -104,7 +104,7 @@
    * @param reset pin connected to RESET of display
    *
    */ 
-  ST7735_TFT(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rs, PinName reset,const char* name ="TFT");
+  ST7735_TFT(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName rs, PinName reset, const char* name ="TFT");
     
   /** Get the width of the screen in pixel
    *
@@ -190,7 +190,7 @@
    * @param x x-position (top left)
    * @param y y-position 
    */   
-  void locate(int x, int y);
+  void virtual locate(int x, int y);
     
   /** Fill the screen with _backgroun color
    *
@@ -203,7 +203,7 @@
    * depends on actual font size
    *
    */    
-  int columns(void);
+  virtual int columns(void);
     
   /** calculate the max number of columns
    *
@@ -211,7 +211,7 @@
    * depends on actual font size
    *
    */   
-  int rows(void);
+  virtual int rows(void);
     
   /** put a char on the screen
    *
@@ -219,7 +219,7 @@
    * @returns printed char
    *
    */
-  int _putc(int value);
+  virtual int _putc(int value);
     
   /** draw a character on given position out of the active font to the TFT
    *
@@ -337,7 +337,7 @@
    * @param w window width in pixel
    * @param h window height in pixels
    */    
-  void window (unsigned int x, unsigned int y, unsigned int w, unsigned int h);
+  virtual void window (int x, int y, int w, int h);
     
   /** Set draw window region to whole screen
    *