AMart_SSD447_light sensor

Dependents:   lightsense_kl46z_PWM_simple_ALM

Fork of SLCD by Erik -

Files at this revision

API Documentation at this revision

Comitter:
Tomo2k
Date:
Fri Mar 14 15:22:09 2014 +0000
Parent:
6:f4773221794b
Child:
8:99e4215cfc11
Commit message:
Added "." as a valid character printed using the decimal point LCD cell.; Added SLCD::clear() method to clear the LCD.; Note that ".." will only print one dot, dots must be manually cleared, eg using clear()

Changed in this revision

SLCD.cpp Show annotated file Show diff for this revision Revisions of this file
SLCD.h Show annotated file Show diff for this revision Revisions of this file
--- a/SLCD.cpp	Fri Mar 14 15:13:15 2014 +0000
+++ b/SLCD.cpp	Fri Mar 14 15:22:09 2014 +0000
@@ -153,6 +153,15 @@
 
 void SLCD::Write_Char (char lbValue)
 {
+    if (CharPosition >= _CHARNUM)
+        CharPosition = 0;
+
+    if (lbValue == '.') {
+        // Use built-in dot
+        DP(CharPosition-1, true);
+        return;
+    }
+
     uint8_t char_val;
     uint8_t temp;
     uint8_t *lbpLCDWF;
@@ -160,8 +169,6 @@
     uint16_t arrayOffset;
     uint8_t position;
 
-    if (CharPosition >= _CHARNUM)
-        CharPosition = 0;
     lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
     /* only ascii character if value not writeable write as @ */
     if (lbValue>='a' && lbValue<='z') {
@@ -199,6 +206,11 @@
     LCD->GCR |= LCD_GCR_RVTRIM(lbContrast);
 }
 
+void SLCD::clear()
+{
+    All_Segments(0);
+}
+
 void SLCD::All_Segments (int mode)
 {
     uint8_t lbTotalBytes = _CHARNUM * _LCDTYPE;
@@ -215,37 +227,44 @@
     }
 }
 
-void SLCD::DP1 (int mode)
+void SLCD::DP(int pos, bool on)
 {
     uint8_t *lbpLCDWF;
+    int tableLoc;
+    switch (pos) {
+        case 0:
+            tableLoc = 1;
+            break;
+        case 1:
+            tableLoc = 3;
+            break;
+        case 2:
+            tableLoc = 5;
+            break;
+        default:
+            return; // Bad position
+    }
     lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
-    if (mode==1) {
-        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]|=1;
+    if (on) {
+        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[tableLoc]]|=1;
     } else {
-        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[1]]&=~1;
+        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[tableLoc]]&=~1;
     }
 }
 
+void SLCD::DP1 (int mode)
+{
+    DP(0, mode==1);
+}
+
 void SLCD::DP2 (int mode)
 {
-    uint8_t *lbpLCDWF;
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
-    if (mode==1) {
-        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]|=1;
-    } else {
-        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[3]]&=~1;
-    }
+    DP(1, mode==1);
 }
 
 void SLCD::DP3 (int mode)
 {
-    uint8_t *lbpLCDWF;
-    lbpLCDWF = (uint8_t *)&LCD->WF8B[0];
-    if (mode==1) {
-        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]|=1;
-    } else {
-        lbpLCDWF[(uint8_t)WF_ORDERING_TABLE[5]]&=~1;
-    }
+    DP(2, mode==1);
 }
 
 void SLCD::Colon (int mode)
--- a/SLCD.h	Fri Mar 14 15:13:15 2014 +0000
+++ b/SLCD.h	Fri Mar 14 15:22:09 2014 +0000
@@ -32,6 +32,8 @@
     void Home (void);
     void Contrast (uint8_t lbContrast);
     void All_Segments (int);
+    void clear();
+    void DP(int pos, bool on);
     void DP1 (int);
     void DP2 (int);
     void DP3 (int);