From 9a64a6d6d833927db2061526c5013647c5326b03 Mon Sep 17 00:00:00 2001 From: soypat Date: Sun, 26 Sep 2021 10:08:11 -0300 Subject: [PATCH] add Sensor interface --- sensor.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 sensor.go diff --git a/sensor.go b/sensor.go new file mode 100644 index 000000000..e5e9d197a --- /dev/null +++ b/sensor.go @@ -0,0 +1,31 @@ +package drivers + +// Measurement specifies a type of measurement, +// for example: temperature, acceleration, pressure. +type Measurement uint32 + +// Sensor measurements +const ( + Voltage Measurement = 1 << iota + Temperature + Humidity + Pressure + Distance + Acceleration + AngularVelocity + MagneticField + Luminosity + Time + + AllMeasurements Measurement = 0xffffffff +) + +// Sensor represents an object capable of making one +// or more measurements. A sensor will then have methods +// which read the last updated measurements. +// +// Many Sensors may be collected into +// one Sensor interface to synchronize measurements. +type Sensor interface { + Update(which Measurement) error +}