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

Files at this revision

API Documentation at this revision

Comitter:
vwochnik
Date:
Thu Feb 20 14:38:53 2014 +0000
Parent:
21:f74b80a0cb38
Child:
23:0a48eebaaba8
Commit message:
fix

Changed in this revision

io.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/io.cpp	Thu Feb 20 11:57:18 2014 +0000
+++ b/io.cpp	Thu Feb 20 14:38:53 2014 +0000
@@ -2,6 +2,7 @@
 #include "rtos.h"
 
 void timer_callback(void const*);
+void lcd_update(void);
 
 // Using Arduino pin notation
 C12832 lcdDisplay(D11, D13, D12, D7, D10);
@@ -17,6 +18,8 @@
 uint32_t count = 0;
 bool btnPressed = false;
 
+char cSignal[80] = "", cTenant[80] = "", cStatus[80] = "";
+
 void io_init(void)
 {
     timer = new RtosTimer(&timer_callback, osTimerPeriodic);
@@ -29,7 +32,7 @@
     if (!accFound)
         puts("Accelerometer not found.");
     
-    lcdDisplay.cls();
+    lcd_update();
 }
 
 float temperature()
@@ -71,23 +74,23 @@
 
 void lcd_signal(int8_t rssi, uint8_t ber)
 {
-    lcdDisplay.locate(0, 0);
     if ((rssi == 0) && (ber == 0))
-        lcdDisplay.printf("No signal                    \n");
+        snprintf(cSignal, 80, "%s", "No signal");
     else
-        lcdDisplay.printf("RSSI: %d dBm  BER: %d %%    \n", rssi, ber);
+        snprintf(cSignal, 80, "RSSI: %d dBm  BER: %d %%", rssi, ber);
+    lcd_update();
 }
 
 void lcd_tenant(const char* tenant)
 {
-    lcdDisplay.locate(0, 11);
-    lcdDisplay.printf("Tenant: %s                                        \n", tenant);
+    snprintf(cTenant, 80, "Tenant: %s", tenant);
+    lcd_update();
 }
 
 void lcd_status(const char* status)
 {
-    lcdDisplay.locate(0, 22);
-    lcdDisplay.printf("%s                                                                                \n", status);
+    snprintf(cStatus, 80, "%s", status);
+    lcd_update();
 }
 
 void timer_callback(void const*)
@@ -96,3 +99,10 @@
         count++;
     btnPressed = button;
 }
+
+void lcd_update(void)
+{
+    lcdDisplay.cls();
+    lcdDisplay.locate(0, 0);
+    lcdDisplay.printf("%s\n%s\n%s\n", cSignal, cTenant, cStatus);
+}