Documentation
¶
Index ¶
- Constants
- type Device
- func (d *Device) Calibrate(setValue float32, secondReading bool) error
- func (d *Device) Configure() error
- func (d *Device) OffsetAndCalibrationFactor(secondReading bool) (int32, float32)
- func (d *Device) SetGainAndChannel(gc gainAndChannelCfg) error
- func (d *Device) SetOffsetAndCalibrationFactor(offset int32, calibrationFactor float32, secondReading bool)
- func (d *Device) Update(drivers.Measurement) error
- func (d *Device) Values() (float32, float32)
- func (d *Device) Zero(secondReading bool) error
Constants ¶
const ( None gainAndChannelCfg = 0 // channel is not used A128 gainAndChannelCfg = 1 // channel A, gain factor 128 - 25 pulses B32 gainAndChannelCfg = 2 // channel B, gain factor 32 - 26 pulses A64 gainAndChannelCfg = 3 // channel A, gain factor 64 - 27 pulses A128B32 gainAndChannelCfg = 4 // channel A@128 and channel B@32 - after first read 26 pulses, after second 25 pulses A64B32 gainAndChannelCfg = 5 // channel A@64 and channel B@32 - after first read 26 pulses, after second 27 pulses )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device contains attributes for reading the values of HX711, a configurable ADC with a serial output to measure small differential voltages. The device is handy for load cells but can be used to read all kind of Wheatstone bridges. Therefore the usage of the phrases "mass", "weight" or "load" are prevented in this driver - "value" is used instead.
func New ¶
func New(powerDownAndSckPin outputPinner, dataPin inputPinner, gc gainAndChannelCfg, tickSleep time.Duration) *Device
New returns a device for reading differential voltages with 2 inputs (A, B). The gain of input A can be chosen between 128 (default) and 64 - the gain of input B is always 32. The reading can be chosen between: * A@128 only * A@64 only * B@32 only * A@128 followed by B@32 * A@64 followed by B@32 setting "tickSleep" to a value bigger than 0 is needed for fast MCUs, typically 1 us is needed and the HX711 works between 0.2 and 50 us pulse wide according the data sheet - for the nRF52840 setting this to 0 leads to a pulse wide of around 1 us, which is fine, but setting it to 1 us leads to a pulse wide of 20 us, which also will work
func (*Device) Calibrate ¶
Calibrate calculates, after a measurement of the set value is done, a factor for linear scaling the values of the subsequent measurements. The unit of the given set value define the unit of the measurement result later. Before using this function, the offset value should be obtained by calling Zero() function with no load. If the given flag is true, this is done for the second reading.
func (*Device) OffsetAndCalibrationFactor ¶
OffsetAndCalibrationFactor returns linear correction values, used for reading. If the given flag is true, this values are related to the second reading.
func (*Device) SetGainAndChannel ¶
SetGainAndChannel changes the gain and channel configuration for the next reading and reset the device
func (*Device) SetOffsetAndCalibrationFactor ¶
func (d *Device) SetOffsetAndCalibrationFactor(offset int32, calibrationFactor float32, secondReading bool)
SetOffsetAndCalibrationFactor sets linear correction values, used for reading. If the given flag is true, this values are related to the second reading.
func (*Device) Update ¶
func (d *Device) Update(drivers.Measurement) error
Update implements the drivers.Sensor interface