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

Revision:
21:d03c7bbb9f37
Parent:
15:2c2c0a7c50c1
--- a/sensors/TimeEventHandler.hpp	Mon Jun 05 07:59:10 2017 +0000
+++ b/sensors/TimeEventHandler.hpp	Fri Jun 09 01:49:53 2017 +0000
@@ -4,78 +4,38 @@
 #include "Preferences.hpp"
 #include "DebugIO.hpp"
 
-namespace MaruSolSensorManager
-{
-
 template<typename A> class TimeEventHandler
 {
 protected:
-    static A *self;
-    static Timeout timeout;
+    TimeEventHandler()
+    {
+        timeout = new Timeout();
+    }
+    Timeout *timeout;
     PACKET packet;
-    void (A::*callback)();
-    uint32_t nop_i;
+    void (A::*cb)();
     int32_t interval_current;
-    inline void nop(){
-        if(nop_i>400)
-        {
-            nop_i = 0;
-            SERIAL_PRINT_DBG(".");
-        }
-        ++nop_i;
-    }
     void read()
     {
-        callback = &A::go;
+        cb = &A::go;
     }
     void backToNOP()
     {
-        callback = NULL;//&A::nop;
+        cb = NULL;
     }
     virtual void checkIntervalUpdate()
     {
     }
 public:
-    void loop()
-    {
-        if(callback != NULL)
-        {
-            (self->*callback)();
-        }
-        self->checkIntervalUpdate();
-    }
-    TimeEventHandler(){
-        nop_i = 0;
-    }
-    static A*
-    getInstance()
+    int loop()
     {
-        return self == NULL ? self = new A() : self;
-    }
-    static void
-    deleteInstance()
-    {
-        timeout.attach(&NOP,10);
-        if(self!=NULL)
+        if(cb != NULL)
         {
-            delete self;
-            self = NULL;
+            (A::self->*cb)();
         }
-    }
-    static void
-    onRead()
-    {
-        self->read();
-    }
-    static void
-    NOP()
-    {
+        A::self->checkIntervalUpdate();
+        return 0;
     }
 };
 
-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