Add TFT commands

Fork of DigoleSerialDisp by Michael Shimniok

Files at this revision

API Documentation at this revision

Comitter:
pinfred
Date:
Fri Nov 11 20:40:55 2016 +0000
Parent:
6:3ed9cddf46d0
Commit message:
add for write return code

Changed in this revision

DigoleSerialDisp.cpp Show annotated file Show diff for this revision Revisions of this file
DigoleSerialDisp.h Show annotated file Show diff for this revision Revisions of this file
--- a/DigoleSerialDisp.cpp	Fri Nov 04 14:08:18 2016 +0000
+++ b/DigoleSerialDisp.cpp	Fri Nov 11 20:40:55 2016 +0000
@@ -46,8 +46,12 @@
 {
     int len = 0;
     if (buffer != NULL) {
-        _device.write(_address, (char *) buffer, size);
-        len = size;
+        len = _device.write(_address, (char *) buffer, size);
+        if (len == 0){
+            len = size;
+        }else{
+            len = -1;
+        }
         delay(7);
     }
     return len;
@@ -341,22 +345,19 @@
     write(w);
     write(h);
     for (int j = 0; j < h * ((w >> 3) + i); j++) {
-        write( (const char *) (bitmap+j) );
+        write( bitmap[j] );
         delay(1);
     }
 }
 
 void DigoleSerialDisp::drawBitmap256(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *bitmap) {
-    uint8_t i = 0;
-    if ((w & 7) != 0)
-        i = 1;
     write("EDIM1");
     write(x); //x;
     write(y);
     write(w);
     write(h);
     for (int j = 0; j < h * w; j++) {
-        write((const char *) (bitmap+j));
+        write(bitmap[j]);
         delay(1);
     }
 }
@@ -495,9 +496,12 @@
 }
 
 
-void DigoleSerialDisp::displayStartScreen(uint8_t m) {
-    write("DSS");
+int DigoleSerialDisp::displayStartScreen(uint8_t m) {
+    int ret =0;
+    ret = write("DSS");
+    if (ret == -1) return -1;
     write(m);
+    return 0;
 } //display start screen
 
 
@@ -538,6 +542,24 @@
 }
 
 
+void DigoleSerialDisp::setDrawWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {      
+    write("DWWIN");
+    write(x);
+    write(y);
+    write(w);
+    write(h);
+}
+
+void DigoleSerialDisp::resetDrawWindow() {      
+    write("RSTDW");
+}
+
+void DigoleSerialDisp::cleanDrawWindow() {      
+    write("WINC");
+}
+
+
+
 void DigoleSerialDisp::uploadStartScreen(int lon, const unsigned char *data) 
 {
     int j;
--- a/DigoleSerialDisp.h	Fri Nov 04 14:08:18 2016 +0000
+++ b/DigoleSerialDisp.h	Fri Nov 11 20:40:55 2016 +0000
@@ -6,6 +6,7 @@
 #define DigoleSerialDisp_h
 
 #include "mbed.h"
+#include "rtos.h"
 #include <inttypes.h>
 
 #define DEC 10
@@ -13,7 +14,7 @@
 #define OCT 8
 #define BIN 2
 
-#define delay(x) wait_ms(x)
+#define delay(x) Thread::wait(x)
 
 // Communication set up command
 // Text function command
@@ -311,7 +312,7 @@
     void moveArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, char xoffset, char yoffset);
 
     /** Display startup screen */
-    void displayStartScreen(uint8_t m);
+    int displayStartScreen(uint8_t m);
     
     /** Set display mode */
     void setMode(uint8_t m);
@@ -325,6 +326,10 @@
     /** Only for universal serial adapter */
     void setLCDChip(uint8_t chip);
 
+    void setDrawWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);
+    void resetDrawWindow();
+    void cleanDrawWindow();
+
 
     /** Set Start Screen, 1st B is the lower byte of data length. 
      * Convert images to C array here: <a href="http://www.digole.com/tools/PicturetoC_Hex_converter.php">http://www.digole.com/tools/PicturetoC_Hex_converter.php</a>