From f31e0532c4e502de7913f086452a3ac4eebb3473 Mon Sep 17 00:00:00 2001 From: Oxan van Leeuwen Date: Mon, 13 Sep 2021 09:33:29 +0200 Subject: [PATCH] Untangle core headers (part 1) (#2276) --- esphome/components/ade7953/ade7953.h | 1 + esphome/components/am43/am43_base.cpp | 2 ++ esphome/components/anova/anova_base.cpp | 2 ++ esphome/components/as3935/as3935.h | 1 + esphome/components/climate/climate_traits.cpp | 2 +- esphome/components/deep_sleep/deep_sleep_component.h | 1 + esphome/components/dht/dht.h | 1 + esphome/components/esp32_ble/ble_uuid.h | 1 + .../gpio/binary_sensor/gpio_binary_sensor.h | 1 + esphome/components/gpio/switch/gpio_switch.h | 1 + esphome/components/nfc/nfc.cpp | 1 + esphome/components/rc522/rc522.h | 1 + .../remote_receiver/remote_receiver_esp8266.cpp | 1 + esphome/components/sx1509/sx1509.h | 1 + esphome/components/ttp229_bsf/ttp229_bsf.h | 1 + esphome/components/tx20/tx20.h | 1 + esphome/components/vl53l0x/vl53l0x_sensor.h | 1 + esphome/core/esphal.h | 4 +--- esphome/core/helpers.h | 5 ++++- esphome/core/log.h | 12 +++++++----- esphome/core/preferences.h | 2 +- 21 files changed, 32 insertions(+), 11 deletions(-) diff --git a/esphome/components/ade7953/ade7953.h b/esphome/components/ade7953/ade7953.h index e0fadf37c3..5a582a991a 100644 --- a/esphome/components/ade7953/ade7953.h +++ b/esphome/components/ade7953/ade7953.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/i2c/i2c.h" #include "esphome/components/sensor/sensor.h" diff --git a/esphome/components/am43/am43_base.cpp b/esphome/components/am43/am43_base.cpp index a17df55571..af474dcb79 100644 --- a/esphome/components/am43/am43_base.cpp +++ b/esphome/components/am43/am43_base.cpp @@ -1,4 +1,6 @@ #include "am43_base.h" +#include +#include namespace esphome { namespace am43 { diff --git a/esphome/components/anova/anova_base.cpp b/esphome/components/anova/anova_base.cpp index ad581b1e6c..811a34a27a 100644 --- a/esphome/components/anova/anova_base.cpp +++ b/esphome/components/anova/anova_base.cpp @@ -1,4 +1,6 @@ #include "anova_base.h" +#include +#include namespace esphome { namespace anova { diff --git a/esphome/components/as3935/as3935.h b/esphome/components/as3935/as3935.h index d0e53e7832..76c7697d38 100644 --- a/esphome/components/as3935/as3935.h +++ b/esphome/components/as3935/as3935.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/sensor/sensor.h" #include "esphome/components/binary_sensor/binary_sensor.h" diff --git a/esphome/components/climate/climate_traits.cpp b/esphome/components/climate/climate_traits.cpp index c871552360..16c9cd05be 100644 --- a/esphome/components/climate/climate_traits.cpp +++ b/esphome/components/climate/climate_traits.cpp @@ -1,5 +1,5 @@ #include "climate_traits.h" -#include "esphome/core/log.h" +#include namespace esphome { namespace climate { diff --git a/esphome/components/deep_sleep/deep_sleep_component.h b/esphome/components/deep_sleep/deep_sleep_component.h index e163cf7709..5050bd6b4d 100644 --- a/esphome/components/deep_sleep/deep_sleep_component.h +++ b/esphome/components/deep_sleep/deep_sleep_component.h @@ -3,6 +3,7 @@ #include "esphome/core/component.h" #include "esphome/core/helpers.h" #include "esphome/core/automation.h" +#include "esphome/core/esphal.h" namespace esphome { namespace deep_sleep { diff --git a/esphome/components/dht/dht.h b/esphome/components/dht/dht.h index 8826a3d2b7..9b848cb119 100644 --- a/esphome/components/dht/dht.h +++ b/esphome/components/dht/dht.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/sensor/sensor.h" namespace esphome { diff --git a/esphome/components/esp32_ble/ble_uuid.h b/esphome/components/esp32_ble/ble_uuid.h index 0e3c9b0d0a..89082e19fa 100644 --- a/esphome/components/esp32_ble/ble_uuid.h +++ b/esphome/components/esp32_ble/ble_uuid.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/helpers.h" +#include "esphome/core/esphal.h" #ifdef ARDUINO_ARCH_ESP32 diff --git a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h index cfe49b3c94..f655207243 100644 --- a/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h +++ b/esphome/components/gpio/binary_sensor/gpio_binary_sensor.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/binary_sensor/binary_sensor.h" namespace esphome { diff --git a/esphome/components/gpio/switch/gpio_switch.h b/esphome/components/gpio/switch/gpio_switch.h index c0036b20e9..b39e070c85 100644 --- a/esphome/components/gpio/switch/gpio_switch.h +++ b/esphome/components/gpio/switch/gpio_switch.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/switch/switch.h" namespace esphome { diff --git a/esphome/components/nfc/nfc.cpp b/esphome/components/nfc/nfc.cpp index 01f63e6ec9..706c09a5aa 100644 --- a/esphome/components/nfc/nfc.cpp +++ b/esphome/components/nfc/nfc.cpp @@ -1,4 +1,5 @@ #include "nfc.h" +#include #include "esphome/core/log.h" namespace esphome { diff --git a/esphome/components/rc522/rc522.h b/esphome/components/rc522/rc522.h index 6880651ac4..e4e3387ff6 100644 --- a/esphome/components/rc522/rc522.h +++ b/esphome/components/rc522/rc522.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/core/automation.h" #include "esphome/components/binary_sensor/binary_sensor.h" diff --git a/esphome/components/remote_receiver/remote_receiver_esp8266.cpp b/esphome/components/remote_receiver/remote_receiver_esp8266.cpp index 3fb68caca2..d509eea925 100644 --- a/esphome/components/remote_receiver/remote_receiver_esp8266.cpp +++ b/esphome/components/remote_receiver/remote_receiver_esp8266.cpp @@ -1,4 +1,5 @@ #include "remote_receiver.h" +#include "esphome/core/esphal.h" #include "esphome/core/log.h" #include "esphome/core/helpers.h" diff --git a/esphome/components/sx1509/sx1509.h b/esphome/components/sx1509/sx1509.h index 55d5e54091..1390059675 100644 --- a/esphome/components/sx1509/sx1509.h +++ b/esphome/components/sx1509/sx1509.h @@ -2,6 +2,7 @@ #include "esphome/components/i2c/i2c.h" #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "sx1509_gpio_pin.h" #include "sx1509_registers.h" diff --git a/esphome/components/ttp229_bsf/ttp229_bsf.h b/esphome/components/ttp229_bsf/ttp229_bsf.h index 94dd014d8e..d73e4fb185 100644 --- a/esphome/components/ttp229_bsf/ttp229_bsf.h +++ b/esphome/components/ttp229_bsf/ttp229_bsf.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/binary_sensor/binary_sensor.h" namespace esphome { diff --git a/esphome/components/tx20/tx20.h b/esphome/components/tx20/tx20.h index 8b79deffbc..56cb723fa1 100644 --- a/esphome/components/tx20/tx20.h +++ b/esphome/components/tx20/tx20.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/sensor/sensor.h" namespace esphome { diff --git a/esphome/components/vl53l0x/vl53l0x_sensor.h b/esphome/components/vl53l0x/vl53l0x_sensor.h index 0c37df67a2..83a6322dcd 100644 --- a/esphome/components/vl53l0x/vl53l0x_sensor.h +++ b/esphome/components/vl53l0x/vl53l0x_sensor.h @@ -3,6 +3,7 @@ #include #include "esphome/core/component.h" +#include "esphome/core/esphal.h" #include "esphome/components/sensor/sensor.h" #include "esphome/components/i2c/i2c.h" diff --git a/esphome/core/esphal.h b/esphome/core/esphal.h index 809c7d91b5..08fbfb09f5 100644 --- a/esphome/core/esphal.h +++ b/esphome/core/esphal.h @@ -1,9 +1,7 @@ #pragma once #include "Arduino.h" -#ifdef ARDUINO_ARCH_ESP32 -#include -#endif + // Fix some arduino defs #ifdef round #undef round diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index 60bc7a9ad3..a63c627e5a 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -6,8 +6,11 @@ #include #include +#ifdef ARDUINO_ARCH_ESP32 +#include "esp32-hal-psram.h" +#endif + #include "esphome/core/optional.h" -#include "esphome/core/esphal.h" #ifdef CLANG_TIDY #undef ICACHE_RAM_ATTR diff --git a/esphome/core/log.h b/esphome/core/log.h index fbaaf14408..0b0911c3ac 100644 --- a/esphome/core/log.h +++ b/esphome/core/log.h @@ -3,18 +3,20 @@ #include #include #include + #ifdef USE_STORE_LOG_STR_IN_FLASH #include "WString.h" #endif -#include "esphome/core/macros.h" -// avoid esp-idf redefining our macros -#include "esphome/core/esphal.h" - +// Both the ESP-IDF and Arduino also define ESP_LOG* macros. Include them here, so that they won't +// be reincluded later on and redefine our macros. #ifdef ARDUINO_ARCH_ESP32 -#include "esp_err.h" +#include +#include #endif +#include "esphome/core/macros.h" + namespace esphome { #define ESPHOME_LOG_LEVEL_NONE 0 diff --git a/esphome/core/preferences.h b/esphome/core/preferences.h index 43d0f023e3..699871ca00 100644 --- a/esphome/core/preferences.h +++ b/esphome/core/preferences.h @@ -1,8 +1,8 @@ #pragma once #include +#include -#include "esphome/core/esphal.h" #include "esphome/core/defines.h" namespace esphome {