mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
Generate ARDUINO_VERSION_CODE in Python code (#3101)
Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
parent
f2d677d51a
commit
cdda648360
15 changed files with 71 additions and 98 deletions
|
@ -293,6 +293,8 @@ async def to_code(config):
|
||||||
|
|
||||||
cg.add_platformio_option("lib_ldf_mode", "off")
|
cg.add_platformio_option("lib_ldf_mode", "off")
|
||||||
|
|
||||||
|
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
|
||||||
|
|
||||||
conf = config[CONF_FRAMEWORK]
|
conf = config[CONF_FRAMEWORK]
|
||||||
cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION])
|
cg.add_platformio_option("platform", conf[CONF_PLATFORM_VERSION])
|
||||||
|
|
||||||
|
@ -335,6 +337,13 @@ async def to_code(config):
|
||||||
"CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE", False
|
"CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE", False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cg.add_define(
|
||||||
|
"USE_ESP_IDF_VERSION_CODE",
|
||||||
|
cg.RawExpression(
|
||||||
|
f"VERSION_CODE({framework_ver.major}, {framework_ver.minor}, {framework_ver.patch})"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
elif conf[CONF_TYPE] == FRAMEWORK_ARDUINO:
|
elif conf[CONF_TYPE] == FRAMEWORK_ARDUINO:
|
||||||
cg.add_platformio_option("framework", "arduino")
|
cg.add_platformio_option("framework", "arduino")
|
||||||
cg.add_build_flag("-DUSE_ARDUINO")
|
cg.add_build_flag("-DUSE_ARDUINO")
|
||||||
|
@ -346,6 +355,13 @@ async def to_code(config):
|
||||||
|
|
||||||
cg.add_platformio_option("board_build.partitions", "partitions.csv")
|
cg.add_platformio_option("board_build.partitions", "partitions.csv")
|
||||||
|
|
||||||
|
cg.add_define(
|
||||||
|
"USE_ARDUINO_VERSION_CODE",
|
||||||
|
cg.RawExpression(
|
||||||
|
f"VERSION_CODE({framework_ver.major}, {framework_ver.minor}, {framework_ver.patch})"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
ARDUINO_PARTITIONS_CSV = """\
|
ARDUINO_PARTITIONS_CSV = """\
|
||||||
nvs, data, nvs, 0x009000, 0x005000,
|
nvs, data, nvs, 0x009000, 0x005000,
|
||||||
|
|
|
@ -198,10 +198,15 @@ async def to_code(config):
|
||||||
|
|
||||||
cg.add_platformio_option("board_build.flash_mode", config[CONF_BOARD_FLASH_MODE])
|
cg.add_platformio_option("board_build.flash_mode", config[CONF_BOARD_FLASH_MODE])
|
||||||
|
|
||||||
|
ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
|
||||||
|
cg.add_define(
|
||||||
|
"USE_ARDUINO_VERSION_CODE",
|
||||||
|
cg.RawExpression(f"VERSION_CODE({ver.major}, {ver.minor}, {ver.patch})"),
|
||||||
|
)
|
||||||
|
|
||||||
if config[CONF_BOARD] in ESP8266_FLASH_SIZES:
|
if config[CONF_BOARD] in ESP8266_FLASH_SIZES:
|
||||||
flash_size = ESP8266_FLASH_SIZES[config[CONF_BOARD]]
|
flash_size = ESP8266_FLASH_SIZES[config[CONF_BOARD]]
|
||||||
ld_scripts = ESP8266_LD_SCRIPTS[flash_size]
|
ld_scripts = ESP8266_LD_SCRIPTS[flash_size]
|
||||||
ver = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
|
|
||||||
|
|
||||||
if ver <= cv.Version(2, 3, 0):
|
if ver <= cv.Version(2, 3, 0):
|
||||||
# No ld script support
|
# No ld script support
|
||||||
|
|
|
@ -2,13 +2,10 @@
|
||||||
|
|
||||||
#include "esp8266_pwm.h"
|
#include "esp8266_pwm.h"
|
||||||
#include "esphome/core/macros.h"
|
#include "esphome/core/macros.h"
|
||||||
|
#include "esphome/core/defines.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
|
|
||||||
#if defined(USE_ESP8266) && ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0)
|
|
||||||
#error ESP8266 PWM requires at least arduino_version 2.4.0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <core_esp8266_waveform.h>
|
#include <core_esp8266_waveform.h>
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
@ -23,7 +23,8 @@ ESP8266PWM = esp8266_pwm_ns.class_("ESP8266PWM", output.FloatOutput, cg.Componen
|
||||||
SetFrequencyAction = esp8266_pwm_ns.class_("SetFrequencyAction", automation.Action)
|
SetFrequencyAction = esp8266_pwm_ns.class_("SetFrequencyAction", automation.Action)
|
||||||
validate_frequency = cv.All(cv.frequency, cv.Range(min=1.0e-6))
|
validate_frequency = cv.All(cv.frequency, cv.Range(min=1.0e-6))
|
||||||
|
|
||||||
CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend(
|
CONFIG_SCHEMA = cv.All(
|
||||||
|
output.FLOAT_OUTPUT_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
cv.Required(CONF_ID): cv.declare_id(ESP8266PWM),
|
cv.Required(CONF_ID): cv.declare_id(ESP8266PWM),
|
||||||
cv.Required(CONF_PIN): cv.All(
|
cv.Required(CONF_PIN): cv.All(
|
||||||
|
@ -31,7 +32,11 @@ CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend(
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_FREQUENCY, default="1kHz"): validate_frequency,
|
cv.Optional(CONF_FREQUENCY, default="1kHz"): validate_frequency,
|
||||||
}
|
}
|
||||||
).extend(cv.COMPONENT_SCHEMA)
|
).extend(cv.COMPONENT_SCHEMA),
|
||||||
|
cv.require_framework_version(
|
||||||
|
esp8266_arduino=cv.Version(2, 4, 0),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
|
|
||||||
#include "http_request.h"
|
#include "http_request.h"
|
||||||
#include "esphome/core/macros.h"
|
#include "esphome/core/defines.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/components/network/util.h"
|
#include "esphome/components/network/util.h"
|
||||||
|
|
||||||
|
@ -42,12 +42,12 @@ void HttpRequestComponent::send(const std::vector<HttpRequestResponseTrigger *>
|
||||||
begin_status = this->client_.begin(url);
|
begin_status = this->client_.begin(url);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||||
this->client_.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
this->client_.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
#elif USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||||
this->client_.setFollowRedirects(true);
|
this->client_.setFollowRedirects(true);
|
||||||
#endif
|
#endif
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||||
this->client_.setRedirectLimit(3);
|
this->client_.setRedirectLimit(3);
|
||||||
#endif
|
#endif
|
||||||
begin_status = this->client_.begin(*this->get_wifi_client_(), url);
|
begin_status = this->client_.begin(*this->get_wifi_client_(), url);
|
||||||
|
|
|
@ -169,6 +169,10 @@ def _validate_method(value):
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.All(
|
CONFIG_SCHEMA = cv.All(
|
||||||
cv.only_with_arduino,
|
cv.only_with_arduino,
|
||||||
|
cv.require_framework_version(
|
||||||
|
esp8266_arduino=cv.Version(2, 4, 0),
|
||||||
|
esp32_arduino=cv.Version(0, 0, 0),
|
||||||
|
),
|
||||||
light.ADDRESSABLE_LIGHT_SCHEMA.extend(
|
light.ADDRESSABLE_LIGHT_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(NeoPixelBusLightOutputBase),
|
cv.GenerateID(CONF_OUTPUT_ID): cv.declare_id(NeoPixelBusLightOutputBase),
|
||||||
|
|
|
@ -9,10 +9,6 @@
|
||||||
#include "esphome/components/light/light_output.h"
|
#include "esphome/components/light/light_output.h"
|
||||||
#include "esphome/components/light/addressable_light.h"
|
#include "esphome/components/light/addressable_light.h"
|
||||||
|
|
||||||
#if defined(USE_ESP8266) && ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0)
|
|
||||||
#error The NeoPixelBus library requires at least arduino_version 2.4.x
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "NeoPixelBus.h"
|
#include "NeoPixelBus.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#ifdef USE_NEXTION_TFT_UPLOAD
|
#ifdef USE_NEXTION_TFT_UPLOAD
|
||||||
|
|
||||||
#include "esphome/core/application.h"
|
#include "esphome/core/application.h"
|
||||||
#include "esphome/core/macros.h"
|
#include "esphome/core/defines.h"
|
||||||
#include "esphome/core/util.h"
|
#include "esphome/core/util.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "esphome/components/network/util.h"
|
#include "esphome/components/network/util.h"
|
||||||
|
@ -32,12 +32,12 @@ int Nextion::upload_by_chunks_(HTTPClient *http, int range_start) {
|
||||||
range_end = this->tft_size_;
|
range_end = this->tft_size_;
|
||||||
|
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||||
http->setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
http->setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
#elif USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||||
http->setFollowRedirects(true);
|
http->setFollowRedirects(true);
|
||||||
#endif
|
#endif
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||||
http->setRedirectLimit(3);
|
http->setRedirectLimit(3);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -148,12 +148,12 @@ void Nextion::upload_tft() {
|
||||||
begin_status = http.begin(this->tft_url_.c_str());
|
begin_status = http.begin(this->tft_url_.c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 7, 0)
|
||||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||||
#elif ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
#elif USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||||
http.setFollowRedirects(true);
|
http.setFollowRedirects(true);
|
||||||
#endif
|
#endif
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 6, 0)
|
||||||
http.setRedirectLimit(3);
|
http.setRedirectLimit(3);
|
||||||
#endif
|
#endif
|
||||||
begin_status = http.begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
begin_status = http.begin(*this->get_wifi_client_(), this->tft_url_.c_str());
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esphome/core/macros.h"
|
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "esphome/core/defines.h"
|
#include "esphome/core/defines.h"
|
||||||
#include "esphome/core/automation.h"
|
#include "esphome/core/automation.h"
|
||||||
|
@ -18,7 +17,7 @@
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESP8266WiFiType.h>
|
#include <ESP8266WiFiType.h>
|
||||||
|
|
||||||
#if defined(USE_ESP8266) && ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0)
|
#if defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE < VERSION_CODE(2, 4, 0)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <user_interface.h>
|
#include <user_interface.h>
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "wifi_component.h"
|
#include "wifi_component.h"
|
||||||
#include "esphome/core/macros.h"
|
#include "esphome/core/defines.h"
|
||||||
|
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ extern "C" {
|
||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
#include "lwip/netif.h" // struct netif
|
#include "lwip/netif.h" // struct netif
|
||||||
#endif
|
#endif
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0)
|
||||||
#include "LwipDhcpServer.h"
|
#include "LwipDhcpServer.h"
|
||||||
#define wifi_softap_set_dhcps_lease(lease) dhcpSoftAP.set_dhcps_lease(lease)
|
#define wifi_softap_set_dhcps_lease(lease) dhcpSoftAP.set_dhcps_lease(lease)
|
||||||
#define wifi_softap_set_dhcps_lease_time(time) dhcpSoftAP.set_dhcps_lease_time(time)
|
#define wifi_softap_set_dhcps_lease_time(time) dhcpSoftAP.set_dhcps_lease_time(time)
|
||||||
|
@ -238,7 +238,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
||||||
conf.bssid_set = 0;
|
conf.bssid_set = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
|
||||||
if (ap.get_password().empty()) {
|
if (ap.get_password().empty()) {
|
||||||
conf.threshold.authmode = AUTH_OPEN;
|
conf.threshold.authmode = AUTH_OPEN;
|
||||||
} else {
|
} else {
|
||||||
|
@ -528,7 +528,7 @@ void WiFiComponent::wifi_event_callback(System_Event_t *event) {
|
||||||
ESP_LOGVV(TAG, "Event: AP receive Probe Request MAC=%s RSSI=%d", format_mac_addr(it.mac).c_str(), it.rssi);
|
ESP_LOGVV(TAG, "Event: AP receive Probe Request MAC=%s RSSI=%d", format_mac_addr(it.mac).c_str(), it.rssi);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
|
||||||
case EVENT_OPMODE_CHANGED: {
|
case EVENT_OPMODE_CHANGED: {
|
||||||
auto it = event->event_info.opmode_changed;
|
auto it = event->event_info.opmode_changed;
|
||||||
ESP_LOGV(TAG, "Event: Changed Mode old=%s new=%s", LOG_STR_ARG(get_op_mode_str(it.old_opmode)),
|
ESP_LOGV(TAG, "Event: Changed Mode old=%s new=%s", LOG_STR_ARG(get_op_mode_str(it.old_opmode)),
|
||||||
|
@ -614,7 +614,7 @@ bool WiFiComponent::wifi_scan_start_() {
|
||||||
config.bssid = nullptr;
|
config.bssid = nullptr;
|
||||||
config.channel = 0;
|
config.channel = 0;
|
||||||
config.show_hidden = 1;
|
config.show_hidden = 1;
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 4, 0)
|
||||||
config.scan_type = WIFI_SCAN_TYPE_ACTIVE;
|
config.scan_type = WIFI_SCAN_TYPE_ACTIVE;
|
||||||
if (first_scan) {
|
if (first_scan) {
|
||||||
config.scan_time.active.min = 100;
|
config.scan_time.active.min = 100;
|
||||||
|
@ -693,7 +693,7 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0)
|
||||||
dhcpSoftAP.begin(&info);
|
dhcpSoftAP.begin(&info);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
//
|
//
|
||||||
// This file is only used by static analyzers and IDEs.
|
// This file is only used by static analyzers and IDEs.
|
||||||
|
|
||||||
|
#include "esphome/core/macros.h"
|
||||||
|
|
||||||
// Informative flags
|
// Informative flags
|
||||||
#define ESPHOME_BOARD "dummy_board"
|
#define ESPHOME_BOARD "dummy_board"
|
||||||
#define ESPHOME_PROJECT_NAME "dummy project"
|
#define ESPHOME_PROJECT_NAME "dummy project"
|
||||||
|
@ -60,13 +62,19 @@
|
||||||
#define USE_SOCKET_IMPL_BSD_SOCKETS
|
#define USE_SOCKET_IMPL_BSD_SOCKETS
|
||||||
|
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
|
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(1, 0, 6)
|
||||||
#define USE_ETHERNET
|
#define USE_ETHERNET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_ESP_IDF
|
||||||
|
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(4, 3, 0)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ESP8266-specific feature flags
|
// ESP8266-specific feature flags
|
||||||
#ifdef USE_ESP8266
|
#ifdef USE_ESP8266
|
||||||
#define USE_ADC_SENSOR_VCC
|
#define USE_ADC_SENSOR_VCC
|
||||||
|
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(3, 0, 2)
|
||||||
#define USE_ESP8266_PREFERENCES_FLASH
|
#define USE_ESP8266_PREFERENCES_FLASH
|
||||||
#define USE_HTTP_REQUEST_ESP8266_HTTPS
|
#define USE_HTTP_REQUEST_ESP8266_HTTPS
|
||||||
#define USE_SOCKET_IMPL_LWIP_TCP
|
#define USE_SOCKET_IMPL_LWIP_TCP
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
|
|
||||||
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
#ifdef USE_STORE_LOG_STR_IN_FLASH
|
||||||
#include "WString.h"
|
#include "WString.h"
|
||||||
|
#include "esphome/core/defines.h" // for USE_ARDUINO_VERSION_CODE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "esphome/core/macros.h"
|
|
||||||
|
|
||||||
// Include ESP-IDF/Arduino based logging methods here so they don't undefine ours later
|
// Include ESP-IDF/Arduino based logging methods here so they don't undefine ours later
|
||||||
#if defined(USE_ESP32_FRAMEWORK_ARDUINO) || defined(USE_ESP_IDF)
|
#if defined(USE_ESP32_FRAMEWORK_ARDUINO) || defined(USE_ESP_IDF)
|
||||||
#include <esp_err.h>
|
#include <esp_err.h>
|
||||||
|
@ -19,8 +18,6 @@
|
||||||
#include <esp32-hal-log.h>
|
#include <esp32-hal-log.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "esphome/core/macros.h"
|
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
|
|
||||||
#define ESPHOME_LOG_LEVEL_NONE 0
|
#define ESPHOME_LOG_LEVEL_NONE 0
|
||||||
|
@ -176,7 +173,7 @@ struct LogString;
|
||||||
|
|
||||||
#include <pgmspace.h>
|
#include <pgmspace.h>
|
||||||
|
|
||||||
#if ARDUINO_VERSION_CODE >= VERSION_CODE(2, 5, 0)
|
#if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 5, 0)
|
||||||
#define LOG_STR_ARG(s) ((PGM_P)(s))
|
#define LOG_STR_ARG(s) ((PGM_P)(s))
|
||||||
#else
|
#else
|
||||||
// Pre-Arduino 2.5, we can't pass a PSTR() to printf(). Emulate support by copying the message to a
|
// Pre-Arduino 2.5, we can't pass a PSTR() to printf(). Emulate support by copying the message to a
|
||||||
|
|
|
@ -1,56 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// Helper macro to define a version code, whos evalue can be compared against other version codes.
|
||||||
#define VERSION_CODE(major, minor, patch) ((major) << 16 | (minor) << 8 | (patch))
|
#define VERSION_CODE(major, minor, patch) ((major) << 16 | (minor) << 8 | (patch))
|
||||||
|
|
||||||
#if defined(USE_ESP8266)
|
|
||||||
|
|
||||||
#include <core_version.h>
|
|
||||||
#if defined(ARDUINO_ESP8266_MAJOR) && defined(ARDUINO_ESP8266_MINOR) && defined(ARDUINO_ESP8266_REVISION) // v3.0.1+
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(ARDUINO_ESP8266_MAJOR, ARDUINO_ESP8266_MINOR, ARDUINO_ESP8266_REVISION)
|
|
||||||
#elif ARDUINO_ESP8266_GIT_VER == 0xefb0341a // version defines were screwed up in v3.0.0
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(3, 0, 0)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_7_4)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 7, 4)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_7_3)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 7, 3)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_7_2)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 7, 2)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_7_1)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 7, 1)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_7_0)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 7, 0)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_6_3)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 6, 3)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_6_2)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 6, 2)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_6_1)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 6, 1)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_5_2)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 5, 2)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_5_1)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 5, 1)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_5_0)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 5, 0)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_4_2)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 4, 2)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_4_1)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 4, 1)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_4_0)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 4, 0)
|
|
||||||
#elif defined(ARDUINO_ESP8266_RELEASE_2_3_0)
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(2, 3, 0)
|
|
||||||
#else
|
|
||||||
#warning "Could not determine Arduino framework version, update esphome/core/macros.h!"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(USE_ESP32_FRAMEWORK_ARDUINO)
|
|
||||||
|
|
||||||
#if defined(IDF_VER) // identifies v2, needed since v1 doesn't have the esp_arduino_version.h header
|
|
||||||
#include <esp_arduino_version.h>
|
|
||||||
#define ARDUINO_VERSION_CODE \
|
|
||||||
VERSION_CODE(ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATH)
|
|
||||||
#else
|
|
||||||
#define ARDUINO_VERSION_CODE VERSION_CODE(1, 0, 0) // there are no defines identifying minor/patch version
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -202,6 +202,7 @@ def write_platformio_project():
|
||||||
|
|
||||||
DEFINES_H_FORMAT = ESPHOME_H_FORMAT = """\
|
DEFINES_H_FORMAT = ESPHOME_H_FORMAT = """\
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "esphome/core/macros.h"
|
||||||
{}
|
{}
|
||||||
"""
|
"""
|
||||||
VERSION_H_FORMAT = """\
|
VERSION_H_FORMAT = """\
|
||||||
|
|
|
@ -74,7 +74,6 @@ build_flags =
|
||||||
; This are common settings for the ESP8266 using Arduino.
|
; This are common settings for the ESP8266 using Arduino.
|
||||||
[common:esp8266-arduino]
|
[common:esp8266-arduino]
|
||||||
extends = common:arduino
|
extends = common:arduino
|
||||||
; when changing this also copy it to esphome-docker-base images
|
|
||||||
platform = platformio/espressif8266 @ 3.2.0
|
platform = platformio/espressif8266 @ 3.2.0
|
||||||
platform_packages =
|
platform_packages =
|
||||||
platformio/framework-arduinoespressif8266 @ ~3.30002.0
|
platformio/framework-arduinoespressif8266 @ ~3.30002.0
|
||||||
|
@ -94,7 +93,6 @@ extra_scripts = post:esphome/components/esp8266/post_build.py.script
|
||||||
; This are common settings for the ESP32 (all variants) using Arduino.
|
; This are common settings for the ESP32 (all variants) using Arduino.
|
||||||
[common:esp32-arduino]
|
[common:esp32-arduino]
|
||||||
extends = common:arduino
|
extends = common:arduino
|
||||||
; when changing this also copy it to esphome-docker-base images
|
|
||||||
platform = platformio/espressif32 @ 3.3.2
|
platform = platformio/espressif32 @ 3.3.2
|
||||||
platform_packages =
|
platform_packages =
|
||||||
platformio/framework-arduinoespressif32 @ ~3.10006.0
|
platformio/framework-arduinoespressif32 @ ~3.10006.0
|
||||||
|
@ -113,7 +111,6 @@ extra_scripts = post:esphome/components/esp32/post_build.py.script
|
||||||
; This are common settings for the ESP32 (all variants) using IDF.
|
; This are common settings for the ESP32 (all variants) using IDF.
|
||||||
[common:esp32-idf]
|
[common:esp32-idf]
|
||||||
extends = common:idf
|
extends = common:idf
|
||||||
; when changing this also copy it to esphome-docker-base images
|
|
||||||
platform = platformio/espressif32 @ 3.3.2
|
platform = platformio/espressif32 @ 3.3.2
|
||||||
platform_packages =
|
platform_packages =
|
||||||
platformio/framework-espidf @ ~3.40300.0
|
platformio/framework-espidf @ ~3.40300.0
|
||||||
|
|
Loading…
Reference in a new issue