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/TimeEventHandler.hpp@2:dfe671e31221, 2017-01-24 (annotated)
- Committer:
- wataloh
- Date:
- Tue Jan 24 10:00:28 2017 +0000
- Revision:
- 2:dfe671e31221
- Parent:
- 1:b2a9a6f2c30e
- Child:
- 5:9d5c7ee80f3b
latest
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wataloh | 1:b2a9a6f2c30e | 1 | #ifndef _TIME_EVENT_HANDLER_HPP_ |
wataloh | 1:b2a9a6f2c30e | 2 | #define _TIME_EVENT_HANDLER_HPP_ |
wataloh | 1:b2a9a6f2c30e | 3 | |
wataloh | 1:b2a9a6f2c30e | 4 | #include "Preferences.hpp" |
wataloh | 1:b2a9a6f2c30e | 5 | #include "debugIO.h" |
wataloh | 1:b2a9a6f2c30e | 6 | |
wataloh | 1:b2a9a6f2c30e | 7 | namespace MaruSolSensorManager |
wataloh | 1:b2a9a6f2c30e | 8 | { |
wataloh | 1:b2a9a6f2c30e | 9 | |
wataloh | 1:b2a9a6f2c30e | 10 | template<typename A> class TimeEventHandler |
wataloh | 1:b2a9a6f2c30e | 11 | { |
wataloh | 1:b2a9a6f2c30e | 12 | protected: |
wataloh | 1:b2a9a6f2c30e | 13 | static A *self; |
wataloh | 1:b2a9a6f2c30e | 14 | static Timeout timeout; |
wataloh | 1:b2a9a6f2c30e | 15 | PACKET packet; |
wataloh | 1:b2a9a6f2c30e | 16 | void (A::*callback)(); |
wataloh | 2:dfe671e31221 | 17 | uint32_t nop_i; |
wataloh | 2:dfe671e31221 | 18 | inline void nop(){ |
wataloh | 2:dfe671e31221 | 19 | if(nop_i>400) |
wataloh | 2:dfe671e31221 | 20 | { |
wataloh | 2:dfe671e31221 | 21 | nop_i = 0; |
wataloh | 2:dfe671e31221 | 22 | SERIAL_PRINT_DBG("."); |
wataloh | 2:dfe671e31221 | 23 | } |
wataloh | 2:dfe671e31221 | 24 | ++nop_i; |
wataloh | 2:dfe671e31221 | 25 | } |
wataloh | 1:b2a9a6f2c30e | 26 | void read() |
wataloh | 1:b2a9a6f2c30e | 27 | { |
wataloh | 1:b2a9a6f2c30e | 28 | callback = &A::go; |
wataloh | 1:b2a9a6f2c30e | 29 | } |
wataloh | 1:b2a9a6f2c30e | 30 | void backToNOP() |
wataloh | 1:b2a9a6f2c30e | 31 | { |
wataloh | 2:dfe671e31221 | 32 | callback = NULL;//&A::nop; |
wataloh | 1:b2a9a6f2c30e | 33 | } |
wataloh | 1:b2a9a6f2c30e | 34 | public: |
wataloh | 1:b2a9a6f2c30e | 35 | void loop() |
wataloh | 1:b2a9a6f2c30e | 36 | { |
wataloh | 2:dfe671e31221 | 37 | if(callback != NULL) |
wataloh | 2:dfe671e31221 | 38 | { |
wataloh | 2:dfe671e31221 | 39 | (self->*callback)(); |
wataloh | 2:dfe671e31221 | 40 | } |
wataloh | 1:b2a9a6f2c30e | 41 | } |
wataloh | 2:dfe671e31221 | 42 | TimeEventHandler(){ |
wataloh | 2:dfe671e31221 | 43 | nop_i = 0; |
wataloh | 2:dfe671e31221 | 44 | } |
wataloh | 1:b2a9a6f2c30e | 45 | static A* |
wataloh | 1:b2a9a6f2c30e | 46 | getInstance() |
wataloh | 1:b2a9a6f2c30e | 47 | { |
wataloh | 1:b2a9a6f2c30e | 48 | return self == NULL ? self = new A() : self; |
wataloh | 1:b2a9a6f2c30e | 49 | } |
wataloh | 1:b2a9a6f2c30e | 50 | static void |
wataloh | 1:b2a9a6f2c30e | 51 | deleteInstance() |
wataloh | 1:b2a9a6f2c30e | 52 | { |
wataloh | 1:b2a9a6f2c30e | 53 | timeout.attach(&NOP,10); |
wataloh | 1:b2a9a6f2c30e | 54 | if(self!=NULL) |
wataloh | 1:b2a9a6f2c30e | 55 | { |
wataloh | 1:b2a9a6f2c30e | 56 | delete self; |
wataloh | 1:b2a9a6f2c30e | 57 | self = NULL; |
wataloh | 1:b2a9a6f2c30e | 58 | } |
wataloh | 1:b2a9a6f2c30e | 59 | } |
wataloh | 1:b2a9a6f2c30e | 60 | static void |
wataloh | 1:b2a9a6f2c30e | 61 | onRead() |
wataloh | 1:b2a9a6f2c30e | 62 | { |
wataloh | 1:b2a9a6f2c30e | 63 | self->read(); |
wataloh | 1:b2a9a6f2c30e | 64 | } |
wataloh | 1:b2a9a6f2c30e | 65 | static void |
wataloh | 1:b2a9a6f2c30e | 66 | NOP() |
wataloh | 1:b2a9a6f2c30e | 67 | { |
wataloh | 1:b2a9a6f2c30e | 68 | } |
wataloh | 1:b2a9a6f2c30e | 69 | }; |
wataloh | 1:b2a9a6f2c30e | 70 | |
wataloh | 1:b2a9a6f2c30e | 71 | template<typename A> A* TimeEventHandler<A>::self=NULL; |
wataloh | 1:b2a9a6f2c30e | 72 | template<typename A> Timeout TimeEventHandler<A>::timeout; |
wataloh | 1:b2a9a6f2c30e | 73 | |
wataloh | 1:b2a9a6f2c30e | 74 | }; |
wataloh | 1:b2a9a6f2c30e | 75 | |
wataloh | 1:b2a9a6f2c30e | 76 | #endif //_TIME_EVENT_HANDLER_HPP_ |