Documentation ¶
Overview ¶
Package hx711 implements an interface to the 24-bits HX711 analog to digital converter.
Datasheet ¶
Index ¶
- Variables
- type Dev
- func (d *Dev) Func() pin.Func
- func (d *Dev) Function() string
- func (d *Dev) Halt() error
- func (d *Dev) IsReady() bool
- func (d *Dev) Name() string
- func (d *Dev) Number() int
- func (d *Dev) Range() (analog.Sample, analog.Sample)
- func (d *Dev) Read() (analog.Sample, error)
- func (d *Dev) ReadContinuous() <-chan analog.Sample
- func (d *Dev) ReadTimeout(timeout time.Duration) (int32, error)
- func (d *Dev) SetFunc(f pin.Func) error
- func (d *Dev) SetInputMode(inputMode InputMode) error
- func (d *Dev) String() string
- func (d *Dev) SupportedFuncs() []pin.Func
- type InputMode
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTimeout is returned from Read and ReadAveraged when the ADC took too // long to indicate data was available. ErrTimeout = errors.New("timed out waiting for HX711 to become ready") )
Functions ¶
This section is empty.
Types ¶
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is a handle to a hx711.
func New ¶
New creates a new HX711 device.
The data pin must support edge detection. If your pin doesn't natively support edge detection you can use PollEdge from gpioutil.
func (*Dev) Halt ¶
Halt stops a continuous read that was started with ReadContinuous.
This will close the channel that was returned by ReadContinuous.
func (*Dev) ReadContinuous ¶
ReadContinuous starts reading values continuously from the ADC. It returns a channel that you can use to receive these values.
You must call Halt to stop reading.
Calling ReadContinuous again before Halt is an error, and nil will be returned.
func (*Dev) ReadTimeout ¶
ReadTimeout reads a single value from the ADC.
It blocks until the ADC indicates there is data ready for retrieval. If the ADC doesn't pull its Data pin low to indicate there is data ready before the timeout is reached, ErrTimeout is returned.
func (*Dev) SetInputMode ¶
SetInputMode changes the voltage gain and channel multiplexer mode.
func (*Dev) SupportedFuncs ¶
SupportedFuncs implements analog.PinADC.