ESPHome
2025.5.0
Loading...
Searching...
No Matches
esphome
components
gp8403
output
gp8403_output.cpp
Go to the documentation of this file.
1
#include "
gp8403_output.h
"
2
3
#include "
esphome/core/log.h
"
4
5
namespace
esphome
{
6
namespace
gp8403 {
7
8
static
const
char
*
const
TAG =
"gp8403.output"
;
9
10
static
const
uint8_t OUTPUT_REGISTER = 0x02;
11
12
void
GP8403Output::dump_config
() {
13
ESP_LOGCONFIG(TAG,
"GP8403 Output:"
);
14
ESP_LOGCONFIG(TAG,
" Channel: %u"
, this->
channel_
);
15
}
16
17
void
GP8403Output::write_state
(
float
state
) {
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
esphome::Parented< GP8403 >::parent_
GP8403 * parent_
Definition
helpers.h:549
esphome::gp8403::GP8403Output::dump_config
void dump_config() override
Definition
gp8403_output.cpp:12
esphome::gp8403::GP8403Output::write_state
void write_state(float state) override
Definition
gp8403_output.cpp:17
esphome::gp8403::GP8403Output::channel_
uint8_t channel_
Definition
gp8403_output.h:21
state
bool state
Definition
fan.h:0
gp8403_output.h
log.h
esphome::i2c::ErrorCode
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
Definition
i2c_bus.h:11
esphome::i2c::ERROR_OK
@ ERROR_OK
No error found during execution of method.
Definition
i2c_bus.h:13
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
Generated by
1.12.0