From 9de61fcf587514f203f8215ffaa186b280975da8 Mon Sep 17 00:00:00 2001 From: Ian Reinhart Geiser Date: Thu, 31 Mar 2022 23:46:39 -0400 Subject: [PATCH] Define touchscreen support when in use. (#3296) --- esphome/components/touchscreen/__init__.py | 7 +++++++ esphome/core/defines.h | 1 + 2 files changed, 8 insertions(+) diff --git a/esphome/components/touchscreen/__init__.py b/esphome/components/touchscreen/__init__.py index 125103e2b8..a4bdc8cafd 100644 --- a/esphome/components/touchscreen/__init__.py +++ b/esphome/components/touchscreen/__init__.py @@ -4,6 +4,7 @@ import esphome.codegen as cg from esphome.components import display from esphome import automation from esphome.const import CONF_ON_TOUCH +from esphome.core import coroutine_with_priority CODEOWNERS = ["@jesserockz"] DEPENDENCIES = ["display"] @@ -39,3 +40,9 @@ async def register_touchscreen(var, config): [(TouchPoint, "touch")], config[CONF_ON_TOUCH], ) + + +@coroutine_with_priority(100.0) +async def to_code(config): + cg.add_global(touchscreen_ns.using) + cg.add_define("USE_TOUCHSCREEN") diff --git a/esphome/core/defines.h b/esphome/core/defines.h index aabb5510f4..b5c82338b3 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -40,6 +40,7 @@ #define USE_SWITCH #define USE_TEXT_SENSOR #define USE_TIME +#define USE_TOUCHSCREEN #define USE_UART_DEBUGGER #define USE_WIFI