conn/physic: add units and sensing devices

This is to provide a saner abstraction and also stop host from depending on
devices.

Add Ampere, Centi and Volt.

This is to fix #137.
pull/1/head
Marc-Antoine Ruel 8 years ago
parent 989d5f693d
commit 0bc4d173ac

@ -50,6 +50,9 @@ type Display interface {
}
// Environment represents measurements from an environmental sensor.
//
// Deprecated: This interface will be removed in v3. Use physic.Environment
// instead.
type Environment struct {
Temperature Celsius
Pressure KPascal
@ -57,15 +60,11 @@ type Environment struct {
}
// Environmental represents an environmental sensor.
//
// Deprecated: This interface will be removed in v3. Use physic.Environmental
// instead.
type Environmental interface {
conn.Resource
// Sense returns the value read from the sensor. Unsupported metrics are not
// modified.
Sense(env *Environment) error
// SenseContinuous initiates a continuous sensing at the specified interval.
//
// It is important to call Halt() once done with the sensing, which will turn
// the device off and will close the channel.
SenseContinuous(interval time.Duration) (<-chan Environment, error)
}

@ -9,6 +9,8 @@ import (
)
// Milli is a fixed point value with 0.001 precision.
//
// Deprecated: This interface will be removed in v3. Use physic.Milli instead.
type Milli int32
// Float64 returns the value as float64 with 0.001 precision.
@ -27,7 +29,8 @@ func (m Milli) String() string {
// Celsius is a temperature at a precision of 0.001°C.
//
// Expected range is [-273150, >1000000]
// Deprecated: This interface will be removed in v3. Use physic.Celsius
// instead.
type Celsius Milli
// Float64 returns the value as float64 with 0.001 precision.
@ -46,6 +49,9 @@ func (c Celsius) ToF() Fahrenheit {
}
// Fahrenheit is an unsound unit used in the United States.
//
// Deprecated: This interface will be removed in v3. Use physic.Fahrenheit
// instead.
type Fahrenheit Milli
// Float64 returns the value as float64 with 0.001 precision.
@ -60,7 +66,8 @@ func (f Fahrenheit) String() string {
// KPascal is pressure at precision of 1Pa.
//
// Expected range is [0, >1000000].
// Deprecated: This interface will be removed in v3. Use physic.KPascal
// instead.
type KPascal Milli
// Float64 returns the value as float64 with 0.001 precision.
@ -74,6 +81,9 @@ func (k KPascal) String() string {
}
// RelativeHumidity is humidity level in %rH with 0.01%rH precision.
//
// Deprecated: This interface will be removed in v3. Use
// physic.RelativeHumidity instead.
type RelativeHumidity int32
// Float64 returns the value in %.

Loading…
Cancel
Save