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/TimeEventHandler.hpp
- Revision:
- 1:b2a9a6f2c30e
- Child:
- 2:dfe671e31221
diff -r 20bce0dcc921 -r b2a9a6f2c30e sensors/TimeEventHandler.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sensors/TimeEventHandler.hpp Thu Jan 19 09:17:16 2017 +0000 @@ -0,0 +1,63 @@ +#ifndef _TIME_EVENT_HANDLER_HPP_ +#define _TIME_EVENT_HANDLER_HPP_ + +#include "Preferences.hpp" +#include "debugIO.h" + +namespace MaruSolSensorManager +{ + +template<typename A> class TimeEventHandler +{ +protected: + static A *self; + static Timeout timeout; + PACKET packet; + void (A::*callback)(); + inline void nop(){} + void read() + { + callback = &A::go; + } + void backToNOP() + { + callback = &A::nop; + } +public: + void loop() + { + (self->*callback)(); + } + TimeEventHandler(){} + static A* + getInstance() + { + return self == NULL ? self = new A() : self; + } + static void + deleteInstance() + { + timeout.attach(&NOP,10); + if(self!=NULL) + { + delete self; + self = NULL; + } + } + static void + onRead() + { + self->read(); + } + static void + NOP() + { + } +}; + +template<typename A> A* TimeEventHandler<A>::self=NULL; +template<typename A> Timeout TimeEventHandler<A>::timeout; + +}; + +#endif //_TIME_EVENT_HANDLER_HPP_ \ No newline at end of file