Implemented first Hangar-Service

Dependencies:   CalibrateMagneto QuaternionMath

Fork of SML2 by TobyRich GmbH

Revision:
21:5a0c9406e119
Parent:
15:4488660e1a3b
Child:
46:fd5a62296b12
--- a/Sensor.h	Thu Apr 09 09:51:51 2015 +0000
+++ b/Sensor.h	Thu Apr 09 11:54:48 2015 +0000
@@ -12,11 +12,11 @@
     {
     public:
         /// A new sensor data frame, might be called several (hundred) times a second.
-        virtual void sensorUpdate(Vector3 data) = 0;
+        virtual void sensorUpdate(Vector3 data) {}
     };
 
     virtual void setDelegate(Delegate &d) {
-        _delegate = &d;
+        delegate = &d;
     }
 
     /// Power on a sensor and make it ready for use.
@@ -30,14 +30,12 @@
     virtual void stop() = 0; ///< Stop capturing data.
 
     virtual Vector3 read() = 0; ///< Read and return instantaneous (current) sensor data. No need to start the sensor.
+    
+    Sensor() : delegate(&defaultDelegate) {}
 
 protected:
-    /// Derived classes should use this method to pass sensor data to their owner. Delegate existence check is automatically done before dispatching.
-    void sendData(Vector3 frame) {
-        if (_delegate)
-            _delegate->sensorUpdate(frame);
-    }
-    Delegate *_delegate;
+    Delegate defaultDelegate;
+    Delegate *delegate;
 };
 
 #endif//_H_SENSOR_H
\ No newline at end of file