mirror of
https://github.com/esphome/esphome.git
synced 2025-03-14 14:48:18 +00:00
fixed issues
This commit is contained in:
parent
04c16adcc4
commit
f9b6cea100
@ -2,8 +2,11 @@ import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import i2c
|
||||
from esphome.const import CONF_ID
|
||||
from esphome.components.mpr121.mpr121_const import CONF_RELEASE_DEBOUNCE, \
|
||||
CONF_TOUCH_DEBOUNCE, CONF_TOUCH_THRESHOLD, CONF_RELEASE_THRESHOLD
|
||||
|
||||
CONF_TOUCH_THRESHOLD = "touch_threshold"
|
||||
CONF_RELEASE_THRESHOLD = "release_threshold"
|
||||
CONF_TOUCH_DEBOUNCE = "touch_debounce"
|
||||
CONF_RELEASE_DEBOUNCE = "release_debounce"
|
||||
|
||||
DEPENDENCIES = ['i2c']
|
||||
AUTO_LOAD = ['binary_sensor']
|
||||
@ -16,11 +19,9 @@ MULTI_CONF = True
|
||||
CONFIG_SCHEMA = cv.Schema({
|
||||
cv.GenerateID(): cv.declare_id(MPR121Component),
|
||||
cv.Optional(CONF_RELEASE_DEBOUNCE, default=0): cv.int_range(min=0, max=7),
|
||||
cv.Optional(CONF_TOUCH_DEBOUNCE, default=0): cv.All(cv.Coerce(int), cv.Range(min=0, max=7)),
|
||||
cv.Optional(CONF_TOUCH_THRESHOLD, default=0x06): cv.All(cv.Coerce(int),
|
||||
cv.Range(min=0x05, max=0x30)),
|
||||
cv.Optional(CONF_RELEASE_THRESHOLD, default=0x0b): cv.All(cv.Coerce(int),
|
||||
cv.Range(min=0x05, max=0x30)),
|
||||
cv.Optional(CONF_TOUCH_DEBOUNCE, default=0): cv.int_range(min=0, max=7),
|
||||
cv.Optional(CONF_TOUCH_THRESHOLD, default=0x06): cv.int_range(min=0x05, max=0x30),
|
||||
cv.Optional(CONF_RELEASE_THRESHOLD, default=0x0b): cv.int_range(min=0x05, max=0x30),
|
||||
}).extend(cv.COMPONENT_SCHEMA).extend(i2c.i2c_device_schema(0x5A))
|
||||
|
||||
|
||||
|
@ -2,9 +2,8 @@ import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
from esphome.const import CONF_CHANNEL, CONF_ID
|
||||
from esphome.components.mpr121.mpr121_const import CONF_TOUCH_THRESHOLD, \
|
||||
from . import mpr121_ns, MPR121Component, CONF_MPR121_ID, CONF_TOUCH_THRESHOLD, \
|
||||
CONF_RELEASE_THRESHOLD
|
||||
from . import mpr121_ns, MPR121Component, CONF_MPR121_ID
|
||||
|
||||
DEPENDENCIES = ['mpr121']
|
||||
MPR121Channel = mpr121_ns.class_('MPR121Channel', binary_sensor.BinarySensor)
|
||||
|
@ -49,14 +49,12 @@ void MPR121Component::set_touch_debounce(uint8_t debounce) {
|
||||
uint8_t mask = debounce << 4;
|
||||
this->debounce_ &= 0x0f;
|
||||
this->debounce_ |= mask;
|
||||
ESP_LOGD(TAG, "debounce:%02x", this->debounce_);
|
||||
}
|
||||
|
||||
void MPR121Component::set_release_debounce(uint8_t debounce) {
|
||||
uint8_t mask = debounce & 0x0f;
|
||||
this->debounce_ &= 0xf0;
|
||||
this->debounce_ |= mask;
|
||||
ESP_LOGD(TAG, "debounce:%02x", this->debounce_);
|
||||
};
|
||||
|
||||
void MPR121Component::dump_config() {
|
||||
|
@ -7,9 +7,6 @@
|
||||
namespace esphome {
|
||||
namespace mpr121 {
|
||||
|
||||
#define DEFAULT_TOUCH_THRESHOLD 12
|
||||
#define DEFAULT_RELEASE_THRESHOLD 6
|
||||
|
||||
enum {
|
||||
MPR121_TOUCHSTATUS_L = 0x00,
|
||||
MPR121_TOUCHSTATUS_H = 0x01,
|
||||
@ -81,8 +78,8 @@ class MPR121Component : public Component, public i2c::I2CDevice {
|
||||
protected:
|
||||
std::vector<MPR121Channel *> channels_{};
|
||||
uint8_t debounce_{0};
|
||||
uint8_t touch_threshold_{DEFAULT_TOUCH_THRESHOLD};
|
||||
uint8_t release_threshold_{DEFAULT_RELEASE_THRESHOLD};
|
||||
uint8_t touch_threshold_{12};
|
||||
uint8_t release_threshold_{6};
|
||||
enum ErrorCode {
|
||||
NONE = 0,
|
||||
COMMUNICATION_FAILED,
|
||||
|
@ -1,4 +0,0 @@
|
||||
CONF_TOUCH_THRESHOLD = "touch_threshold"
|
||||
CONF_RELEASE_THRESHOLD = "release_threshold"
|
||||
CONF_TOUCH_DEBOUNCE = "touch_debounce"
|
||||
CONF_RELEASE_DEBOUNCE = "release_debounce"
|
Loading…
x
Reference in New Issue
Block a user