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
io.cpp
- Committer:
- vwochnik
- Date:
- 2014-02-18
- Revision:
- 15:0ccf0f530a05
- Parent:
- 14:56da550a1baa
- Child:
- 17:877a9a3148a4
File content as of revision 15:0ccf0f530a05:
#include "io.h"
#include "rtos.h"
void timer_callback(void const*);
// Using Arduino pin notation
LM75B tempSensor(SDA, SCL);
MMA7660 accSensor(p28, p27);
DigitalIn button(p14);
//C12832 lcdDisplay(D11, D13, D12, D7, D10);
RtosTimer *timer;
bool tempFound = false, accFound = false;
uint32_t count = 0;
bool btnPressed = false;
void io_init(void)
{
timer = new RtosTimer(&timer_callback, osTimerPeriodic);
timer->start(50);
tempFound = tempSensor.open();
accFound = accSensor.testConnection();
}
float temperature()
{
if (!tempFound)
return 0.0;
return tempSensor.temp();
}
acceleration_t acceleration()
{
float data[3];
acceleration_t ret = { 0.0, 0.0, 0.0 };
if (accFound) {
accSensor.readData(data);
ret.x = data[0];
ret.y = data[1];
ret.z = data[2];
}
return ret;
}
uint32_t counter()
{
return count;
}
void timer_callback(void const*)
{
if ((!btnPressed) && (button))
count++;
btnPressed = button;
}
