Add X9C Potentiometer component (#4183)

fixes https://github.com/esphome/feature-requests/issues/1270
This commit is contained in:
EtienneMD
2023-01-10 20:51:50 -05:00
committed by GitHub
parent a19f0c0db0
commit 1cf3424ebe
7 changed files with 159 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/hal.h"
#include "esphome/components/output/float_output.h"
namespace esphome {
namespace x9c {
class X9cOutput : public output::FloatOutput, public Component {
public:
void set_cs_pin(InternalGPIOPin *pin) { cs_pin_ = pin; }
void set_inc_pin(InternalGPIOPin *pin) { inc_pin_ = pin; }
void set_ud_pin(InternalGPIOPin *pin) { ud_pin_ = pin; }
void set_initial_value(float initial_value) { initial_value_ = initial_value; }
void setup() override;
void dump_config() override;
void trim_value(int change_amount);
protected:
void write_state(float state) override;
InternalGPIOPin *cs_pin_;
InternalGPIOPin *inc_pin_;
InternalGPIOPin *ud_pin_;
float initial_value_;
float pot_value_;
};
} // namespace x9c
} // namespace esphome