portable version of the cumulocity demo
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
DeviceIO.cpp@52:8f1370084268, 2014-08-13 (annotated)
- Committer:
- vwochnik
- Date:
- Wed Aug 13 10:55:11 2014 +0000
- Revision:
- 52:8f1370084268
- Parent:
- 47:89ae46d5c466
- Child:
- 55:ed3a2751a2b5
minor refactoring and improvement
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Cumulocity | 41:804f6a0bda26 | 1 | #include "DeviceIO.h" |
Cumulocity | 41:804f6a0bda26 | 2 | |
vwochnik | 52:8f1370084268 | 3 | #define DEF "\033[39m" |
vwochnik | 52:8f1370084268 | 4 | #define GRE "\033[32m" |
vwochnik | 52:8f1370084268 | 5 | #define CYA "\033[36m" |
vwochnik | 52:8f1370084268 | 6 | |
Cumulocity | 47:89ae46d5c466 | 7 | DeviceIO::DeviceIO(GPSI2C& gps) : |
Cumulocity | 47:89ae46d5c466 | 8 | _gpsTracker(gps), |
Cumulocity | 46:f6976fd64387 | 9 | _resetButton(D4), // fire button on arduino app shield |
Cumulocity | 47:89ae46d5c466 | 10 | _analog1(A0), |
Cumulocity | 47:89ae46d5c466 | 11 | _analog2(A1), |
Cumulocity | 41:804f6a0bda26 | 12 | _temperatureSensor(SDA,SCL), |
Cumulocity | 41:804f6a0bda26 | 13 | _accelerometer(SDA,SCL), |
Cumulocity | 41:804f6a0bda26 | 14 | _lcd(D11, D13, D12, D7, D10) |
Cumulocity | 41:804f6a0bda26 | 15 | { |
Cumulocity | 41:804f6a0bda26 | 16 | } |
Cumulocity | 41:804f6a0bda26 | 17 | |
Cumulocity | 46:f6976fd64387 | 18 | bool DeviceIO::resetButtonPressed() |
Cumulocity | 46:f6976fd64387 | 19 | { |
Cumulocity | 46:f6976fd64387 | 20 | return _resetButton; |
Cumulocity | 46:f6976fd64387 | 21 | } |
Cumulocity | 46:f6976fd64387 | 22 | |
Cumulocity | 47:89ae46d5c466 | 23 | GPSTracker& DeviceIO::gpsTracker() |
Cumulocity | 47:89ae46d5c466 | 24 | { |
Cumulocity | 47:89ae46d5c466 | 25 | return _gpsTracker; |
Cumulocity | 47:89ae46d5c466 | 26 | } |
Cumulocity | 47:89ae46d5c466 | 27 | |
Cumulocity | 47:89ae46d5c466 | 28 | AnalogIn& DeviceIO::analog1() |
Cumulocity | 47:89ae46d5c466 | 29 | { |
Cumulocity | 47:89ae46d5c466 | 30 | return _analog1; |
Cumulocity | 47:89ae46d5c466 | 31 | } |
Cumulocity | 47:89ae46d5c466 | 32 | |
Cumulocity | 47:89ae46d5c466 | 33 | AnalogIn& DeviceIO::analog2() |
Cumulocity | 47:89ae46d5c466 | 34 | { |
Cumulocity | 47:89ae46d5c466 | 35 | return _analog2; |
Cumulocity | 47:89ae46d5c466 | 36 | } |
Cumulocity | 41:804f6a0bda26 | 37 | LM75B& DeviceIO::temperatureSensor() |
Cumulocity | 41:804f6a0bda26 | 38 | { |
Cumulocity | 41:804f6a0bda26 | 39 | return _temperatureSensor; |
Cumulocity | 41:804f6a0bda26 | 40 | } |
Cumulocity | 41:804f6a0bda26 | 41 | |
Cumulocity | 41:804f6a0bda26 | 42 | MMA7660& DeviceIO::accelerometer() |
Cumulocity | 41:804f6a0bda26 | 43 | { |
Cumulocity | 41:804f6a0bda26 | 44 | return _accelerometer; |
Cumulocity | 41:804f6a0bda26 | 45 | } |
Cumulocity | 41:804f6a0bda26 | 46 | |
Cumulocity | 41:804f6a0bda26 | 47 | void DeviceIO::lcdPrint(const char *line1, const char *line2, const char *line3) |
Cumulocity | 41:804f6a0bda26 | 48 | { |
vwochnik | 52:8f1370084268 | 49 | printf(GRE "io::lcdPrint" DEF "\r\n"); |
Cumulocity | 41:804f6a0bda26 | 50 | _lcd.cls(); |
Cumulocity | 41:804f6a0bda26 | 51 | _lcd.locate(0, 0); |
vwochnik | 52:8f1370084268 | 52 | |
Cumulocity | 41:804f6a0bda26 | 53 | _lcd.printf("%s\n", line1); |
vwochnik | 52:8f1370084268 | 54 | printf(GRE "> " CYA "%s\r\n" DEF, line1); |
vwochnik | 52:8f1370084268 | 55 | |
Cumulocity | 41:804f6a0bda26 | 56 | if (line2 != NULL) { |
Cumulocity | 41:804f6a0bda26 | 57 | _lcd.printf("%s\n", line2); |
vwochnik | 52:8f1370084268 | 58 | printf(GRE "> " CYA "%s\r\n" DEF, line2); |
vwochnik | 52:8f1370084268 | 59 | |
vwochnik | 52:8f1370084268 | 60 | if (line3 != NULL) { |
Cumulocity | 41:804f6a0bda26 | 61 | _lcd.printf("%s\n", line3); |
vwochnik | 52:8f1370084268 | 62 | printf(GRE "> " CYA "%s\r\n" DEF, line3); |
vwochnik | 52:8f1370084268 | 63 | } |
Cumulocity | 41:804f6a0bda26 | 64 | } |
Cumulocity | 41:804f6a0bda26 | 65 | } |