pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
Diff: sensors/ToDoQ.cpp
- Revision:
- 1:b2a9a6f2c30e
- Parent:
- 0:20bce0dcc921
- Child:
- 14:b205267fa5f6
diff -r 20bce0dcc921 -r b2a9a6f2c30e sensors/ToDoQ.cpp --- a/sensors/ToDoQ.cpp Tue Dec 20 01:51:02 2016 +0000 +++ b/sensors/ToDoQ.cpp Thu Jan 19 09:17:16 2017 +0000 @@ -1,76 +1,70 @@ #include "ToDoQ.h" -#if defined (TARGET_KL25Z) - #include "TempHandler.h" - #include "PowerHandler.h" - #include "ColorHandler.h" -#elif defined (TARGET_TEENSY3_1) - #include "TapHandler.h" -#endif + +#include "SensorsMain.hpp" + +NAMESPACE_MARUSOLSENSORMANAGER_START -namespace MaruSolSensorManager +DEF_SELF(ToDoQ); + +ToDoQ* +ToDoQ::create(onGetTodo callback) { - static uint32_t read_tilt_delay = 0; - static ToDoQ* self = NULL; - ToDoQ* - ToDoQ::create(onGetTodo callback) - { - return self == NULL ? self = new ToDoQ(callback) : self; - } - ToDoQ::ToDoQ(onGetTodo callback) + if(self == NULL) { - for (int i = 0; i < TODO_QUEUE_SIZE; i++) { - q[i] = NULL; - } - _onGetTodo = callback; -#if defined (TARGET_KL25Z) - TempHandler::getInstance(); - PowerHandler::getInstance(); - ColorHandler::getInstance(); - TempHandler::getInstance(); -#elif defined (TARGET_TEENSY3_1) - TapHandler::getInstance(); -#endif + self = new ToDoQ(); } - void - ToDoQ::loop() + self->setOnToDo(callback); + return self; +} + +ToDoQ::ToDoQ() +{ + for (int i = 0; i < TODO_QUEUE_SIZE; i++) { - if(read_tilt_delay > 200) - { - read_tilt_delay = 0; - TapHandler::getInstance()->read_tilt(); - } - else + q[i] = NULL; + } +} + +void +ToDoQ::setOnToDo(onGetTodo callback) +{ + _onGetTodo = callback; +} + +void +ToDoQ::loop() +{ + SensorsMain::getInstance()->loop(); + for (int i = 0; i < TODO_QUEUE_SIZE; i++) + { + if (q[i] != NULL) { - ++read_tilt_delay; - } - - for (int i = 0; i < TODO_QUEUE_SIZE; i++) - { - if (q[i] != NULL) - { - _onGetTodo(q[i]); - q[i]=NULL; - break; - } + _onGetTodo(q[i]); + q[i]=NULL; + break; } } - void - ToDoQ::_queuePut(ToDo *todo) +} + +void +ToDoQ::_queuePut(ToDo *todo) +{ + SERIAL_PRINT_DBG("ToDoQ::_queuePut entered\n"); + for (int i = 0; i < TODO_QUEUE_SIZE; i++) { - SERIAL_PRINT_DBG("ToDoQ::_queuePut entered\n"); - for (int i = 0; i < TODO_QUEUE_SIZE; i++) + if(q[i] == NULL) { - if(q[i] == NULL) - { - SERIAL_PRINT_DBG("ToDoQ::_queuePut found empty slot\n"); - q[i] = todo; - break; - } + SERIAL_PRINT_DBG("ToDoQ::_queuePut found empty slot\n"); + q[i] = todo; + break; } } - void - ToDoQ::queuePut(ToDo *todo) - { - self->_queuePut(todo); - } -}; \ No newline at end of file +} + +void +ToDoQ::queuePut(ToDo *todo) +{ + getInstance<ToDoQ>()->_queuePut(todo); +} + +NAMESPACE_MARUSOLSENSORMANAGER_END \ No newline at end of file