Documentation ¶
Index ¶
- Variables
- func HostInit() error
- type Hx711
- func (hx711 *Hx711) BackgroundReadMovingAvgs(numReadings, numAvgs int, movingAvg *float64, stop *bool, ...)
- func (hx711 *Hx711) GetAdjustValues(weight1 float64, weight2 float64)
- func (hx711 *Hx711) ReadDataMedian(numReadings int) (float64, error)
- func (hx711 *Hx711) ReadDataMedianRaw(numReadings int) (int, error)
- func (hx711 *Hx711) ReadDataMedianThenAvg(numReadings, numAvgs int) (float64, error)
- func (hx711 *Hx711) ReadDataMedianThenMovingAvgs(numReadings, numAvgs int, previousReadings *[]float64) (float64, error)
- func (hx711 *Hx711) ReadDataRaw() (int, error)
- func (hx711 *Hx711) Reset() error
- func (hx711 *Hx711) SetGain(gain int)
- func (hx711 *Hx711) Shutdown() error
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = fmt.Errorf("timeout")
Functions ¶
Types ¶
type Hx711 ¶
type Hx711 struct { // AdjustZero should be set to an int that will zero out a raw reading AdjustZero int // AdjustScale should be set to a float64 that will give output units wanted AdjustScale float64 // contains filtered or unexported fields }
Hx711 struct to interface with the hx711 chip. Call NewHx711 to create a new one.
func NewHx711 ¶
NewHx711 creates new Hx711. Make sure to set clockPinName and dataPinName to the correct pins. https://cdn.sparkfun.com/datasheets/Sensors/ForceFlex/hx711_english.pdf
func (*Hx711) BackgroundReadMovingAvgs ¶
func (hx711 *Hx711) BackgroundReadMovingAvgs(numReadings, numAvgs int, movingAvg *float64, stop *bool, stopped chan struct{})
BackgroundReadMovingAvgs it meant to be run in the background, run as a Goroutine. Will continue to get readings and update movingAvg until stop is set to true. After it has been stopped, the stopped chan will be closed. Note when scale errors the movingAvg value will not change. Do not call Reset before or Shutdown after. Reset and Shutdown are called for you. Will panic if movingAvg or stop are nil
func (*Hx711) GetAdjustValues ¶
GetAdjustValues will help get you the adjust values to plug in later. Do not call Reset before or Shutdown after. Reset and Shutdown are called for you.
func (*Hx711) ReadDataMedian ¶
ReadDataMedian will get median of numReadings raw readings, then will adjust number with AdjustZero and AdjustScale. Do not call Reset before or Shutdown after. Reset and Shutdown are called for you.
func (*Hx711) ReadDataMedianRaw ¶
ReadDataMedianRaw will get median of numReadings raw readings. Do not call Reset before or Shutdown after. Reset and Shutdown are called for you.
func (*Hx711) ReadDataMedianThenAvg ¶
ReadDataMedianThenAvg will get median of numReadings raw readings, then do that numAvgs number of time, and average those. then will adjust number with AdjustZero and AdjustScale. Do not call Reset before or Shutdown after. Reset and Shutdown are called for you.
func (*Hx711) ReadDataMedianThenMovingAvgs ¶
func (hx711 *Hx711) ReadDataMedianThenMovingAvgs(numReadings, numAvgs int, previousReadings *[]float64) (float64, error)
ReadDataMedianThenMovingAvgs will get median of numReadings raw readings, then will adjust number with AdjustZero and AdjustScale. Stores data into previousReadings. Then returns moving average. Do not call Reset before or Shutdown after. Reset and Shutdown are called for you. Will panic if previousReadings is nil
func (*Hx711) ReadDataRaw ¶
ReadDataRaw will get one raw reading from chip. Usually will need to call Reset before calling this and Shutdown after.
func (*Hx711) Reset ¶
Reset starts up or resets the chip. The chip needs to be reset if it is not used for just about any amount of time.