Fix xl9535 pin reads (#6242)

This commit is contained in:
Jesse Hills 2024-02-19 16:44:18 +13:00
parent 6eb3c65445
commit cc1813f5b9
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -36,14 +36,14 @@ bool XL9535Component::digital_read(uint8_t pin) {
return state; return state;
} }
state = (port & (pin - 10)) != 0; state = (port & (1 << (pin - 10))) != 0;
} else { } else {
if (this->read_register(XL9535_INPUT_PORT_0_REGISTER, &port, 1) != i2c::ERROR_OK) { if (this->read_register(XL9535_INPUT_PORT_0_REGISTER, &port, 1) != i2c::ERROR_OK) {
this->status_set_warning(); this->status_set_warning();
return state; return state;
} }
state = (port & pin) != 0; state = (port & (1 << pin)) != 0;
} }
this->status_clear_warning(); this->status_clear_warning();