mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
BP1658CJ - Fix timing for all platforms, now consistent with other drivers (#5799)
This commit is contained in:
parent
d0bcba3b3f
commit
a72725f4b4
1 changed files with 8 additions and 7 deletions
|
@ -90,40 +90,41 @@ void BP1658CJ::set_channel_value_(uint8_t channel, uint16_t value) {
|
|||
|
||||
void BP1658CJ::write_bit_(bool value) {
|
||||
this->data_pin_->digital_write(value);
|
||||
this->clock_pin_->digital_write(true);
|
||||
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
|
||||
this->clock_pin_->digital_write(true);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
this->clock_pin_->digital_write(false);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
}
|
||||
|
||||
void BP1658CJ::write_byte_(uint8_t data) {
|
||||
for (uint8_t mask = 0x80; mask; mask >>= 1) {
|
||||
this->write_bit_(data & mask);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
}
|
||||
|
||||
// ack bit
|
||||
this->data_pin_->pin_mode(gpio::FLAG_INPUT);
|
||||
this->clock_pin_->digital_write(true);
|
||||
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
|
||||
this->clock_pin_->digital_write(false);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
this->data_pin_->pin_mode(gpio::FLAG_OUTPUT);
|
||||
}
|
||||
|
||||
void BP1658CJ::write_buffer_(uint8_t *buffer, uint8_t size) {
|
||||
this->data_pin_->digital_write(false);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
this->clock_pin_->digital_write(false);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
this->write_byte_(buffer[i]);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
}
|
||||
|
||||
this->clock_pin_->digital_write(true);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
this->data_pin_->digital_write(true);
|
||||
delayMicroseconds(BP1658CJ_DELAY);
|
||||
}
|
||||
|
||||
} // namespace bp1658cj
|
||||
|
|
Loading…
Reference in a new issue