endail / hx711-pico-c

Implementation of single and multiple HX711 use via RP2040's state machine
https://endail.github.io/hx711-pico-c/
MIT License
35 stars 7 forks source link

State machine should accept an initial, configurable gain #46

Closed endail closed 1 year ago

endail commented 1 year ago

https://github.com/endail/hx711-pico-c/blob/abf2bf6e9e89ae887d1102dcccdd6394adf65845/src/hx711_noblock.pio#L83

Currently the state machine begins with a predefined default gain of 128. This is fine if when the HX711 chip has powered up it too is configured for a gain of 128. But it is possible for a different gain to be saved to the chip for when it restarts.

This may require filling the TX FIFO with a gain value prior to starting the state machine, but also a nonblocking pull in the PIO program to set a default.

endail commented 1 year ago

On second thought, setting the X register directly from C prior to starting the state machine might be a better option. That way the pull can be avoided altogether and even a default gain word in the machine.

endail commented 1 year ago

It doesn't seem like the register can be set through a standard sdk function call. An ad hoc pull and mov through pio_sm_exec would also work.