Skip to content

Commit

Permalink
add Sensor interface
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Oct 22, 2021
1 parent b35aab6 commit 5bf78c4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions sensor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package drivers

// Measurement specifies a type of measurement,
// for example: temperature, acceleration, pressure.
type Measurement uint32

// Sensor measurements
const (
Temperature Measurement = 1 << iota
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
}

0 comments on commit 5bf78c4

Please sign in to comment.