pub struct Hx711<SPI> { /* private fields */ }
Expand description
Represents an instance of a HX711 device
Implementations§
source§impl<SPI, E> Hx711<SPI>where
SPI: Transfer<u8, Error = E> + Write<u8, Error = E>,
impl<SPI, E> Hx711<SPI>where SPI: Transfer<u8, Error = E> + Write<u8, Error = E>,
sourcepub fn new(spi: SPI) -> Self
pub fn new(spi: SPI) -> Self
opens a connection to a HX711 on a specified SPI.
The datasheet specifies PD_SCK high time and PD_SCK low time to be in the 0.2 to 50 us range, therefore bus speed has to be between 5 MHz and 20 kHz. 1 MHz seems to be a good choice. D is an embedded_hal implementation of DelayMs.
sourcepub fn read(&mut self) -> Result<i32, E>
pub fn read(&mut self) -> Result<i32, E>
reads a value from the HX711 and returns it
Errors
Returns SPI errors and nb::Error::WouldBlock if data isn’t ready to be read from hx711
sourcepub fn reset(&mut self) -> Result<(), E>
pub fn reset(&mut self) -> Result<(), E>
Reset the chip to it’s default state. Mode is set to convert channel A with a gain factor of 128.
Errors
Returns SPI errors