Library for 1.8 inch 160*180 TFT Display. Nice fonts in different formats.

Revision:
1:6a6d8d2b19f1
Parent:
0:3015b613b20d
Child:
2:291ac9fb4d64
--- a/ST7735.cpp	Sat Aug 15 10:58:51 2015 +0000
+++ b/ST7735.cpp	Sat Aug 15 11:59:03 2015 +0000
@@ -25,14 +25,17 @@
 ST7735::ST7735(PinName cePin, PinName dcPin, PinName mosiPin, PinName sclkPin)
 {
     spi = new SPI(mosiPin, NC, sclkPin); // create new SPI instance and initialise
-    initSPI();
+    initSPI();    
     
     // set up other pins as required
     ce = new DigitalOut(cePin,1);
     dc = new DigitalOut(dcPin,0);
 
-
-}
+    // Defaults after power-up
+    textsize = 1; 
+    textcolor = ST7735_GREEN;
+    textbgcolor = ST7735_BLACK;
+ }
 
 // function to initialise SPI peripheral
 void ST7735::initSPI()
@@ -226,7 +229,7 @@
 
 // Initialization code common to both 'B' and 'R' type displays
 void ST7735::commonInit(const uint8_t *cmdList){
-  wait_ms(50);   // Wait for reset to be stable after power-up
+  wait_ms(100);   // Wait for reset to be stable after power-up
   colstart  = rowstart = 0; // May be overridden in init func
   if(cmdList) commandList(cmdList);
 }
@@ -780,7 +783,7 @@
 int w = (width+7)/8;
 int pX      = 0;
 int pY      = y;
-int color   = 0;
+//int color   = 0;
 char line = 0;
 
 //fillRect(x,pY,width+gap,height,textbgcolor);
@@ -1032,3 +1035,19 @@
     return sumX;
 }
 
+void ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {
+
+  writecommand(ST7735_CASET); // Column addr set
+  writedata(0x00);
+  writedata(x0+colstart);     // XSTART 
+  writedata(0x00);
+  writedata(x1+colstart);     // XEND
+
+  writecommand(ST7735_RASET); // Row addr set
+  writedata(0x00);
+  writedata(y0+rowstart);     // YSTART
+  writedata(0x00);
+  writedata(y1+rowstart);     // YEND
+
+  writecommand(ST7735_RAMWR); // write to RAM
+}