mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
Update gp8211_output.cpp
This commit is contained in:
parent
e8e8097e8c
commit
e8c9529337
1 changed files with 2 additions and 4 deletions
|
@ -8,9 +8,7 @@ static const char *const TAG = "gp8211.output";
|
||||||
|
|
||||||
static const uint8_t OUTPUT_REGISTER = 0x02;
|
static const uint8_t OUTPUT_REGISTER = 0x02;
|
||||||
|
|
||||||
void GP8211Output::dump_config() {
|
void GP8211Output::dump_config() { ESP_LOGCONFIG(TAG, "GP8211 Output:"); }
|
||||||
ESP_LOGCONFIG(TAG, "GP8211 Output:");
|
|
||||||
}
|
|
||||||
|
|
||||||
void GP8211Output::write_state(float state) {
|
void GP8211Output::write_state(float state) {
|
||||||
ESP_LOGD(TAG, "Original brightness state received from Light component: %.5f", state);
|
ESP_LOGD(TAG, "Original brightness state received from Light component: %.5f", state);
|
||||||
|
@ -18,7 +16,7 @@ void GP8211Output::write_state(float state) {
|
||||||
uint16_t value = static_cast<uint16_t>(state * 32767);
|
uint16_t value = static_cast<uint16_t>(state * 32767);
|
||||||
ESP_LOGD(TAG, "Calculated DAC value: %u", value);
|
ESP_LOGD(TAG, "Calculated DAC value: %u", value);
|
||||||
|
|
||||||
i2c::ErrorCode err = this->parent_->write_register(OUTPUT_REGISTER, (uint8_t *)&value, 2);
|
i2c::ErrorCode err = this->parent_->write_register(OUTPUT_REGISTER, (uint8_t *) &value, 2);
|
||||||
|
|
||||||
if (err != i2c::ERROR_OK) {
|
if (err != i2c::ERROR_OK) {
|
||||||
ESP_LOGE(TAG, "Error writing to GP8211, code %d", err);
|
ESP_LOGE(TAG, "Error writing to GP8211, code %d", err);
|
||||||
|
|
Loading…
Reference in a new issue