Fork of David Smart's RA8875 library for the purpose of adding touch screen support

Fork of RA8875 by David Smart

Revision:
53:86d24b9480b9
Parent:
52:e6039a823420
Child:
54:e117ad10fba6
--- a/RA8875.cpp	Sat Mar 15 18:24:35 2014 +0000
+++ b/RA8875.cpp	Mon Mar 17 11:29:40 2014 +0000
@@ -87,10 +87,15 @@
 }
 
 
-RetCode_t RA8875::SetLayerMode(uint8_t mode)
+RetCode_t RA8875::SetLayerMode(LayerMode_T mode)
 {
-    WriteCommand(0x52, mode);
-    return noerror;
+    unsigned char ltpr0 = ReadCommand(0x52) & ~0x7; // retain all but the display layer mode
+    if (mode <= (LayerMode_T)6) {
+        WriteCommand(0x52, ltpr0 | (mode & 0x7));
+        return noerror;
+    } else {
+        return bad_parameter;
+    }
 }
 
 
@@ -105,6 +110,15 @@
 }
 
 
+RetCode_t RA8875::SetBackgroundTransparencyColor(color_t color)
+{
+    WriteCommand(0x67, (color >> 11) & 0x1F);
+    WriteCommand(0x68, (color >> 5) & 0x3F);
+    WriteCommand(0x69, (color & 0x1F));
+    return noerror;
+}
+
+
 #ifdef PERF_METRICS
 void RA8875::ClearPerformance()
 {
@@ -1225,35 +1239,35 @@
     
     // visible, non-blinking
     display.SetTextCursor(0,20);
-    display.SetTextCursorControl(IBEAM, false);
+    display.SetTextCursorControl(RA8875::IBEAM, false);
     p = iCursor;
     while (*p) {
         display._putc(*p++);
         wait_ms(delay);
     }
 
-    display.SetTextCursorControl(UNDER, false);
+    display.SetTextCursorControl(RA8875::UNDER, false);
     p = uCursor;
     while (*p) {
         display._putc(*p++);
         wait_ms(delay);
     }
     
-    display.SetTextCursorControl(BLOCK, false);
+    display.SetTextCursorControl(RA8875::BLOCK, false);
     p = bCursor;
     while (*p) {
         display._putc(*p++);
         wait_ms(delay);
     }
 
-    display.SetTextCursorControl(BLOCK, true);
+    display.SetTextCursorControl(RA8875::BLOCK, true);
     p = bbCursor;
     while (*p) {
         display._putc(*p++);
         wait_ms(delay);
     }
     wait_ms(delay * 20);
-    display.SetTextCursorControl(NOCURSOR, false);
+    display.SetTextCursorControl(RA8875::NOCURSOR, false);
 }
 
 
@@ -1477,15 +1491,15 @@
         if (!SuppressSlowStuff)
             wait_ms(20);
     }
-    display.SetLayerMode(1);        // Show it after the build-up
+    display.SetLayerMode(RA8875::OnlyLayer2);        // Show it after the build-up
     if (!SuppressSlowStuff)
         wait_ms(2000);
 
     display.SelectDrawingLayer(0);
-    display.SetLayerMode(0);        // Show Layer 0 again
+    display.SetLayerMode(RA8875::OnlyLayer1);        // Show Layer 0 again
     if (!SuppressSlowStuff)
         wait_ms(1000);
-    display.SetLayerMode(3);        // Transparent mode
+    display.SetLayerMode(RA8875::TransparentMode);        // Transparent mode
     if (!SuppressSlowStuff)
         wait_ms(1000);
     for (i=0; i<=8; i++) {
@@ -1496,7 +1510,7 @@
     
     // Restore before we exit
     display.SetLayerTransparency(0, 0);
-    display.SetLayerMode(0);        // Restore to layer 0
+    display.SetLayerMode(RA8875::OnlyLayer1);        // Restore to layer 0
 }