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

io/DeviceIO.cpp

Committer:
xinlei
Date:
2015-02-16
Revision:
72:c5709ae7b193
Parent:
65:a62dbef2f924
Child:
74:ca3001991fdc

File content as of revision 72:c5709ae7b193:

#include "DeviceIO.h"
#include "logging.h"

#define DEF "\033[39m"
#define GRE "\033[32m"
#define CYA "\033[36m"

DeviceIO::DeviceIO(GPSI2C& gps) :
    _resetButton(D4), // fire button on arduino app shield
    _analog1(A0),
    _analog2(A1),
    _speaker(D6),
    _temperatureSensor(SDA,SCL),
    _accelerometer(SDA,SCL),
    _lcd(D11, D13, D12, D7, D10),
    _gpsTracker(gps),
    _deviceFeedback(_speaker)
{
}

bool DeviceIO::resetButtonPressed()
{
    return _resetButton;
}

GPSTracker& DeviceIO::gpsTracker()
{
    return _gpsTracker;
}

DeviceFeedback& DeviceIO::deviceFeedback()
{
    return _deviceFeedback;
}

AnalogIn& DeviceIO::analog1()
{
    return _analog1;
}

AnalogIn& DeviceIO::analog2()
{
    return _analog2;
}
LM75B& DeviceIO::temperatureSensor()
{
    return _temperatureSensor;
}

MMA7660& DeviceIO::accelerometer()
{
    return _accelerometer;
}

void DeviceIO::lcdPrint(const char *line1, const char *line2, const char *line3)
{
    aInfo(GRE "io::lcdPrint" DEF "\r\n");
    _lcd.cls();
    _lcd.locate(0, 0);

    _lcd.printf("%s\n", line1);
    aInfo(GRE "> " CYA "%s\r\n" DEF, line1);

    if (line2 != NULL) {
        _lcd.printf("%s\n", line2);
        aInfo(GRE "> " CYA "%s\r\n" DEF, line2);

        if (line3 != NULL) {
            _lcd.printf("%s\n", line3);
            aInfo(GRE "> " CYA "%s\r\n" DEF, line3);
        }
    }
}