mirror of
https://github.com/esphome/esphome.git
synced 2025-04-14 23:00:29 +01:00
commit
1d024432e3
@ -134,9 +134,9 @@ void Mcp4461Component::loop() {
|
|||||||
if (status_has_warning()) {
|
if (status_has_warning()) {
|
||||||
this->get_status_register();
|
this->get_status_register();
|
||||||
}
|
}
|
||||||
if (this->update_) {
|
uint8_t i;
|
||||||
uint8_t i;
|
for (i = 0; i < 8; i++) {
|
||||||
for (i = 0; i < 8; i++) {
|
if (this->reg_[i].update) {
|
||||||
// set wiper i state if changed
|
// set wiper i state if changed
|
||||||
if (this->reg_[i].state != this->read_wiper_level_(i)) {
|
if (this->reg_[i].state != this->read_wiper_level_(i)) {
|
||||||
this->write_wiper_level_(i, this->reg_[i].state);
|
this->write_wiper_level_(i, this->reg_[i].state);
|
||||||
@ -158,7 +158,7 @@ void Mcp4461Component::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->update_ = false;
|
this->reg_[i].update = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ void Mcp4461Component::set_wiper_level(Mcp4461WiperIdx wiper, uint16_t value) {
|
|||||||
}
|
}
|
||||||
ESP_LOGV(TAG, "Setting MCP4461 wiper %" PRIu8 " to %" PRIu16 "!", wiper_idx, value);
|
ESP_LOGV(TAG, "Setting MCP4461 wiper %" PRIu8 " to %" PRIu16 "!", wiper_idx, value);
|
||||||
this->reg_[wiper_idx].state = value;
|
this->reg_[wiper_idx].state = value;
|
||||||
this->update_ = true;
|
this->reg_[wiper_idx].update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mcp4461Component::write_wiper_level_(uint8_t wiper, uint16_t value) {
|
void Mcp4461Component::write_wiper_level_(uint8_t wiper, uint16_t value) {
|
||||||
@ -324,7 +324,7 @@ void Mcp4461Component::enable_wiper(Mcp4461WiperIdx wiper) {
|
|||||||
}
|
}
|
||||||
ESP_LOGV(TAG, "Enabling wiper %" PRIu8, wiper_idx);
|
ESP_LOGV(TAG, "Enabling wiper %" PRIu8, wiper_idx);
|
||||||
this->reg_[wiper_idx].terminal_hw = true;
|
this->reg_[wiper_idx].terminal_hw = true;
|
||||||
this->update_ = true;
|
this->reg_[wiper_idx].update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mcp4461Component::disable_wiper(Mcp4461WiperIdx wiper) {
|
void Mcp4461Component::disable_wiper(Mcp4461WiperIdx wiper) {
|
||||||
@ -343,7 +343,7 @@ void Mcp4461Component::disable_wiper(Mcp4461WiperIdx wiper) {
|
|||||||
}
|
}
|
||||||
ESP_LOGV(TAG, "Disabling wiper %" PRIu8, wiper_idx);
|
ESP_LOGV(TAG, "Disabling wiper %" PRIu8, wiper_idx);
|
||||||
this->reg_[wiper_idx].terminal_hw = false;
|
this->reg_[wiper_idx].terminal_hw = false;
|
||||||
this->update_ = true;
|
this->reg_[wiper_idx].update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mcp4461Component::increase_wiper(Mcp4461WiperIdx wiper) {
|
bool Mcp4461Component::increase_wiper(Mcp4461WiperIdx wiper) {
|
||||||
@ -530,7 +530,7 @@ void Mcp4461Component::enable_terminal(Mcp4461WiperIdx wiper, char terminal) {
|
|||||||
ESP_LOGW(TAG, "Unknown terminal %c specified", terminal);
|
ESP_LOGW(TAG, "Unknown terminal %c specified", terminal);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->update_ = true;
|
this->reg_[wiper_idx].update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mcp4461Component::disable_terminal(Mcp4461WiperIdx wiper, char terminal) {
|
void Mcp4461Component::disable_terminal(Mcp4461WiperIdx wiper, char terminal) {
|
||||||
@ -560,7 +560,7 @@ void Mcp4461Component::disable_terminal(Mcp4461WiperIdx wiper, char terminal) {
|
|||||||
ESP_LOGW(TAG, "Unknown terminal %c specified", terminal);
|
ESP_LOGW(TAG, "Unknown terminal %c specified", terminal);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->update_ = true;
|
this->reg_[wiper_idx].update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Mcp4461Component::get_eeprom_value(Mcp4461EepromLocation location) {
|
uint16_t Mcp4461Component::get_eeprom_value(Mcp4461EepromLocation location) {
|
||||||
|
@ -8,6 +8,7 @@ namespace esphome {
|
|||||||
namespace mcp4461 {
|
namespace mcp4461 {
|
||||||
|
|
||||||
struct WiperState {
|
struct WiperState {
|
||||||
|
bool update = false;
|
||||||
bool terminal_a = true;
|
bool terminal_a = true;
|
||||||
bool terminal_b = true;
|
bool terminal_b = true;
|
||||||
bool terminal_w = true;
|
bool terminal_w = true;
|
||||||
@ -118,7 +119,6 @@ class Mcp4461Component : public Component, public i2c::I2CDevice {
|
|||||||
|
|
||||||
WiperState reg_[8];
|
WiperState reg_[8];
|
||||||
void begin_();
|
void begin_();
|
||||||
bool update_{false};
|
|
||||||
bool last_eeprom_write_timed_out_{false};
|
bool last_eeprom_write_timed_out_{false};
|
||||||
bool write_protected_{false};
|
bool write_protected_{false};
|
||||||
bool wiper_0_disabled_{false};
|
bool wiper_0_disabled_{false};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user