This commit is contained in:
marc 2025-04-19 19:47:15 +02:00
parent a0d0533181
commit 5cabe7e3f4
5 changed files with 58 additions and 52 deletions

View File

@ -12,6 +12,7 @@
extern char *upEvent;
extern char *downEvent;
extern esp_mqtt_client_handle_t client;
lv_subject_t dateHeureSubj;
lv_obj_t *lblTempInt2;
@ -65,7 +66,7 @@ static void event_handler(lv_event_t *e)
break;
case LV_EVENT_CLICKED:
ESP_LOGI(TAG, "%s was clicked\n", evtData);
//esp_mqtt_client_publish(client, "volets", evtData, 0, 0, 0);
esp_mqtt_client_publish(client, "volets", evtData, 0, 0, 0);
break;
case LV_EVENT_LONG_PRESSED:
LV_LOG_USER("%s was long pressed\n", evtData);
@ -93,6 +94,7 @@ void init_display(){
lv_display_t *dsp = bsp_display_start_with_config(&cfg);
//bsp_display_rotate(dsp,LV_DISP_ROTATION_180);
bsp_display_brightness_set(50);
bsp_display_backlight_on();
mainState.display_init=true;
}
@ -545,6 +547,11 @@ void draw_tabSettings(lv_obj_t * parent)
}
lv_obj_t *tabview;
static void cuve_click_cb(lv_event_t * e){
lv_tabview_set_active(tabview, 3, false);
}
void draw_tabHome(lv_obj_t* parent){
lv_obj_t *supmain = parent;
@ -627,6 +634,7 @@ void draw_tabHome(lv_obj_t* parent){
//Create a container with COLUMN flex direction
lv_obj_t *cont_Cuve = lv_obj_create(cont_colTemp);
lv_obj_add_event_cb(cont_Cuve, cuve_click_cb, LV_EVENT_CLICKED, NULL);
lv_obj_add_style(cont_Cuve, &style_container, 0);
lv_obj_set_flex_flow(cont_Cuve, LV_FLEX_FLOW_ROW_WRAP);
// lv_obj_set_height(cont_Cuve,80);
@ -776,7 +784,6 @@ void draw_ihm()
lv_obj_clean(lv_scr_act());
//Create a Tab view object
lv_obj_t *tabview;
tabview = lv_tabview_create(lv_screen_active());
lv_tabview_set_tab_bar_position(tabview, LV_DIR_LEFT);
lv_tabview_set_tab_bar_size(tabview, 80);
@ -893,5 +900,8 @@ void log_cb(lv_log_level_t level, const char * buf){
}
void show_temp(char * tempHumid){
display_lock("tempHumid");
lv_label_set_text(lblTempInt2, tempHumid);
display_unlock("tempHumid");
}

View File

@ -120,27 +120,6 @@ void mount_sd_card()
extern char *days[7];
extern char *months[12];
static void updateTime(void *pvParameter)
{
char strftime_buf[64];
time_t now = 0;
while (1)
{
time(&now);
struct tm timeinfo = {0};
localtime_r(&now, &timeinfo);
sprintf(strftime_buf, "%s %d %s %02d:%02d", days[timeinfo.tm_wday], timeinfo.tm_mday, months[timeinfo.tm_mon], timeinfo.tm_hour, timeinfo.tm_min);
draw_time(strftime_buf);
/*
lv_obj_refr_size(lv_obj_get_child(lv_obj_get_child(lv_layer_top(),0),0));
lv_obj_refr_size(lv_obj_get_child(lv_layer_top(),0));
lvgl_port_unlock();
}*/
vTaskDelay(60000 / portTICK_PERIOD_MS);
}
}
esp_err_t _ota_http_event_handler(esp_http_client_event_t *evt)
{
switch (evt->event_id) {
@ -189,7 +168,10 @@ void simple_ota_example_task(void *pvParameter)
ESP_LOGI(TAG, "Bind interface name is %s", ifr.ifr_name);
#endif
esp_http_client_config_t config = {
.url = "https://192.168.0.28:8070/rgb_lcd.bin",
.url = "http://192.168.0.28:8070/rgb_lcd.bin",
.timeout_ms = 30000,
.buffer_size = 6144,
.buffer_size_tx = 6144, //TX Buffer, Main Buffer
.event_handler = _ota_http_event_handler,
.keep_alive_enable = true,
.cert_pem = (char *)server_cert_pem_start,
@ -363,13 +345,6 @@ void app_main(void)
time(&now);
}
char strftime_buf[64];
// Set timezone to Eastern Standard Time and print local time
setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1);
tzset();
localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
printf("10. Free heap after buffers allocation: %d\n", xPortGetFreeHeapSize());
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
@ -417,5 +392,7 @@ void app_main(void)
xTaskCreate(&readTempHumid, "read_temp_task", 8192, NULL, 5, NULL);
//xTaskCreate(&simple_ota_example_task, "ota_example_task", 8192, NULL, 5, NULL);
}

View File

@ -3,6 +3,7 @@
#include "esp_sntp.h"
#include "obtain_time.h"
#include "esp_lvgl_port.h"
#include "ihm.h"
static const char *TAG = "sntp";
extern lv_subject_t dateHeureSubj;
@ -13,28 +14,45 @@ char *months[12]={"Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Ao
void time_sync_notification_cb(struct timeval *tv)
{
ESP_LOGI(TAG, "Notification of a time synchronization event");
//setlocale(LC_ALL, "fr_FR");
char strftime_buf[64];
// Set timezone to Eastern Standard Time and print local time
setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1);
tzset();
time_t now;
struct tm timeinfo;
localtime_r(&now, &timeinfo);
strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
time(&now);
localtime_r(&now, &timeinfo);
}
void obtain_time(void)
void obtain_time()
{
ESP_LOGI(TAG, "Initializing and starting SNTP");
esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG("pool.ntp.org");
config.sync_cb = time_sync_notification_cb; // Note: This is only needed if we want
esp_netif_sntp_init(&config);
// wait for time to be set
time_t now = 0;
struct tm timeinfo = { 0 };
int retry = 0;
const int retry_count = 15;
while (esp_netif_sntp_sync_wait(2000 / portTICK_PERIOD_MS) == ESP_ERR_TIMEOUT && ++retry < retry_count) {
ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, retry_count);
}
time(&now);
localtime_r(&now, &timeinfo);
esp_netif_sntp_deinit();
}
void updateTime(void *pvParameter)
{
char strftime_buf[64];
time_t now = 0;
while (1)
{
time(&now);
struct tm timeinfo = {0};
localtime_r(&now, &timeinfo);
sprintf(strftime_buf, "%s %d %s %02d:%02d", days[timeinfo.tm_wday], timeinfo.tm_mday, months[timeinfo.tm_mon], timeinfo.tm_hour, timeinfo.tm_min);
draw_time(strftime_buf);
/*
lv_obj_refr_size(lv_obj_get_child(lv_obj_get_child(lv_layer_top(),0),0));
lv_obj_refr_size(lv_obj_get_child(lv_layer_top(),0));
lvgl_port_unlock();
}*/
vTaskDelay(60000 / portTICK_PERIOD_MS);
}
}

View File

@ -1,2 +1,3 @@
void obtain_time(void);
void obtain_time();
void updateTime(void *pvParameter);
#pragma once

View File

@ -1041,7 +1041,7 @@ CONFIG_ESP_HTTP_CLIENT_EVENT_POST_TIMEOUT=2000
# ESP HTTPS OTA
#
# CONFIG_ESP_HTTPS_OTA_DECRYPT_CB is not set
# CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP is not set
CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP=y
CONFIG_ESP_HTTPS_OTA_EVENT_POST_TIMEOUT=2000
# end of ESP HTTPS OTA
@ -2589,12 +2589,12 @@ CONFIG_LV_USE_DRAW_SW_ASM=0
#
CONFIG_LV_USE_LOG=y
# CONFIG_LV_LOG_LEVEL_TRACE is not set
CONFIG_LV_LOG_LEVEL_INFO=y
# CONFIG_LV_LOG_LEVEL_INFO is not set
# CONFIG_LV_LOG_LEVEL_WARN is not set
# CONFIG_LV_LOG_LEVEL_ERROR is not set
CONFIG_LV_LOG_LEVEL_ERROR=y
# CONFIG_LV_LOG_LEVEL_USER is not set
# CONFIG_LV_LOG_LEVEL_NONE is not set
CONFIG_LV_LOG_LEVEL=1
CONFIG_LV_LOG_LEVEL=3
CONFIG_LV_LOG_PRINTF=y
# CONFIG_LV_LOG_USE_TIMESTAMP is not set
# CONFIG_LV_LOG_USE_FILE_LINE is not set
@ -2921,7 +2921,7 @@ CONFIG_STACK_CHECK_NONE=y
# CONFIG_EVENT_LOOP_PROFILING is not set
CONFIG_POST_EVENTS_FROM_ISR=y
CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
# CONFIG_OTA_ALLOW_HTTP is not set
CONFIG_OTA_ALLOW_HTTP=y
CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304
CONFIG_MAIN_TASK_STACK_SIZE=3584