Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Adafruit_ST7735 by
Revision 6:f572731fc65f, committed 2015-03-03
- Comitter:
 - perezalvarezhi
 - Date:
 - Tue Mar 03 21:03:37 2015 +0000
 - Parent:
 - 5:57e689b2af4f
 - Commit message:
 - ReturnedToOldRTC
 
Changed in this revision
| Adafruit_ST7735.cpp | Show annotated file Show diff for this revision Revisions of this file | 
--- a/Adafruit_ST7735.cpp	Tue Mar 03 20:20:07 2015 +0000
+++ b/Adafruit_ST7735.cpp	Tue Mar 03 21:03:37 2015 +0000
@@ -40,20 +40,17 @@
 void Adafruit_ST7735::writecommand(uint8_t c)
 {
     _rs = 0;
-    
-    _cs = 0;
+    chipEnable();
     spi_port.write( c );
-    _cs = 1;
+    chipDisable();
 }
 
-
 void Adafruit_ST7735::writedata(uint8_t c)
 {
     _rs = 1;
-    _cs = 0;
+    chipEnable();
     spi_port.write( c );
-
-    _cs = 1;
+    chipDisable();
 }
 
 
@@ -240,18 +237,18 @@
 // Initialization code common to both 'B' and 'R' type displays
 void Adafruit_ST7735::commonInit(uint8_t *cmdList)
 {
-
+    
     colstart  = rowstart = 0; // May be overridden in init func
 
     _rs = 1;
-    _cs = 1;
+    chipDisable();
 
     // use default SPI format
     spi_port.format(8,3);
     spi_port.frequency(24000000);     // Lets try 48MHz
 
     // toggle RST low to reset; CS low so it'll listen to us
-    _cs = 0;
+    chipEnable();
     _rst = 1;
     wait_ms(50);
     _rst = 0;
@@ -348,7 +345,7 @@
     setAddrWindow(0, 0, _width-1, _height-1);
 
     _rs = 1;
-    _cs = 0;
+    chipEnable();
 
     for(y=_height; y>0; y--) {
         for(x=_width; x>0; x--) {
@@ -357,18 +354,18 @@
         }
     }
 
-    _cs = 1;
+    chipDisable();
 }
 
 
 void Adafruit_ST7735::pushColor(uint16_t color)
 {
     _rs = 1;
-    _cs = 0;
+    chipEnable();
 
     spi_port.write( color >> 8 );
     spi_port.write( color );
-    _cs = 1;
+    chipDisable();
 }
 
 
@@ -380,12 +377,12 @@
     setAddrWindow(x,y,x+1,y+1);
 
     _rs = 1;
-    _cs = 0;
+    chipEnable();
 
     spi_port.write( color >> 8 );
     spi_port.write( color );
 
-    _cs = 1;
+    chipDisable();
 }
 
 
@@ -400,12 +397,12 @@
 
     uint8_t hi = color >> 8, lo = color;
     _rs = 1;
-    _cs = 0;
+    chipEnable();
     while (h--) {
         spi_port.write( hi );
         spi_port.write( lo );
     }
-    _cs = 1;
+    chipDisable();
 }
 
 
@@ -420,12 +417,12 @@
 
     uint8_t hi = color >> 8, lo = color;
     _rs = 1;
-    _cs = 0;
+    chipEnable();
     while (w--) {
         spi_port.write( hi );
         spi_port.write( lo );
     }
-    _cs = 1;
+    chipDisable();
 }
 
 
@@ -443,7 +440,7 @@
 
     uint8_t hi = color >> 8, lo = color;
     _rs = 1;
-    _cs = 0;
+    chipEnable();
     for(y=h; y>0; y--) {
         for(x=w; x>0; x--) {
             spi_port.write( hi );
@@ -451,7 +448,7 @@
         }
     }
 
-    _cs = 1;
+    chipDisable();
 }
 
 
@@ -468,15 +465,14 @@
     setAddrWindow(x, y, x+w-1, y+h-1);
 
     _rs = 1;
-    _cs = 0;
+    chipEnable();
     for(y=0; y<h; y++) {
         for(x=0; x<w; x++) {
             spi_port.write( map[ y*w*2 + x*2 ] );
             spi_port.write( map[ y*w*2 + x*2 + 1] );
         }
     }
-
-    _cs = 1;
+    chipDisable();
 }
 
 // fill a rectangle
@@ -512,7 +508,7 @@
     }
 
     _rs = 1;
-    _cs = 0;
+    chipEnable();
     for(yy=0; yy<dh; yy++) {
         for(xx=0; xx<dw; xx++) {       
             if( xx+x >= 0){
@@ -526,7 +522,7 @@
             }
         }
     }
-    _cs = 1;
+    chipDisable();
 }
 
 // Pass 8-bit (each) R,G,B, get back 16-bit packed color
    