implement new light mode (off/day/night/simulation)

missing:
- fully connect it to the ui
- setup duration in light settings

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2025-09-29 23:15:06 +02:00
parent dc66484f5e
commit 08b0e04584
50 changed files with 14880 additions and 8787 deletions

View File

@@ -1,52 +1,45 @@
#include "app_task.h"
#include "ble_manager.h"
#include "esp_event.h"
#include "esp_insights.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "color.h"
#include "hal_esp32/PersistenceManager.h"
#include "led_manager.h"
#include "led_status.h"
#include "nvs_flash.h"
#include "sdkconfig.h"
#include "led_strip_ws2812.h"
#include "simulator.h"
#include "wifi_manager.h"
#include <ble_manager.h>
#include <esp_event.h>
#include <esp_insights.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <nvs_flash.h>
#include <sdkconfig.h>
#ifdef __cplusplus
extern "C"
__BEGIN_DECLS
void app_main(void)
{
#endif
void app_main(void)
// Initialize NVS
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
// Initialize NVS
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ESP_ERROR_CHECK(nvs_flash_erase());
ESP_ERROR_CHECK(nvs_flash_init());
}
led_status_init(CONFIG_STATUS_WLED_PIN);
wled_init();
register_handler();
xTaskCreatePinnedToCore(app_task, "app_task", 4096, NULL, tskIDLE_PRIORITY + 1, NULL, portNUM_PROCESSORS - 1);
xTaskCreatePinnedToCore(simulate, "simulate", 4096, NULL, tskIDLE_PRIORITY + 1, NULL, portNUM_PROCESSORS - 1);
// xTaskCreatePinnedToCore(ble_manager_task, "ble_manager", 4096, NULL, tskIDLE_PRIORITY + 1, NULL,
// portNUM_PROCESSORS - 1);
auto persistence = PersistenceManager();
persistence.Load();
if (persistence.GetValue("light_active", false))
{
led_event_data_t payload = {.value = 42};
send_event(EVENT_LED_ON, &payload);
}
ESP_ERROR_CHECK(nvs_flash_erase());
ESP_ERROR_CHECK(nvs_flash_init());
}
auto persistence = PersistenceManager();
persistence.Load();
led_status_init(CONFIG_STATUS_WLED_PIN);
led_strip_init();
start_simulation_task();
xTaskCreatePinnedToCore(app_task, "app_task", 4096, NULL, tskIDLE_PRIORITY + 1, NULL, portNUM_PROCESSORS - 1);
// xTaskCreatePinnedToCore(ble_manager_task, "ble_manager", 4096, NULL, tskIDLE_PRIORITY + 1, NULL,
// portNUM_PROCESSORS - 1);
if (persistence.GetValue("light_active", false))
{
led_strip_update(LED_STATE_DAY, rgb_t{});
}
#ifdef __cplusplus
}
#endif
__END_DECLS