mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 17:05:21 +01:00
Fix Rotary Encoder (#580)
Fixes https://github.com/esphome/issues/issues/360
This commit is contained in:
parent
01db114724
commit
3012fee013
2 changed files with 5 additions and 5 deletions
|
@ -101,15 +101,15 @@ void RotaryEncoderSensor::setup() {
|
|||
ESP_LOGCONFIG(TAG, "Setting up Rotary Encoder '%s'...", this->name_.c_str());
|
||||
this->pin_a_->setup();
|
||||
this->store_.pin_a = this->pin_a_->to_isr();
|
||||
this->pin_a_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
||||
|
||||
this->pin_b_->setup();
|
||||
this->store_.pin_b = this->pin_b_->to_isr();
|
||||
this->pin_b_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
||||
|
||||
if (this->pin_i_ != nullptr) {
|
||||
this->pin_i_->setup();
|
||||
}
|
||||
|
||||
this->pin_a_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
||||
this->pin_b_->attach_interrupt(RotaryEncoderSensorStore::gpio_intr, &this->store_, CHANGE);
|
||||
}
|
||||
void RotaryEncoderSensor::dump_config() {
|
||||
LOG_SENSOR("", "Rotary Encoder", this);
|
||||
|
|
|
@ -36,7 +36,7 @@ CONFIG_SCHEMA = cv.All(sensor.sensor_schema(UNIT_STEPS, ICON_ROTATE_RIGHT, 0).ex
|
|||
pins.validate_has_interrupt),
|
||||
cv.Required(CONF_PIN_B): cv.All(pins.internal_gpio_input_pin_schema,
|
||||
pins.validate_has_interrupt),
|
||||
cv.Optional(CONF_PIN_RESET): pins.internal_gpio_input_pin_schema,
|
||||
cv.Optional(CONF_PIN_RESET): pins.internal_gpio_output_pin_schema,
|
||||
cv.Optional(CONF_RESOLUTION, default=1): cv.enum(RESOLUTIONS, int=True),
|
||||
cv.Optional(CONF_MIN_VALUE): cv.int_,
|
||||
cv.Optional(CONF_MAX_VALUE): cv.int_,
|
||||
|
@ -50,7 +50,7 @@ def to_code(config):
|
|||
pin_a = yield cg.gpio_pin_expression(config[CONF_PIN_A])
|
||||
cg.add(var.set_pin_a(pin_a))
|
||||
pin_b = yield cg.gpio_pin_expression(config[CONF_PIN_B])
|
||||
cg.add(var.set_pin_a(pin_b))
|
||||
cg.add(var.set_pin_b(pin_b))
|
||||
|
||||
if CONF_PIN_RESET in config:
|
||||
pin_i = yield cg.gpio_pin_expression(config[CONF_PIN_RESET])
|
||||
|
|
Loading…
Reference in a new issue