Implemented first Hangar-Service
Dependencies: CalibrateMagneto QuaternionMath
Fork of SML2 by
Diff: Sensor.h
- Revision:
- 12:1632d7391453
- Parent:
- 8:cba37530d480
- Child:
- 15:4488660e1a3b
diff -r d21275e60ebb -r 1632d7391453 Sensor.h --- a/Sensor.h Thu Mar 12 10:16:01 2015 +0000 +++ b/Sensor.h Fri Mar 13 09:12:56 2015 +0000 @@ -4,31 +4,33 @@ #include "Vector3.h" /// Base class for I2C-connected sensors. Defines functionality supported by all sensors. -class Sensor { +class Sensor +{ public: /// Defines protocol used to send data back to owner. Derive from this class and use Sensor.setDelegate() to receive sensor updates. - class Delegate { + class Delegate + { public: /// A new sensor data frame, might be called several (hundred) times a second. virtual void sensorUpdate(Sensor* source, Vector3 data) = 0; }; - + virtual void setDelegate(Delegate &d) { _delegate = &d; } - + /// Power on a sensor and make it ready for use. /// @return true if power-up was successful, false otherwise. virtual bool powerOn() = 0; - + /// Power off a sensor. This will generally only put the sensor into deep sleep. virtual void powerOff() = 0; - + virtual void start() = 0; ///< Start continuous data capture. If a delegate is set, its sensorUpdate() method will be called for each data frame. virtual void stop() = 0; ///< Stop capturing data. - + virtual Vector3 read() = 0; ///< Read and return instantaneous (current) sensor data. No need to start the sensor. - + 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) {