Sleep mode fix for BP5758D driver (#5461)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
dwildstr 2023-10-02 19:06:54 -04:00 committed by Jesse Hills
parent 85c5928baa
commit f709350b04
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A

View file

@ -39,10 +39,14 @@ void BP5758D::loop() {
uint8_t data[17];
if (this->pwm_amounts_[0] == 0 && this->pwm_amounts_[1] == 0 && this->pwm_amounts_[2] == 0 &&
this->pwm_amounts_[3] == 0 && this->pwm_amounts_[4] == 0) {
// Off / Sleep
data[0] = BP5758D_MODEL_ID + BP5758D_ADDR_STANDBY;
for (int i = 1; i < 16; i++)
data[i] = 0;
// First turn all channels off
data[0] = BP5758D_MODEL_ID + BP5758D_ADDR_START_3CH;
this->write_buffer_(data, 17);
// Then sleep
data[0] = BP5758D_MODEL_ID + BP5758D_ADDR_STANDBY;
this->write_buffer_(data, 17);
} else if (this->pwm_amounts_[0] == 0 && this->pwm_amounts_[1] == 0 && this->pwm_amounts_[2] == 0 &&
(this->pwm_amounts_[3] > 0 || this->pwm_amounts_[4] > 0)) {