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
sensors/ToDoQ.cpp@0:20bce0dcc921, 2016-12-20 (annotated)
- Committer:
- wataloh
- Date:
- Tue Dec 20 01:51:02 2016 +0000
- Revision:
- 0:20bce0dcc921
- Child:
- 1:b2a9a6f2c30e
kl25z teensy merged
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wataloh | 0:20bce0dcc921 | 1 | #include "ToDoQ.h" |
wataloh | 0:20bce0dcc921 | 2 | #if defined (TARGET_KL25Z) |
wataloh | 0:20bce0dcc921 | 3 | #include "TempHandler.h" |
wataloh | 0:20bce0dcc921 | 4 | #include "PowerHandler.h" |
wataloh | 0:20bce0dcc921 | 5 | #include "ColorHandler.h" |
wataloh | 0:20bce0dcc921 | 6 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 0:20bce0dcc921 | 7 | #include "TapHandler.h" |
wataloh | 0:20bce0dcc921 | 8 | #endif |
wataloh | 0:20bce0dcc921 | 9 | |
wataloh | 0:20bce0dcc921 | 10 | namespace MaruSolSensorManager |
wataloh | 0:20bce0dcc921 | 11 | { |
wataloh | 0:20bce0dcc921 | 12 | static uint32_t read_tilt_delay = 0; |
wataloh | 0:20bce0dcc921 | 13 | static ToDoQ* self = NULL; |
wataloh | 0:20bce0dcc921 | 14 | ToDoQ* |
wataloh | 0:20bce0dcc921 | 15 | ToDoQ::create(onGetTodo callback) |
wataloh | 0:20bce0dcc921 | 16 | { |
wataloh | 0:20bce0dcc921 | 17 | return self == NULL ? self = new ToDoQ(callback) : self; |
wataloh | 0:20bce0dcc921 | 18 | } |
wataloh | 0:20bce0dcc921 | 19 | ToDoQ::ToDoQ(onGetTodo callback) |
wataloh | 0:20bce0dcc921 | 20 | { |
wataloh | 0:20bce0dcc921 | 21 | for (int i = 0; i < TODO_QUEUE_SIZE; i++) { |
wataloh | 0:20bce0dcc921 | 22 | q[i] = NULL; |
wataloh | 0:20bce0dcc921 | 23 | } |
wataloh | 0:20bce0dcc921 | 24 | _onGetTodo = callback; |
wataloh | 0:20bce0dcc921 | 25 | #if defined (TARGET_KL25Z) |
wataloh | 0:20bce0dcc921 | 26 | TempHandler::getInstance(); |
wataloh | 0:20bce0dcc921 | 27 | PowerHandler::getInstance(); |
wataloh | 0:20bce0dcc921 | 28 | ColorHandler::getInstance(); |
wataloh | 0:20bce0dcc921 | 29 | TempHandler::getInstance(); |
wataloh | 0:20bce0dcc921 | 30 | #elif defined (TARGET_TEENSY3_1) |
wataloh | 0:20bce0dcc921 | 31 | TapHandler::getInstance(); |
wataloh | 0:20bce0dcc921 | 32 | #endif |
wataloh | 0:20bce0dcc921 | 33 | } |
wataloh | 0:20bce0dcc921 | 34 | void |
wataloh | 0:20bce0dcc921 | 35 | ToDoQ::loop() |
wataloh | 0:20bce0dcc921 | 36 | { |
wataloh | 0:20bce0dcc921 | 37 | if(read_tilt_delay > 200) |
wataloh | 0:20bce0dcc921 | 38 | { |
wataloh | 0:20bce0dcc921 | 39 | read_tilt_delay = 0; |
wataloh | 0:20bce0dcc921 | 40 | TapHandler::getInstance()->read_tilt(); |
wataloh | 0:20bce0dcc921 | 41 | } |
wataloh | 0:20bce0dcc921 | 42 | else |
wataloh | 0:20bce0dcc921 | 43 | { |
wataloh | 0:20bce0dcc921 | 44 | ++read_tilt_delay; |
wataloh | 0:20bce0dcc921 | 45 | } |
wataloh | 0:20bce0dcc921 | 46 | |
wataloh | 0:20bce0dcc921 | 47 | for (int i = 0; i < TODO_QUEUE_SIZE; i++) |
wataloh | 0:20bce0dcc921 | 48 | { |
wataloh | 0:20bce0dcc921 | 49 | if (q[i] != NULL) |
wataloh | 0:20bce0dcc921 | 50 | { |
wataloh | 0:20bce0dcc921 | 51 | _onGetTodo(q[i]); |
wataloh | 0:20bce0dcc921 | 52 | q[i]=NULL; |
wataloh | 0:20bce0dcc921 | 53 | break; |
wataloh | 0:20bce0dcc921 | 54 | } |
wataloh | 0:20bce0dcc921 | 55 | } |
wataloh | 0:20bce0dcc921 | 56 | } |
wataloh | 0:20bce0dcc921 | 57 | void |
wataloh | 0:20bce0dcc921 | 58 | ToDoQ::_queuePut(ToDo *todo) |
wataloh | 0:20bce0dcc921 | 59 | { |
wataloh | 0:20bce0dcc921 | 60 | SERIAL_PRINT_DBG("ToDoQ::_queuePut entered\n"); |
wataloh | 0:20bce0dcc921 | 61 | for (int i = 0; i < TODO_QUEUE_SIZE; i++) |
wataloh | 0:20bce0dcc921 | 62 | { |
wataloh | 0:20bce0dcc921 | 63 | if(q[i] == NULL) |
wataloh | 0:20bce0dcc921 | 64 | { |
wataloh | 0:20bce0dcc921 | 65 | SERIAL_PRINT_DBG("ToDoQ::_queuePut found empty slot\n"); |
wataloh | 0:20bce0dcc921 | 66 | q[i] = todo; |
wataloh | 0:20bce0dcc921 | 67 | break; |
wataloh | 0:20bce0dcc921 | 68 | } |
wataloh | 0:20bce0dcc921 | 69 | } |
wataloh | 0:20bce0dcc921 | 70 | } |
wataloh | 0:20bce0dcc921 | 71 | void |
wataloh | 0:20bce0dcc921 | 72 | ToDoQ::queuePut(ToDo *todo) |
wataloh | 0:20bce0dcc921 | 73 | { |
wataloh | 0:20bce0dcc921 | 74 | self->_queuePut(todo); |
wataloh | 0:20bce0dcc921 | 75 | } |
wataloh | 0:20bce0dcc921 | 76 | }; |