mirror of
https://github.com/esphome/esphome.git
synced 2025-09-27 15:42:22 +01:00
Update mcp4461.cpp
This commit is contained in:
@@ -100,16 +100,16 @@ uint8_t Mcp4461Component::get_wiper_address_(uint8_t wiper) {
|
|||||||
}
|
}
|
||||||
switch (wiper) {
|
switch (wiper) {
|
||||||
case 0:
|
case 0:
|
||||||
addr = static_cast<uint8_t>(Mcp4461Addresses::MCP4461_VW0);
|
addr = std::to_underlying(Mcp4461Addresses::MCP4461_VW0);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
addr = static_cast<uint8_t>(Mcp4461Addresses::MCP4461_VW1);
|
addr = std::to_underlying(Mcp4461Addresses::MCP4461_VW1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
addr = static_cast<uint8_t>(Mcp4461Addresses::MCP4461_VW2);
|
addr = std::to_underlying(Mcp4461Addresses::MCP4461_VW2);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
addr = static_cast<uint8_t>(Mcp4461Addresses::MCP4461_VW3);
|
addr = std::to_underlying(Mcp4461Addresses::MCP4461_VW3);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ESP_LOGE(TAG, "unknown wiper specified");
|
ESP_LOGE(TAG, "unknown wiper specified");
|
||||||
@@ -123,6 +123,10 @@ uint8_t Mcp4461Component::get_wiper_address_(uint8_t wiper) {
|
|||||||
|
|
||||||
uint16_t Mcp4461Component::get_wiper_level(Mcp4461WiperIdx wiper) {
|
uint16_t Mcp4461Component::get_wiper_level(Mcp4461WiperIdx wiper) {
|
||||||
uint8_t wiper_idx = static_cast<uint8_t>(wiper);
|
uint8_t wiper_idx = static_cast<uint8_t>(wiper);
|
||||||
|
if (!this->reg_[wiper_idx].enabled) {
|
||||||
|
ESP_LOGW(TAG, "reading from disabled volatile wiper %" PRIu8 ", returning 0", wiper_idx);
|
||||||
|
return static_cast<uint16_t>(0);
|
||||||
|
}
|
||||||
return this->read_wiper_level_(wiper_idx);
|
return this->read_wiper_level_(wiper_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user