Support to Fahrenheit with esp-idf

This commit is contained in:
Edward Firmo
2023-12-18 13:21:19 +01:00
parent a1e488c72f
commit b086ccc16d
2 changed files with 28 additions and 27 deletions

View File

@@ -22,28 +22,28 @@ substitutions:
api: api:
services: services:
##### SERVICE TO UPDATE THE TFT FILE from URL ##### ##### SERVICE TO UPDATE THE TFT FILE from URL #####
##### It will use the default url if url is empty or "default" ##### It will use the default url if url is empty or "default"
- service: upload_tft_url - service: upload_tft_url
variables: variables:
url: string url: string
then: then:
- lambda: |- - lambda: |-
static const char *const TAG = "service.upload_tft_url"; static const char *const TAG = "service.upload_tft_url";
ESP_LOGVV(TAG, "Starting..."); ESP_LOGVV(TAG, "Starting...");
std::string clean_url = url; std::string clean_url = url;
// Convert to lowercase // Convert to lowercase
std::transform(clean_url.begin(), clean_url.end(), clean_url.begin(), std::transform(clean_url.begin(), clean_url.end(), clean_url.begin(),
[](unsigned char c){ return std::tolower(c); }); [](unsigned char c){ return std::tolower(c); });
// Trim trailing spaces // Trim trailing spaces
auto endPos = clean_url.find_last_not_of(" \t"); auto endPos = clean_url.find_last_not_of(" \t");
if (std::string::npos != endPos) { if (std::string::npos != endPos) {
clean_url = clean_url.substr(0, endPos + 1); clean_url = clean_url.substr(0, endPos + 1);
} }
if ( clean_url.empty() or clean_url == "default") url = tft_list->state; if ( clean_url.empty() or clean_url == "default") url = tft_list->state;
upload_tft->execute(url.c_str()); upload_tft->execute(url.c_str());
button: button:
##### UPDATE TFT DISPLAY ##### ##### UPDATE TFT DISPLAY #####

View File

@@ -364,9 +364,9 @@ api:
- wait_until: - wait_until:
condition: condition:
- not: - not:
- text_sensor.state: # Is boot page visible? - text_sensor.state: # Is boot page visible?
id: current_page id: current_page
state: 'boot' state: 'boot'
timeout: 2s timeout: 2s
- if: - if:
condition: condition:
@@ -1257,7 +1257,8 @@ sensor:
reference_resistance: 10kOhm reference_resistance: 10kOhm
filters: filters:
- lambda: |- - lambda: |-
if ("${temp_units}" == "°F" or "${temp_units}" == "F" or "${temp_units}" == "°f" or "${temp_units}" == "f") std::string temp_unit = "${temp_units}";
if (temp_unit == "°F" or temp_unit == "F" or temp_unit == "°f" or temp_unit == "f")
return (x * (9.0/5.0)) + 32.0 + temperature_correction->state; return (x * (9.0/5.0)) + 32.0 + temperature_correction->state;
else else
return x + temperature_correction->state; return x + temperature_correction->state;
@@ -2588,9 +2589,9 @@ script:
- wait_until: - wait_until:
condition: condition:
- not: - not:
- text_sensor.state: # Is boot page visible? - text_sensor.state: # Is boot page visible?
id: current_page id: current_page
state: 'boot' state: 'boot'
timeout: 15s timeout: 15s
- lambda: |- - lambda: |-
static const char *const TAG = "script.boot_sequence"; static const char *const TAG = "script.boot_sequence";