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@15:2c2c0a7c50c1, 2017-05-29 (annotated)
- Committer:
- wataloh
- Date:
- Mon May 29 04:06:34 2017 +0000
- Revision:
- 15:2c2c0a7c50c1
- Parent:
- 5:9d5c7ee80f3b
- Child:
- 21:d03c7bbb9f37
5 sec delay for every data send to ASR-1.; ; upload interval change reflected immediately.
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 | 5:9d5c7ee80f3b | 5 | #include "DebugIO.hpp" |
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 | 15:2c2c0a7c50c1 | 18 | int32_t interval_current; |
wataloh | 2:dfe671e31221 | 19 | inline void nop(){ |
wataloh | 2:dfe671e31221 | 20 | if(nop_i>400) |
wataloh | 2:dfe671e31221 | 21 | { |
wataloh | 2:dfe671e31221 | 22 | nop_i = 0; |
wataloh | 2:dfe671e31221 | 23 | SERIAL_PRINT_DBG("."); |
wataloh | 2:dfe671e31221 | 24 | } |
wataloh | 2:dfe671e31221 | 25 | ++nop_i; |
wataloh | 2:dfe671e31221 | 26 | } |
wataloh | 1:b2a9a6f2c30e | 27 | void read() |
wataloh | 1:b2a9a6f2c30e | 28 | { |
wataloh | 1:b2a9a6f2c30e | 29 | callback = &A::go; |
wataloh | 1:b2a9a6f2c30e | 30 | } |
wataloh | 1:b2a9a6f2c30e | 31 | void backToNOP() |
wataloh | 1:b2a9a6f2c30e | 32 | { |
wataloh | 2:dfe671e31221 | 33 | callback = NULL;//&A::nop; |
wataloh | 1:b2a9a6f2c30e | 34 | } |
wataloh | 15:2c2c0a7c50c1 | 35 | virtual void checkIntervalUpdate() |
wataloh | 15:2c2c0a7c50c1 | 36 | { |
wataloh | 15:2c2c0a7c50c1 | 37 | } |
wataloh | 1:b2a9a6f2c30e | 38 | public: |
wataloh | 1:b2a9a6f2c30e | 39 | void loop() |
wataloh | 1:b2a9a6f2c30e | 40 | { |
wataloh | 2:dfe671e31221 | 41 | if(callback != NULL) |
wataloh | 2:dfe671e31221 | 42 | { |
wataloh | 2:dfe671e31221 | 43 | (self->*callback)(); |
wataloh | 2:dfe671e31221 | 44 | } |
wataloh | 15:2c2c0a7c50c1 | 45 | self->checkIntervalUpdate(); |
wataloh | 1:b2a9a6f2c30e | 46 | } |
wataloh | 2:dfe671e31221 | 47 | TimeEventHandler(){ |
wataloh | 2:dfe671e31221 | 48 | nop_i = 0; |
wataloh | 2:dfe671e31221 | 49 | } |
wataloh | 1:b2a9a6f2c30e | 50 | static A* |
wataloh | 1:b2a9a6f2c30e | 51 | getInstance() |
wataloh | 1:b2a9a6f2c30e | 52 | { |
wataloh | 1:b2a9a6f2c30e | 53 | return self == NULL ? self = new A() : self; |
wataloh | 1:b2a9a6f2c30e | 54 | } |
wataloh | 1:b2a9a6f2c30e | 55 | static void |
wataloh | 1:b2a9a6f2c30e | 56 | deleteInstance() |
wataloh | 1:b2a9a6f2c30e | 57 | { |
wataloh | 1:b2a9a6f2c30e | 58 | timeout.attach(&NOP,10); |
wataloh | 1:b2a9a6f2c30e | 59 | if(self!=NULL) |
wataloh | 1:b2a9a6f2c30e | 60 | { |
wataloh | 1:b2a9a6f2c30e | 61 | delete self; |
wataloh | 1:b2a9a6f2c30e | 62 | self = NULL; |
wataloh | 1:b2a9a6f2c30e | 63 | } |
wataloh | 1:b2a9a6f2c30e | 64 | } |
wataloh | 1:b2a9a6f2c30e | 65 | static void |
wataloh | 1:b2a9a6f2c30e | 66 | onRead() |
wataloh | 1:b2a9a6f2c30e | 67 | { |
wataloh | 1:b2a9a6f2c30e | 68 | self->read(); |
wataloh | 1:b2a9a6f2c30e | 69 | } |
wataloh | 1:b2a9a6f2c30e | 70 | static void |
wataloh | 1:b2a9a6f2c30e | 71 | NOP() |
wataloh | 1:b2a9a6f2c30e | 72 | { |
wataloh | 1:b2a9a6f2c30e | 73 | } |
wataloh | 1:b2a9a6f2c30e | 74 | }; |
wataloh | 1:b2a9a6f2c30e | 75 | |
wataloh | 1:b2a9a6f2c30e | 76 | template<typename A> A* TimeEventHandler<A>::self=NULL; |
wataloh | 1:b2a9a6f2c30e | 77 | template<typename A> Timeout TimeEventHandler<A>::timeout; |
wataloh | 1:b2a9a6f2c30e | 78 | |
wataloh | 1:b2a9a6f2c30e | 79 | }; |
wataloh | 1:b2a9a6f2c30e | 80 | |
wataloh | 1:b2a9a6f2c30e | 81 | #endif //_TIME_EVENT_HANDLER_HPP_ |