Official reference client implementation for Cumulocity SmartREST on u-blox C027.

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Vincent Wochnik

Revision:
93:0acd11870c6a
Child:
96:5dfdc8568e9f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/io/LCDDisplay.cpp	Mon Apr 13 14:24:58 2015 +0000
@@ -0,0 +1,79 @@
+#include "LCDDisplay.h"
+#include "logging.h"
+
+#define DEF "\033[39m"
+#define GRE "\033[32m"
+#define CYA "\033[36m"
+
+void LCDDisplay::_setLine(char *dest, const char* src, size_t n)
+{
+        if (n == 0) {
+                return ;
+        } else if (src && src!=dest) {
+                strncpy(dest, src, n-1);
+                dest[n-1] = '\0';
+        }
+}
+
+void LCDDisplay::clear()
+{
+        _setLine(firstLine, "", sizeof(firstLine));
+        _setLine(secondLine, "", sizeof(secondLine));
+        _setLine(thirdLine, "", sizeof(thirdLine));
+        _lcd.cls();
+}
+
+void LCDDisplay::setFirstLine(const char* p)
+{
+        _setLine(firstLine, p, sizeof(firstLine));
+        lcdPrint(firstLine, secondLine, thirdLine);
+}
+
+void LCDDisplay::setSecondLine(const char* p)
+{
+        _setLine(secondLine, p, sizeof(secondLine));
+        lcdPrint(firstLine, secondLine, thirdLine);
+}
+
+void LCDDisplay::setThirdLine(const char* p)
+{
+        _setLine(thirdLine, p, sizeof(thirdLine));
+        lcdPrint(firstLine, secondLine, thirdLine);
+}
+
+void LCDDisplay::setLines(const char *p1, const char *p2, const char *p3)
+{
+        _setLine(firstLine, p1, sizeof(firstLine));
+        if (p2)
+            _setLine(secondLine, p2, sizeof(secondLine));
+        else
+            _setLine(secondLine, "", sizeof(secondLine));
+
+        if (p3)
+            _setLine(thirdLine, p3, sizeof(thirdLine));
+        else
+            _setLine(thirdLine, "", sizeof(thirdLine));
+        lcdPrint(firstLine, secondLine, thirdLine);
+}
+
+void LCDDisplay::lcdPrint(const char *l1, const char *l2, const char *l3)
+{
+    aDebug(GRE "io::lcdPrint" DEF "\r\n");
+
+    lcdLock.lock();
+    _lcd.cls();
+    _lcd.locate(0, 0);
+    _lcd.printf("%s\n", l1);
+    aDebug(GRE "> " CYA "%s\r\n" DEF, l1);
+
+    if (l2 != NULL) {
+        _lcd.printf("%s\n", l2);
+        aDebug(GRE "> " CYA "%s\r\n" DEF, l2);
+
+        if (l3 != NULL) {
+            _lcd.printf("%s\n", l3);
+            aDebug(GRE "> " CYA "%s\r\n" DEF, l3);
+        }
+    }
+    lcdLock.unlock();
+}