endail/hx711

Typedef for raw values

endail opened this issue · 1 comments

static std::int32_t _convertFromTwosComplement(const std::int32_t val) noexcept;

hx711/src/HX711.cpp

Lines 65 to 67 in de87c5b

std::int32_t HX711::_convertFromTwosComplement(const std::int32_t val) noexcept {
return -(val & 0x800000) + (val & 0x7fffff);
}

void HX711::_readBits(std::int32_t* const v) {

std::int32_t v = 0;

HX711 uses 24 bits, but in code it's unclear why a 32 bit int is used.

Suggest typedef'ing std::int32_t (or one of the other std ints) with HX711::rawval_t or similar.