mirror of
https://github.com/esphome/esphome.git
synced 2025-10-31 23:21:54 +00:00
Update mcp4461_output.cpp
This commit is contained in:
@@ -8,16 +8,18 @@ namespace esphome {
|
|||||||
namespace mcp4461 {
|
namespace mcp4461 {
|
||||||
|
|
||||||
static const char *const TAG = "mcp4461.output";
|
static const char *const TAG = "mcp4461.output";
|
||||||
static const LogString *mcp4461_get_message_string(int status) {
|
static const LogString *get_wiper_message_string(int status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case Mcp4461Component::COMPONENT_FAILED:
|
||||||
|
return LOG_STR("Parent MCP4461 component failed");
|
||||||
|
default:
|
||||||
|
return LOG_STR("Unknown error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@@ -39,7 +41,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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@@ -55,7 +57,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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@@ -68,7 +70,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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@@ -81,7 +83,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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@@ -96,7 +98,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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@@ -111,7 +113,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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
@@ -124,7 +126,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(LOG_PARENT_FAILED_STR));
|
ESP_LOGE(TAG, "%s", LOG_STR_ARG(get_wiper_message_string(Mcp4461Component::COMPONENT_FAILED)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
uint8_t wiper_idx = static_cast<uint8_t>(this->wiper_);
|
||||||
|
|||||||
Reference in New Issue
Block a user