tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/sensor.go (about) 1 package drivers 2 3 // Measurement specifies a type of measurement, 4 // for example: temperature, acceleration, pressure. 5 type Measurement uint32 6 7 // Sensor measurements 8 const ( 9 Voltage Measurement = 1 << iota 10 Temperature 11 Humidity 12 Pressure 13 Distance 14 Acceleration 15 AngularVelocity 16 MagneticField 17 Luminosity 18 Time 19 // Gas or liquid concentration, usually measured in ppm (parts per million). 20 Concentration 21 // Add Measurements above AllMeasurements. 22 23 // AllMeasurements is the OR of all Measurement values. It ensures all measurements are done. 24 AllMeasurements Measurement = (1 << 32) - 1 25 ) 26 27 // Sensor represents an object capable of making one 28 // or more measurements. A sensor will then have methods 29 // which read the last updated measurements. 30 // 31 // Many Sensors may be collected into 32 // one Sensor interface to synchronize measurements. 33 type Sensor interface { 34 // Update performs IO to update the measurements of a sensor. 35 // It shall return error only when the sensor encounters an error that prevents it from 36 // storing all or part of the measurements it was called to do. 37 Update(which Measurement) error 38 }