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