ESPHome  2024.10.2
mcp47a1.cpp
Go to the documentation of this file.
1 #include "mcp47a1.h"
2 #include "esphome/core/helpers.h"
3 #include "esphome/core/log.h"
4 
5 namespace esphome {
6 namespace mcp47a1 {
7 
8 static const char *const TAG = "mcp47a1";
9 
11  ESP_LOGCONFIG(TAG, "MCP47A1 Output:");
12  LOG_I2C_DEVICE(this);
13 }
14 
16  const uint8_t value = remap(state, 0.0f, 1.0f, 63, 0);
17  this->write_byte(0, value);
18 }
19 
20 } // namespace mcp47a1
21 } // namespace esphome
void write_state(float state) override
Definition: mcp47a1.cpp:15
void dump_config() override
Definition: mcp47a1.cpp:10
T remap(U value, U min, U max, T min_out, T max_out)
Remap value from the range (min, max) to (min_out, max_out).
Definition: helpers.h:153
bool write_byte(uint8_t a_register, uint8_t data, bool stop=true)
Definition: i2c.h:262
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
bool state
Definition: fan.h:34