Closed hubiscode closed 2 years ago
I get incorrect values for negative numbers. The following function for the conversion from 24-bit to 32-bit works correctly for me.
static inline int32_t hx711_get_twos_comp(const uint32_t raw) { int32_t val = raw; if (val & 0x800000) { val -= 0x1000000; } assert(val >= HX711_MIN_VALUE && val <= HX711_MAX_VALUE); return val; }
This should be fixed now. Can you check if it's working for you?
Works great, thank you.
I get incorrect values for negative numbers. The following function for the conversion from 24-bit to 32-bit works correctly for me.