Add MCP47A1 DAC output (#3014)

This commit is contained in:
Jesse Hills
2022-01-08 21:35:55 +13:00
committed by GitHub
parent 84a830195f
commit ea1be8e7bf
6 changed files with 69 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#include "mcp47a1.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
namespace esphome {
namespace mcp47a1 {
static const char *const TAG = "mcp47a1";
void MCP47A1::dump_config() {
ESP_LOGCONFIG(TAG, "MCP47A1 Output:");
LOG_I2C_DEVICE(this);
}
void MCP47A1::write_state(float state) {
const uint8_t value = remap(state, 0.0f, 1.0f, 63, 0);
this->write_byte(0, value);
}
} // namespace mcp47a1
} // namespace esphome