ESPHome 2025.5.0
Loading...
Searching...
No Matches
gp8403_output.cpp
Go to the documentation of this file.
1#include "gp8403_output.h"
2
3#include "esphome/core/log.h"
4
5namespace esphome {
6namespace gp8403 {
7
8static const char *const TAG = "gp8403.output";
9
10static const uint8_t OUTPUT_REGISTER = 0x02;
11
13 ESP_LOGCONFIG(TAG, "GP8403 Output:");
14 ESP_LOGCONFIG(TAG, " Channel: %u", this->channel_);
15}
16
18 uint16_t value = ((uint16_t) (state * 4095)) << 4;
19 i2c::ErrorCode err = this->parent_->write_register(OUTPUT_REGISTER + (2 * this->channel_), (uint8_t *) &value, 2);
20 if (err != i2c::ERROR_OK) {
21 ESP_LOGE(TAG, "Error writing to GP8403, code %d", err);
22 }
23}
24
25} // namespace gp8403
26} // namespace esphome
void write_state(float state) override
bool state
Definition fan.h:0
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
Definition i2c_bus.h:11
@ ERROR_OK
No error found during execution of method.
Definition i2c_bus.h:13
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7