Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain 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);
+}
