Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: sensor.h
- Revision:
- 27:27cffdb2e9d3
- Child:
- 34:e67581c9b50d
diff -r bdb2bf657f29 -r 27cffdb2e9d3 sensor.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensor.h Mon Jan 09 23:26:52 2017 +0000
@@ -0,0 +1,41 @@
+#include "common.h"
+
+class Sensor {
+ public:
+ explicit Sensor(SENSOR_TYPE id);
+
+ virtual void updateState() = 0;
+ virtual Data dataToSend() = 0;
+ virtual void resetState() = 0;
+
+ protected:
+ SENSOR_TYPE sensor_id_;
+};
+
+class DigitalSensor: public Sensor {
+ public:
+ explicit DigitalSensor(SENSOR_TYPE id, PinName pin=PA_10);
+
+ virtual void updateState();
+ virtual Data dataToSend();
+ virtual void resetState();
+
+ static const float SEND_INTERVAL;
+ private:
+ DigitalIn sensor_;
+ bool last_state_;
+ int32_t changes_counter_;
+};
+
+class AnalogSensor: public Sensor {
+ public:
+ explicit AnalogSensor(SENSOR_TYPE id, PinName pin=PA_4);
+
+ virtual void updateState();
+ virtual Data dataToSend();
+ virtual void resetState();
+
+ static const float SEND_INTERVAL;
+ private:
+ AnalogIn sensor_;
+};
\ No newline at end of file