mirror of
https://github.com/esphome/esphome.git
synced 2025-04-15 07:10:33 +01:00
commit
7f27d84550
@ -22,7 +22,7 @@ void Mcp4461Component::setup() {
|
|||||||
|
|
||||||
void Mcp4461Component::begin_() {
|
void Mcp4461Component::begin_() {
|
||||||
// save WP/WL status
|
// save WP/WL status
|
||||||
this->set_write_protection_status_();
|
this->update_write_protection_status_();
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
if (this->reg_[i].initial_value.has_value()) {
|
if (this->reg_[i].initial_value.has_value()) {
|
||||||
uint16_t initial_state;
|
uint16_t initial_state;
|
||||||
@ -76,7 +76,7 @@ void Mcp4461Component::set_initial_value(Mcp4461WiperIdx wiper, float initial_va
|
|||||||
this->reg_[wiper_id].initial_value = initial_value;
|
this->reg_[wiper_id].initial_value = initial_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mcp4461Component::set_write_protection_status_() {
|
void Mcp4461Component::update_write_protection_status_() {
|
||||||
uint8_t status_register_value;
|
uint8_t status_register_value;
|
||||||
status_register_value = this->get_status_register();
|
status_register_value = this->get_status_register();
|
||||||
this->write_protected_ = static_cast<bool>((status_register_value >> 0) & 0x01);
|
this->write_protected_ = static_cast<bool>((status_register_value >> 0) & 0x01);
|
||||||
@ -457,7 +457,7 @@ uint8_t Mcp4461Component::get_terminal_register(Mcp4461TerminalIdx terminal_conn
|
|||||||
|
|
||||||
void Mcp4461Component::update_terminal_register(Mcp4461TerminalIdx terminal_connector) {
|
void Mcp4461Component::update_terminal_register(Mcp4461TerminalIdx terminal_connector) {
|
||||||
if (this->is_failed()) {
|
if (this->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(mcp4461_get_message_string(this->error_code_)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((static_cast<uint8_t>(terminal_connector) != 0 && static_cast<uint8_t>(terminal_connector) != 1)) {
|
if ((static_cast<uint8_t>(terminal_connector) != 0 && static_cast<uint8_t>(terminal_connector) != 1)) {
|
||||||
|
@ -107,7 +107,7 @@ class Mcp4461Component : public Component, public i2c::I2CDevice {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Mcp4461Wiper;
|
friend class Mcp4461Wiper;
|
||||||
void set_write_protection_status_();
|
void update_write_protection_status_();
|
||||||
uint8_t get_wiper_address_(uint8_t wiper);
|
uint8_t get_wiper_address_(uint8_t wiper);
|
||||||
uint16_t read_wiper_level_(uint8_t wiper);
|
uint16_t read_wiper_level_(uint8_t wiper);
|
||||||
bool is_writing_();
|
bool is_writing_();
|
||||||
|
@ -8,10 +8,11 @@ namespace esphome {
|
|||||||
namespace mcp4461 {
|
namespace mcp4461 {
|
||||||
|
|
||||||
static const char *const TAG = "mcp4461.output";
|
static const char *const TAG = "mcp4461.output";
|
||||||
|
static const LogString *const LOG_PARENT_FAILED_STR = LOG_STR("Parent MCP4461 component has failed! Aborting");
|
||||||
|
|
||||||
void Mcp4461Wiper::write_state(float state) {
|
void Mcp4461Wiper::write_state(float state) {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@ -33,7 +34,7 @@ uint16_t Mcp4461Wiper::get_wiper_level() { return this->parent_->get_wiper_level
|
|||||||
|
|
||||||
void Mcp4461Wiper::save_level() {
|
void Mcp4461Wiper::save_level() {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@ -49,7 +50,7 @@ void Mcp4461Wiper::save_level() {
|
|||||||
|
|
||||||
void Mcp4461Wiper::enable_wiper() {
|
void Mcp4461Wiper::enable_wiper() {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@ -62,7 +63,7 @@ void Mcp4461Wiper::enable_wiper() {
|
|||||||
|
|
||||||
void Mcp4461Wiper::disable_wiper() {
|
void Mcp4461Wiper::disable_wiper() {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@ -75,7 +76,7 @@ void Mcp4461Wiper::disable_wiper() {
|
|||||||
|
|
||||||
void Mcp4461Wiper::increase_wiper() {
|
void Mcp4461Wiper::increase_wiper() {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@ -90,7 +91,7 @@ void Mcp4461Wiper::increase_wiper() {
|
|||||||
|
|
||||||
void Mcp4461Wiper::decrease_wiper() {
|
void Mcp4461Wiper::decrease_wiper() {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@ -105,7 +106,7 @@ void Mcp4461Wiper::decrease_wiper() {
|
|||||||
|
|
||||||
void Mcp4461Wiper::enable_terminal(char terminal) {
|
void Mcp4461Wiper::enable_terminal(char terminal) {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@ -118,7 +119,7 @@ void Mcp4461Wiper::enable_terminal(char terminal) {
|
|||||||
|
|
||||||
void Mcp4461Wiper::disable_terminal(char terminal) {
|
void Mcp4461Wiper::disable_terminal(char terminal) {
|
||||||
if (this->parent_->is_failed()) {
|
if (this->parent_->is_failed()) {
|
||||||
ESP_LOGE(TAG, "%s", LOG_STR_ARG(Mcp4461Component::MCP4461_PARENT_FAILED));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(LOG_PARENT_FAILED_STR));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user