ESPHome 2025.5.0
Loading...
Searching...
No Matches
gp8403.cpp
Go to the documentation of this file.
1#include "gp8403.h"
2
3#include "esphome/core/log.h"
4
5namespace esphome {
6namespace gp8403 {
7
8static const char *const TAG = "gp8403";
9
10static const uint8_t RANGE_REGISTER = 0x01;
11
12void GP8403::setup() { this->write_register(RANGE_REGISTER, (uint8_t *) (&this->voltage_), 1); }
13
15 ESP_LOGCONFIG(TAG, "GP8403:");
16 ESP_LOGCONFIG(TAG, " Voltage: %dV", this->voltage_ == GP8403_VOLTAGE_5V ? 5 : 10);
17 LOG_I2C_DEVICE(this);
18}
19
20} // namespace gp8403
21} // namespace esphome
void dump_config() override
Definition gp8403.cpp:14
GP8403Voltage voltage_
Definition gp8403.h:23
void setup() override
Definition gp8403.cpp:12
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a specific register in the I²C device
Definition i2c.cpp:25
@ GP8403_VOLTAGE_5V
Definition gp8403.h:10
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7