portable version of the cumulocity demo

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DeviceIO.cpp Source File

DeviceIO.cpp

00001 #include "DeviceIO.h"
00002 #include "PinNames.h"
00003 
00004 #define DEF "\033[39m"
00005 #define GRE "\033[32m"
00006 #define CYA "\033[36m"
00007 
00008 DeviceIO::DeviceIO(GPSI2C& gps) :
00009     _gpsTracker(gps),
00010     _resetButton(D4), // fire button on arduino app shield
00011     _analog1(A0),
00012     _analog2(A1),
00013     _temperatureSensor(D14/*SDA*/, D15/*SCL*/),
00014     _accelerometer(D14/*SDA*/, D15/*SCL*/),
00015     _lcd(D11, D13, D12, D7, D10)
00016 {
00017 }
00018 
00019 bool DeviceIO::resetButtonPressed()
00020 {
00021     return _resetButton;
00022 }
00023 
00024 GPSTracker& DeviceIO::gpsTracker()
00025 {
00026     return _gpsTracker;
00027 }
00028 
00029 AnalogIn& DeviceIO::analog1()
00030 {
00031     return _analog1;
00032 }
00033 
00034 AnalogIn& DeviceIO::analog2()
00035 {
00036     return _analog2;
00037 }
00038 LM75B& DeviceIO::temperatureSensor()
00039 {
00040     return _temperatureSensor;
00041 }
00042 
00043 MMA7660& DeviceIO::accelerometer()
00044 {
00045     return _accelerometer;
00046 }
00047 
00048 void DeviceIO::lcdPrint(const char *line1, const char *line2, const char *line3)
00049 {
00050     printf(GRE "io::lcdPrint" DEF "\r\n");
00051     _lcd.cls();
00052     _lcd.locate(0, 0);
00053 
00054     _lcd.printf("%s\n", line1);
00055     printf(GRE "> " CYA "%s\r\n" DEF, line1);
00056 
00057     if (line2 != NULL) {
00058         _lcd.printf("%s\n", line2);
00059         printf(GRE "> " CYA "%s\r\n" DEF, line2);
00060 
00061         if (line3 != NULL) {
00062             _lcd.printf("%s\n", line3);
00063             printf(GRE "> " CYA "%s\r\n" DEF, line3);
00064         }
00065     }
00066 }