From 5342edf04af2476ba88eceadbe1a2e08682ab2f3 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sat, 25 Sep 2021 10:05:32 +0200 Subject: [PATCH] Misc fixes for esp-idf (#2386) --- esphome/components/logger/logger.cpp | 13 ++++++------- esphome/core/config.py | 5 +++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/esphome/components/logger/logger.cpp b/esphome/components/logger/logger.cpp index 045f7059a9..4352b7e208 100644 --- a/esphome/components/logger/logger.cpp +++ b/esphome/components/logger/logger.cpp @@ -176,13 +176,12 @@ void Logger::pre_setup() { uart_num_ = UART_NUM_2; break; } - uart_config_t uart_config = { - .baud_rate = (int) baud_rate_, - .data_bits = UART_DATA_8_BITS, - .parity = UART_PARITY_DISABLE, - .stop_bits = UART_STOP_BITS_1, - .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - }; + uart_config_t uart_config{}; + uart_config.baud_rate = (int) baud_rate_; + uart_config.data_bits = UART_DATA_8_BITS; + uart_config.parity = UART_PARITY_DISABLE; + uart_config.stop_bits = UART_STOP_BITS_1; + uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE; uart_param_config(uart_num_, &uart_config); const int uart_buffer_size = tx_buffer_size_; // Install UART driver using an event queue here diff --git a/esphome/core/config.py b/esphome/core/config.py index 71add56b13..bbdfcf124c 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -247,6 +247,11 @@ async def _add_automations(config): @coroutine_with_priority(100.0) async def to_code(config): cg.add_global(cg.global_ns.namespace("esphome").using) + # These can be used by user lambdas, put them to default scope + cg.add_global(cg.RawExpression("using std::isnan")) + cg.add_global(cg.RawExpression("using std::min")) + cg.add_global(cg.RawExpression("using std::max")) + cg.add( cg.App.pre_setup( config[CONF_NAME],