Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/nspanel_easy/page_climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace nspanel_easy {
std::string set_climate_climate_icon;
bool set_climate_embedded_climate;

const char *temperature_unit = "°C"; // default

} // namespace nspanel_easy

#endif // NSPANEL_EASY_PAGE_CLIMATE
2 changes: 0 additions & 2 deletions components/nspanel_easy/page_climate.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace nspanel_easy {
extern std::string set_climate_climate_icon;
extern bool set_climate_embedded_climate;

extern const char *temperature_unit;

} // namespace nspanel_easy

#endif // NSPANEL_EASY_PAGE_CLIMATE
3 changes: 2 additions & 1 deletion components/nspanel_easy/pages.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ namespace nspanel_easy {
"confirm",
"utilities",
"home_smpl",
"debug"
"debug",
"water_heater"
};

constexpr size_t PAGE_COUNT = sizeof(page_names) / sizeof(page_names[0]);
Expand Down
170 changes: 35 additions & 135 deletions esphome/nspanel_esphome_addon_upload_tft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,144 +241,44 @@ script:
- lambda: return (!(display_mode > 0 and display_mode < 4));
timeout: 1s

# Stop Bluetooth components to free-up some memory
- if:
# Stop Bluetooth stack if present
- lambda: |-
// Stop Bluetooth stack to free memory for TFT upload
#ifdef USE_ESP32_BLE
ESP_LOGI("${TAG_UPLOAD_TFT}", "Stopping Bluetooth stack to free memory for TFT upload");
ESP_LOGI("${TAG_UPLOAD_TFT}", "Free heap before: %u bytes, largest block: %u bytes",
esp_get_free_heap_size(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
App.feed_wdt();
if (esp32_ble::global_ble != nullptr) {
ESP_LOGI("${TAG_UPLOAD_TFT}", "Disabling BLE stack");
esp32_ble::global_ble->disable();
}
#endif // USE_ESP32_BLE
- wait_until:
condition:
- lambda: |-
// Any of the BT components
#if defined(USE_ESP32_BLE_CLIENT) || defined(USE_ESP32_BLE_SERVER) || defined(USE_BLUETOOTH_PROXY)
return true;
#else
return false;
#endif // USE_ESP32_BLE_CLIENT || USE_ESP32_BLE_SERVER || USE_BLUETOOTH_PROXY
then:
- lambda: |-
ESP_LOGI("${TAG_UPLOAD_TFT}", "Stopping Bluetooth stack to free memory for TFT upload");
ESP_LOGI("${TAG_UPLOAD_TFT}", "Free heap before: %u bytes, largest block: %u bytes",
esp_get_free_heap_size(),
heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
// Bluetooth proxy
#ifdef USE_BLUETOOTH_PROXY
// Stop Bluetooth Proxy (releases connections and buffers)
auto *proxy = bluetooth_proxy::global_bluetooth_proxy;
if (proxy != nullptr) {
ESP_LOGD("${TAG_UPLOAD_TFT}", "Stopping Bluetooth Proxy");
proxy->set_active(false);
// ESP_LOGD("${TAG_UPLOAD_TFT}", "Flushing pending advertisements");
// proxy->flush_pending_advertisements();
}
#else
ESP_LOGD("${TAG_UPLOAD_TFT}", "Bluetooth Proxy component not present");
#endif // USE_BLUETOOTH_PROXY
- delay: !lambda |-
// Bluetooth proxy
#ifdef USE_BLUETOOTH_PROXY
return 2000;
#else
return 0;
#endif // USE_BLUETOOTH_PROXY

- lambda: |-
// BLE tracker
#ifdef USE_ESP32_BLE_CLIENT
App.feed_wdt();
// Stop BLE tracker scanning if active
auto *tracker = esp32_ble_tracker::global_esp32_ble_tracker;
if (tracker != nullptr) {
ESP_LOGD("${TAG_UPLOAD_TFT}", "Stopping BLE tracker");
tracker->stop_scan();
ESP_LOGD("${TAG_UPLOAD_TFT}", "Setting scan active to false");
tracker->set_scan_active(false);
ESP_LOGD("${TAG_UPLOAD_TFT}", "Stopping continuous scan");
tracker->set_scan_continuous(false);
}
#else
ESP_LOGD("${TAG_UPLOAD_TFT}", "BLE tracker component not present");
#endif // USE_ESP32_BLE_CLIENT
- delay: !lambda |-
// BLE tracker
#ifdef USE_ESP32_BLE_CLIENT
return 2000;
#else
return 0;
#endif // USE_ESP32_BLE_CLIENT

- lambda: |-
// BLE server
#ifdef USE_ESP32_BLE_SERVER
App.feed_wdt();
// Stop BLE server advertising if active
auto *ble = esp32_ble::global_ble;
if (ble != nullptr) {
ESP_LOGD("${TAG_UPLOAD_TFT}", "Stopping BLE advertising");
ble->advertising_stop();
}
// Wait up to 5s to the stack being disabled
#ifdef USE_ESP32_BLE
return (esp32_ble::global_ble == nullptr || !esp32_ble::global_ble->is_active());
#else
ESP_LOGD("${TAG_UPLOAD_TFT}", "BLE server component not present");
#endif // USE_ESP32_BLE_SERVER
- delay: !lambda |-
// BLE server
#ifdef USE_ESP32_BLE_SERVER
return 2000;
#else
return 0;
#endif // USE_ESP32_BLE_SERVER

- lambda: |-
// Bluetooth proxy - Disable the BT controller
#ifdef USE_BLUETOOTH_PROXY
ESP_LOGD("${TAG_UPLOAD_TFT}", "Disable BT controller");
esp_err_t err = esp_bt_controller_disable();
if (err != ESP_OK) {
ESP_LOGW("${TAG_UPLOAD_TFT}", "BT controller disable failed: %s", esp_err_to_name(err));
}
#endif // USE_BLUETOOTH_PROXY
- delay: !lambda |-
// Bluetooth proxy
#ifdef USE_BLUETOOTH_PROXY
return 2000;
#else
return 0;
#endif // USE_BLUETOOTH_PROXY
- lambda: |-
// Bluetooth proxy - Deinit the BT controller
#ifdef USE_BLUETOOTH_PROXY
ESP_LOGD("${TAG_UPLOAD_TFT}", "Deinitializing BT controller");
esp_err_t err = esp_bt_controller_deinit();
if (err != ESP_OK) {
ESP_LOGW("${TAG_UPLOAD_TFT}", "BT controller deinit failed: %s", esp_err_to_name(err));
}
#endif // USE_BLUETOOTH_PROXY
- delay: !lambda |-
// Bluetooth proxy
#ifdef USE_BLUETOOTH_PROXY
return 2000;
#else
return 0;
#endif // USE_BLUETOOTH_PROXY
- lambda: |-
// Bluetooth proxy - Release all BT memory (Classic + BLE) back to the heap
#ifdef USE_BLUETOOTH_PROXY
ESP_LOGD("${TAG_UPLOAD_TFT}", "Releasing all Bluetooth memory (BTDM)");
esp_err_t err = esp_bt_controller_mem_release(ESP_BT_MODE_BTDM);
if (err == ESP_OK) {
ESP_LOGI("${TAG_UPLOAD_TFT}", "Bluetooth memory released successfully");
} else {
ESP_LOGW("${TAG_UPLOAD_TFT}", "Bluetooth memory release failed: %s", esp_err_to_name(err));
}
#endif // USE_BLUETOOTH_PROXY
- delay: !lambda |-
// Bluetooth proxy
#ifdef USE_BLUETOOTH_PROXY
return 2000;
#else
return 0;
#endif // USE_BLUETOOTH_PROXY

- lambda: |-
ESP_LOGI("${TAG_UPLOAD_TFT}", "Free heap after: %u bytes, largest block: %u bytes",
esp_get_free_heap_size(),
heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
return true;
#endif // USE_ESP32_BLE
timeout: 5s
- lambda: |-
// Release BT memory back to the heap — not done by disable().
// Required to reclaim RAM for the TFT upload.
#ifdef USE_ESP32_BLE
App.feed_wdt();
ESP_LOGD("${TAG_UPLOAD_TFT}", "Releasing Bluetooth memory (BTDM)");
esp_err_t err = esp_bt_controller_mem_release(ESP_BT_MODE_BTDM);
if (err == ESP_OK) {
ESP_LOGI("${TAG_UPLOAD_TFT}", "Bluetooth memory released successfully");
} else {
ESP_LOGW("${TAG_UPLOAD_TFT}", "Bluetooth memory release failed: %s", esp_err_to_name(err));
}
ESP_LOGI("${TAG_UPLOAD_TFT}", "Free heap after: %u bytes, largest block: %u bytes",
esp_get_free_heap_size(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
#endif // USE_ESP32_BLE

### Attempt twice
- script.execute: upload_tft_sequence_attempt
Expand Down
11 changes: 11 additions & 0 deletions esphome/nspanel_esphome_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ substitutions:
BOOT_STEP_API: 30
TAG_API: nspanel.api
EVENT_NAME: esphome.nspanel_easy
mui_unavailable: Unavailable

api:
id: api_server
Expand Down Expand Up @@ -253,6 +254,13 @@ esphome:
build_flags:
- -D NSPANEL_EASY_API

globals:
- id: mui_unavailable
type: std::string
restore_value: true
initial_value: '"${mui_unavailable}"'
max_restore_data_length: 25

script:
- id: action_component_color
mode: single
Expand Down Expand Up @@ -302,6 +310,9 @@ script:
disp1->send_command_printf("%s.%s.txt=\"%s\"", page.c_str(), component.c_str(), escaped.c_str());
return;
}
if (component == "mui_unavailable") {
id(mui_unavailable) = txt;
}

- id: action_component_val
mode: single
Expand Down
20 changes: 16 additions & 4 deletions esphome/nspanel_esphome_hw_temperature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ globals:
restore_value: true
initial_value: 'true'

- id: temperature_unit
type: std::string
restore_value: true
initial_value: '"${temp_units}"'

number:
- id: temperature_correction # Temperature correction
name: Temperature Correction
Expand All @@ -53,13 +58,20 @@ number:
- lambda: temp_nspanel->publish_state(temp_nspanel->raw_state);

script:
- id: !extend action_component_text
then:
- lambda: |-
if (page != "mem") return;
if (component == "temp_unit") {
id(temperature_unit) = (txt == "°F") ? "°F" : "°C";
}

- id: !extend action_component_val
then:
- lambda: |-
if (page == "mem") {
if (component == "embedded_indoor_temperature") {
id(embedded_indoor_temp) = (val>0);
}
if (page != "mem") return;
if (component == "embedded_indoor_temperature") {
id(embedded_indoor_temp) = (val>0);
}

- id: display_embedded_temp # Show panel's temperature if selected, or API or Wi-Fi are out
Expand Down
Loading
Loading