Documentation
¶
Index ¶
- Variables
- type Bus
- type BusOption
- type FileReaderWriter
- type Onewire
- type Readings
- type Resolution
- type Sensor
- func (s *Sensor) Average() float64
- func (s *Sensor) Close()
- func (s *Sensor) Configure(config SensorConfig) error
- func (s *Sensor) FullID() string
- func (s *Sensor) GetConfig() SensorConfig
- func (s *Sensor) GetReadings() []Readings
- func (s *Sensor) ID() string
- func (s *Sensor) Name() string
- func (s *Sensor) Poll()
- func (s *Sensor) Temperature() (actual, avg float64, err error)
- type SensorConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoSuchID = errors.New("there is no sensor with provided ID") ErrNoInterface = errors.New("no interface") )
View Source
var (
ErrUnexpectedResolution = errors.New("unexpected resolution")
)
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
type BusOption ¶
type BusOption func(bus *Bus)
func WithInterface ¶
func WithOnewire ¶
func WithOnewire() BusOption
func WithOnewireOnPath ¶
type FileReaderWriter ¶
type Onewire ¶
type Onewire interface { Path() string FileReaderWriter }
Onewire represents Linux onewire driver
type Readings ¶
type Readings struct { ID string `json:"id"` Temperature float64 `json:"temperature"` Average float64 `json:"average"` Stamp time.Time `json:"stamp"` Error string `json:"error"` }
Readings are returned, when Sensor is used in Poll mode
type Resolution ¶
type Resolution int
const ( Resolution9Bit Resolution = 9 Resolution10Bit Resolution = 10 Resolution11Bit Resolution = 11 Resolution12Bit Resolution = 12 )
Possible resolutions
type Sensor ¶
type Sensor struct { FileReaderWriter // contains filtered or unexported fields }
Sensor represents DS18b20
func NewSensor ¶
func NewSensor(o FileReaderWriter, id, basePath string) (*Sensor, error)
NewSensor creates new sensor based on args
func (*Sensor) Configure ¶
func (s *Sensor) Configure(config SensorConfig) error
Configure allows user to configure sensor with SensorConfig
func (*Sensor) GetConfig ¶
func (s *Sensor) GetConfig() SensorConfig
GetConfig returns current config
func (*Sensor) GetReadings ¶
GetReadings returns all collected readings and then clears data
func (*Sensor) Poll ¶
func (s *Sensor) Poll()
Poll is an option to run temperature updates in background After calling Poll, user can get data from GetReadings
func (*Sensor) Temperature ¶
Temperature returns current temperature and average (which is based on Samples)
type SensorConfig ¶
type SensorConfig struct { Name string `json:"name"` ID string `json:"id"` Correction float64 `json:"correction"` Resolution Resolution `json:"resolution"` PollInterval time.Duration `json:"poll_interval"` Samples uint `json:"samples"` }
SensorConfig allows user to configure Sensor (except ID, which is unique and can't be changed)
Click to show internal directories.
Click to hide internal directories.