SmartREST client reference implementation for the u-blox C027 mbed compatible device.
Dependencies: C027 C027_Support mbed mbed-rtos MbedSmartRest LM75B MMA7660 C12832
Fork of MbedSmartRestTest by
Diff: io.cpp
- Revision:
- 22:3a595f7826af
- Parent:
- 21:f74b80a0cb38
- Child:
- 32:56804dd00193
--- 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); +}