for TFT2P0327 aitendo.com 128*160 TFT LCD. LCD driver is S6D0151 Sumsung.

Dependents:   FRDM_tocos_x2_FIXED

Files at this revision

API Documentation at this revision

Comitter:
king33jp
Date:
Sun Oct 02 13:20:50 2016 +0000
Parent:
4:648a364412e4
Commit message:
all change fixed.; rectfill modify; reverse fix; and; orientation command added.; onley 0 and 2 is valid.

Changed in this revision

S6D0151_TFT.cpp Show annotated file Show diff for this revision Revisions of this file
S6D0151_TFT.h Show annotated file Show diff for this revision Revisions of this file
--- a/S6D0151_TFT.cpp	Sun Oct 02 13:03:41 2016 +0000
+++ b/S6D0151_TFT.cpp	Sun Oct 02 13:20:50 2016 +0000
@@ -71,9 +71,20 @@
     regwr( 0x0021 , addr );
 }
 
+void S6D0151_TFT::reverse(int rev){
+    if(rev == TFT_REVERSE_ON){
+        regwr(0x0007,0x0033); //DISPLAY CONTROL (R07h)
+    } else {
+        regwr(0x0007,0x0037); //DISPLAY CONTROL (R07h)
+    }
+    // X X X PT1 PT0 X X SPT X X GON DTE CL REV D1 D0
+    //GON=1,DTE=1 VGH/VGL Normal operation
+    //Rev bit mean Color reverse.
+    //REV=1 Displays all character and graphics display sections with Reverse
+    //D[1:0]=11 Display is RAM data
+}
 
 /**
-* 
 */
 void S6D0151_TFT::regwr(unsigned short reg,unsigned short dat){
     int data;
@@ -183,7 +194,6 @@
         //VRH[5:0]=1e=011110 VCIR_EXIN X 2.250 = 4.50V
     wait_ms(20);   
    
-//    regwr(0x0001,0x0014);   //DRIVER OUTPUT CONTROL (R01h)
     regwr(0x0001,0x0014);   //DRIVER OUTPUT CONTROL (R01h)
     // X X X DPL EPL SM GS SS X X X NL4 NL3 NL2 NL1 NL0
     // demo code was 0x0114,SS bit=1 is reverse horizontal.
@@ -652,7 +662,7 @@
     wr_dat_start();
     for (int p=0; p<pixel; p++) {
         _spi.write(color >> 8);
-        _spi.write(color);
+        _spi.write(color & 0xFF);
     }
     wr_dat_stop();
     return;
--- a/S6D0151_TFT.h	Sun Oct 02 13:03:41 2016 +0000
+++ b/S6D0151_TFT.h	Sun Oct 02 13:20:50 2016 +0000
@@ -31,6 +31,9 @@
 #define Orange          0xFD20      /* 255, 165,   0 */
 #define GreenYellow     0xAFE5      /* 173, 255,  47 */
 
+#define TFT_REVERSE_ON  0
+#define TFT_REVERSE_OFF 1
+
 class S6D0151_TFT : public GraphicsDisplay {
  public:
 
@@ -213,7 +216,13 @@
    *
    */  
   void set_orientation(unsigned int o);
-    
+  
+  /** set TFT display image reverse
+   * @param rev  TFT_REVERSE_ON , TFT_REVERSE_OFF
+   * for daylight,maybe you need reverse on.
+   */
+  void reverse(int rev);
+  
   SPI _spi;
   DigitalOut _cs;
   DigitalOut _reset;