Basic touch event handling
This commit is contained in:
@@ -14,13 +14,12 @@ CONF_TX_ULTIMATE_EASY = "tx_ultimate_easy"
|
||||
|
||||
CONF_UART = "uart"
|
||||
|
||||
CONF_ON_TOUCH_EVENT = "on_touch_event"
|
||||
CONF_ON_PRESS = "on_press"
|
||||
CONF_ON_RELEASE = "on_release"
|
||||
|
||||
CONF_ON_SWIPE_LEFT = "on_swipe_left"
|
||||
CONF_ON_SWIPE_RIGHT = "on_swipe_right"
|
||||
|
||||
CONF_ON_FULL_TOUCH_RELEASE = "on_full_touch_release"
|
||||
CONF_ON_MULTI_TOUCH_RELEASE = "on_multi_touch_release"
|
||||
CONF_ON_LONG_TOUCH_RELEASE = "on_long_touch_release"
|
||||
|
||||
tx_ultimate_easy_ns = cg.esphome_ns.namespace('tx_ultimate_easy')
|
||||
@@ -35,11 +34,12 @@ CONFIG_SCHEMA = cv.Schema({
|
||||
|
||||
cv.Required(CONF_UART): cv.use_id(uart),
|
||||
|
||||
cv.Optional(CONF_ON_TOUCH_EVENT): automation.validate_automation(single=True),
|
||||
cv.Optional(CONF_ON_PRESS): automation.validate_automation(single=True),
|
||||
cv.Optional(CONF_ON_RELEASE): automation.validate_automation(single=True),
|
||||
cv.Optional(CONF_ON_SWIPE_LEFT): automation.validate_automation(single=True),
|
||||
cv.Optional(CONF_ON_SWIPE_RIGHT): automation.validate_automation(single=True),
|
||||
cv.Optional(CONF_ON_FULL_TOUCH_RELEASE): automation.validate_automation(single=True),
|
||||
cv.Optional(CONF_ON_MULTI_TOUCH_RELEASE): automation.validate_automation(single=True),
|
||||
cv.Optional(CONF_ON_LONG_TOUCH_RELEASE): automation.validate_automation(single=True),
|
||||
|
||||
}).extend(cv.COMPONENT_SCHEMA).extend(uart.UART_DEVICE_SCHEMA)
|
||||
@@ -49,44 +49,51 @@ async def register_tx_ultimate_easy(var, config):
|
||||
uart_component = await cg.get_variable(config[CONF_UART])
|
||||
cg.add(var.set_uart_component(uart_component))
|
||||
|
||||
if CONF_ON_TOUCH_EVENT in config:
|
||||
await automation.build_automation(
|
||||
var.get_trigger_touch_event(),
|
||||
[(TouchPoint, "touch")],
|
||||
config[CONF_ON_TOUCH_EVENT],
|
||||
)
|
||||
|
||||
if CONF_ON_PRESS in config:
|
||||
await automation.build_automation(
|
||||
var.get_touch_trigger(),
|
||||
var.get_trigger_touch(),
|
||||
[(TouchPoint, "touch")],
|
||||
config[CONF_ON_PRESS],
|
||||
)
|
||||
|
||||
if CONF_ON_RELEASE in config:
|
||||
await automation.build_automation(
|
||||
var.get_release_trigger(),
|
||||
var.get_trigger_release(),
|
||||
[(TouchPoint, "touch")],
|
||||
config[CONF_ON_RELEASE],
|
||||
)
|
||||
|
||||
if CONF_ON_SWIPE_LEFT in config:
|
||||
await automation.build_automation(
|
||||
var.get_swipe_left_trigger(),
|
||||
var.get_trigger_swipe_left(),
|
||||
[(TouchPoint, "touch")],
|
||||
config[CONF_ON_SWIPE_LEFT],
|
||||
)
|
||||
|
||||
if CONF_ON_SWIPE_RIGHT in config:
|
||||
await automation.build_automation(
|
||||
var.get_swipe_right_trigger(),
|
||||
var.get_trigger_swipe_right(),
|
||||
[(TouchPoint, "touch")],
|
||||
config[CONF_ON_SWIPE_RIGHT],
|
||||
)
|
||||
|
||||
if CONF_ON_FULL_TOUCH_RELEASE in config:
|
||||
if CONF_ON_MULTI_TOUCH_RELEASE in config:
|
||||
await automation.build_automation(
|
||||
var.get_full_touch_release_trigger(),
|
||||
var.get_trigger_multi_touch_release(),
|
||||
[(TouchPoint, "touch")],
|
||||
config[CONF_ON_FULL_TOUCH_RELEASE],
|
||||
config[CONF_ON_MULTI_TOUCH_RELEASE],
|
||||
)
|
||||
|
||||
if CONF_ON_LONG_TOUCH_RELEASE in config:
|
||||
await automation.build_automation(
|
||||
var.get_long_touch_release_trigger(),
|
||||
var.get_trigger_long_touch_release(),
|
||||
[(TouchPoint, "touch")],
|
||||
config[CONF_ON_LONG_TOUCH_RELEASE],
|
||||
)
|
||||
@@ -95,5 +102,4 @@ async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
await uart.register_uart_device(var, config)
|
||||
|
||||
await register_tx_ultimate_easy(var, config)
|
||||
|
||||
Reference in New Issue
Block a user