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 Orefatoi

Committer:
wataloh
Date:
Thu Jan 19 09:17:16 2017 +0000
Revision:
1:b2a9a6f2c30e
Child:
2:dfe671e31221
simplified

Who changed what in which revision?

UserRevisionLine numberNew 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 1:b2a9a6f2c30e 17 inline void nop(){}
wataloh 1:b2a9a6f2c30e 18 void read()
wataloh 1:b2a9a6f2c30e 19 {
wataloh 1:b2a9a6f2c30e 20 callback = &A::go;
wataloh 1:b2a9a6f2c30e 21 }
wataloh 1:b2a9a6f2c30e 22 void backToNOP()
wataloh 1:b2a9a6f2c30e 23 {
wataloh 1:b2a9a6f2c30e 24 callback = &A::nop;
wataloh 1:b2a9a6f2c30e 25 }
wataloh 1:b2a9a6f2c30e 26 public:
wataloh 1:b2a9a6f2c30e 27 void loop()
wataloh 1:b2a9a6f2c30e 28 {
wataloh 1:b2a9a6f2c30e 29 (self->*callback)();
wataloh 1:b2a9a6f2c30e 30 }
wataloh 1:b2a9a6f2c30e 31 TimeEventHandler(){}
wataloh 1:b2a9a6f2c30e 32 static A*
wataloh 1:b2a9a6f2c30e 33 getInstance()
wataloh 1:b2a9a6f2c30e 34 {
wataloh 1:b2a9a6f2c30e 35 return self == NULL ? self = new A() : self;
wataloh 1:b2a9a6f2c30e 36 }
wataloh 1:b2a9a6f2c30e 37 static void
wataloh 1:b2a9a6f2c30e 38 deleteInstance()
wataloh 1:b2a9a6f2c30e 39 {
wataloh 1:b2a9a6f2c30e 40 timeout.attach(&NOP,10);
wataloh 1:b2a9a6f2c30e 41 if(self!=NULL)
wataloh 1:b2a9a6f2c30e 42 {
wataloh 1:b2a9a6f2c30e 43 delete self;
wataloh 1:b2a9a6f2c30e 44 self = NULL;
wataloh 1:b2a9a6f2c30e 45 }
wataloh 1:b2a9a6f2c30e 46 }
wataloh 1:b2a9a6f2c30e 47 static void
wataloh 1:b2a9a6f2c30e 48 onRead()
wataloh 1:b2a9a6f2c30e 49 {
wataloh 1:b2a9a6f2c30e 50 self->read();
wataloh 1:b2a9a6f2c30e 51 }
wataloh 1:b2a9a6f2c30e 52 static void
wataloh 1:b2a9a6f2c30e 53 NOP()
wataloh 1:b2a9a6f2c30e 54 {
wataloh 1:b2a9a6f2c30e 55 }
wataloh 1:b2a9a6f2c30e 56 };
wataloh 1:b2a9a6f2c30e 57
wataloh 1:b2a9a6f2c30e 58 template<typename A> A* TimeEventHandler<A>::self=NULL;
wataloh 1:b2a9a6f2c30e 59 template<typename A> Timeout TimeEventHandler<A>::timeout;
wataloh 1:b2a9a6f2c30e 60
wataloh 1:b2a9a6f2c30e 61 };
wataloh 1:b2a9a6f2c30e 62
wataloh 1:b2a9a6f2c30e 63 #endif //_TIME_EVENT_HANDLER_HPP_