diff --git a/.vscode/settings.json b/.vscode/settings.json index 14e64aa..1020cdc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -88,7 +88,19 @@ "typeinfo": "cpp", "variant": "cpp", "esp_task_wdt.h": "c", - "stdio.h": "c" + "stdio.h": "c", + "lv_color.h": "c", + "lv_theme_simple.h": "c", + "esp_log.h": "c", + "lv_theme_domotic.h": "c", + "event_groups.h": "c", + "freertos.h": "c", + "ihm.h": "c", + "esp_check.h": "c", + "esp-bsp.h": "c", + "esp_littlefs.h": "c", + "esp_vfs_fat.h": "c", + "esp_http_client.h": "c" }, "idf.pythonInstallPath": "/usr/local/bin/python" } diff --git a/components/meteofrance/include/meteofrance.h b/components/meteofrance/include/meteofrance.h index bcc8694..39c6a2f 100644 --- a/components/meteofrance/include/meteofrance.h +++ b/components/meteofrance/include/meteofrance.h @@ -1,7 +1,8 @@ - +#pragma once #include "time.h" +#include "stdbool.h" -struct node { +/*struct node { struct node *next; int e; }; @@ -10,6 +11,7 @@ struct Hashtable { unsigned Tablesize; struct node *Cells; }; + */ struct dailyforecast_prev{ float min; @@ -24,17 +26,17 @@ struct forecast_prev{ char icon[9]; }; -struct meteodailyforecast_data{ +typedef struct meteodailyforecast_data{ time_t datetime; bool isValid; struct dailyforecast_prev previsions; -}; +} meteodailyforecast_data; -struct meteoforecast_data{ +typedef struct meteoforecast_data{ time_t datetime; bool isValid; struct forecast_prev previsions; -}; +} meteoforecast_data; typedef void (*weather_data_callback)(struct meteodailyforecast_data *datas, struct meteoforecast_data *datasf); typedef void (*weather_data_start_callback)(); diff --git a/components/meteofrance/meteofrance.c b/components/meteofrance/meteofrance.c index 078fbe8..a3a49fb 100644 --- a/components/meteofrance/meteofrance.c +++ b/components/meteofrance/meteofrance.c @@ -9,6 +9,8 @@ See the file LICENSE for details. */ +#include "meteofrance.h" + #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_system.h" @@ -17,7 +19,6 @@ #include #include -#include "meteofrance.h" #include "cJSON.h" #include "esp_http_client.h" #include "esp_tls.h" @@ -389,7 +390,7 @@ void initialise_weather_data_retrieval(unsigned long retreival_period) // http_client_on_process_chunk(&http_client, process_chunk); // http_client_on_disconnected(&http_client, disconnected); TaskHandle_t xHandle = NULL; - BaseType_t ret1 = xTaskCreate(&http_request_task, "http_request_task", 5 * 1024, NULL, 5, &xHandle); + BaseType_t ret1 = xTaskCreate(&http_request_task, "http_meteof", 5 * 1024, NULL, 5, &xHandle); if(ret1!=pdPASS ){ ESP_LOGE(TAG, "Impossible de creer la tache %i", ret1); } diff --git a/dependencies.lock b/dependencies.lock index 311841e..f0125e1 100644 --- a/dependencies.lock +++ b/dependencies.lock @@ -104,7 +104,7 @@ dependencies: type: service version: 1.2.0 espressif/esp_hosted: - component_hash: ef6bc803451fab3c3f9a679bbc1c48fba0ceeeabc5af4178dd7d2300fafa423e + component_hash: 9e7a202cc18c08fa9b67c0261f9733b33af9b3af73eafd4ef6704cdb37bde7c2 dependencies: - name: idf require: private @@ -112,7 +112,7 @@ dependencies: source: registry_url: https://components.espressif.com type: service - version: 1.4.0 + version: 1.4.1 espressif/esp_lcd_ek79007: component_hash: 07c1afab7e9fd4dd2fd06ff9245e65327c5bbd5485efec199496e19a9304d47b dependencies: @@ -262,6 +262,6 @@ direct_dependencies: - joltwallet/littlefs - lvgl/lvgl - suda-morris/am2302_rmt -manifest_hash: 63eaaa4e8d94182764c8e6d23da6beff61e56db0cec736ba19ba0f825469c47c +manifest_hash: 15284e0a2c7903f038a0abcadaa03469042782b30abea68977d3e3e45b11bbaa target: esp32p4 version: 2.0.0 diff --git a/main/idf_component.yml b/main/idf_component.yml index 674e290..24dedb3 100644 --- a/main/idf_component.yml +++ b/main/idf_component.yml @@ -1,6 +1,6 @@ dependencies: espressif/esp_wifi_remote: "0.8.5" - espressif/esp32_p4_function_ev_board: "^4.1.1" + #espressif/esp32_p4_function_ev_board: "^4.1.1" suda-morris/am2302_rmt: "^1.0.0" espressif/esp_websocket_client: "^1.3.0" joltwallet/littlefs: ^1.14.8 @@ -12,8 +12,8 @@ dependencies: version: '5.4.*' lvgl/lvgl: version: 9.2.0 - espressif/esp32_p4_function_ev_board: - version: "4.1.*" + #espressif/esp32_p4_function_ev_board: + # version: "4.1.*" chmorgan/esp-audio-player: version: "1.0.*" diff --git a/main/ihm.c b/main/ihm.c new file mode 100644 index 0000000..b23e7bb --- /dev/null +++ b/main/ihm.c @@ -0,0 +1,1055 @@ +#include "bsp/display.h" +#include "bsp_board_extra.h" +#include "lv_theme_domotic.h" +#include "esp_lvgl_port.h" +#include "ihm.h" +#include "misc/lv_types.h" +#include "esp_log.h" +#include "string.h" +#include "meteofrance.h" + + +extern char *upEvent; +extern char *downEvent; + +lv_subject_t dateHeureSubj; +lv_obj_t *lblTempInt2; +char tempExtStr[6]; +char tempIntStr[6]; +char hauteurCuveStr[9]; +char hauteurCuveEvolStr[9]; +lv_subject_t tempIntSubj; +lv_subject_t tempExtSubj; +lv_subject_t hauteurCuveSubj; +lv_subject_t hauteurCuveEvolSubj; +lv_subject_t forecastD1Subj; +lv_subject_t forecastD2Subj; +lv_subject_t forecastD3Subj; +lv_subject_t *tmpSubj[3] = {&forecastD1Subj, &forecastD2Subj, &forecastD3Subj}; +lv_subject_t forecastH1Subj; +lv_subject_t forecastH2Subj; +lv_subject_t forecastH3Subj; +lv_subject_t *tmpHSubj[3] = {&forecastH1Subj, &forecastH2Subj, &forecastH3Subj}; + +lv_subject_t meteoStatus; +char dateHeureStr[30]; + +static lv_style_t no_padding; +static const char *TAG = "IHM"; + +void draw_time(char* dateHeure){ + if(display_lock("updateTime")){ + lv_subject_copy_string(&dateHeureSubj, dateHeure); + display_unlock("updateTime"); + } +} + +void draw_temp(char * tempHumid){ + if(lvgl_port_lock(5)){ + lv_label_set_text(lblTempInt2,tempHumid); + lvgl_port_unlock(); + } + +} +static void event_handler(lv_event_t *e) +{ + lv_event_code_t code = lv_event_get_code(e); + // lv_obj_t *obj = (lv_obj_t *)lv_event_get_target(e); + char *evtData = (char *)lv_event_get_user_data(e); + + switch (code) + { + case LV_EVENT_PRESSED: + // LV_LOG_USER("%s was pressed\n", evtData); + break; + case LV_EVENT_CLICKED: + ESP_LOGI(TAG, "%s was clicked\n", evtData); + //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); + break; + case LV_EVENT_LONG_PRESSED_REPEAT: + LV_LOG_USER("%s was long press repeat\n", evtData); + break; + default: + break; + } +} + +void app_main_display() +{ + + bsp_display_cfg_t cfg = { + .lvgl_port_cfg = ESP_LVGL_PORT_INIT_CONFIG(), + .buffer_size = BSP_LCD_DRAW_BUFF_SIZE, + .double_buffer = BSP_LCD_DRAW_BUFF_DOUBLE, + .flags = { + .buff_dma = true, + .buff_spiram = false, + .sw_rotate = false, + } + }; + /*lv_display_t *dsp =*/ bsp_display_start_with_config(&cfg); + //bsp_display_rotate(dsp,LV_DISP_ROTATION_180); + + bsp_display_backlight_on(); + + lv_subject_init_int(&meteoStatus, -1); + + on_weather_data_retrieval(weather_data_retreived); + on_weather_data_retrieval_start(weather_data_retreived_start); + initialise_weather_data_retrieval(600000); + ESP_LOGW(TAG, "Weather data retrieval initialized"); + + lv_theme_t * th = lv_theme_domotic_init(lv_display_get_default()); + lv_display_set_theme(lv_disp_get_default(), th); /* Assign theme to display */ + + lv_subject_init_string(&dateHeureSubj, dateHeureStr, NULL, 64, "--"); + + lv_style_init(&no_padding); + lv_style_set_pad_all(&no_padding, 0); + + static const lv_color_t grad_colors[2] = { + LV_COLOR_MAKE(0x9B, 0x18, 0x42), + LV_COLOR_MAKE(0x00, 0x00, 0x00), + }; + + static lv_style_t style_gradient; + lv_style_init(&style_gradient); + + /*First define a color gradient. In this example we use a purple to black color map.*/ + static lv_grad_dsc_t grad; + + ESP_LOGE(TAG,"On aimerait %d stops", sizeof(grad_colors) / sizeof(lv_color_t)); + lv_gradient_init_stops(&grad, grad_colors, NULL, NULL, sizeof(grad_colors) / sizeof(lv_color_t)); + + /*Make a radial gradient with the center in the middle of the object, extending to the farthest corner*/ + lv_grad_radial_init(&grad, LV_GRAD_CENTER, LV_GRAD_CENTER, LV_GRAD_RIGHT, LV_GRAD_BOTTOM, LV_GRAD_EXTEND_PAD); + + /*Set gradient as background*/ + lv_style_set_bg_grad(&style_gradient, &grad); + + lv_obj_t *cont_status = lv_obj_create(lv_layer_top()); + lv_obj_add_style(cont_status, &no_padding, 0); + lv_obj_align(cont_status, LV_ALIGN_TOP_RIGHT, 0, 0); + lv_obj_set_flex_flow(cont_status, LV_FLEX_FLOW_ROW); + lv_obj_set_height(cont_status, LV_SIZE_CONTENT); + lv_obj_set_width(cont_status, LV_SIZE_CONTENT); + + lv_obj_t *jour = lv_label_create(cont_status); + lv_obj_set_style_text_font(jour,lv_theme_get_font_normal(jour),0); + lv_obj_set_width(jour, LV_SIZE_CONTENT); + lv_label_bind_text(jour, &dateHeureSubj, NULL); + + lv_obj_refr_size(cont_status); + // lv_obj_align(jour, LV_ALIGN_CENTER,0,0); + + lv_obj_t *meteoR = lv_label_create(cont_status); + lv_obj_set_style_text_font(meteoR,lv_theme_get_font_normal(jour),0); + lv_label_set_text(meteoR, "\xEF\x83\x82"); + lv_obj_set_style_text_color(meteoR, lv_color_make(0x00, 0xff, 0xff), 0); + lv_subject_add_observer_obj(&meteoStatus, meteo_obs_cb, meteoR, NULL); + + // lv_label_bind_text(meteoR, &meteoStatus, "Meteo %d"); + + /*lv_obj_t *wifi =*/ lv_image_create(cont_status); + // lv_obj_set_style_bg_color(wifi, lv_palette_darken(LV_PALETTE_GREY, 3), 0); + // lv_obj_set_style_border_width(wifi,1,0); + // lv_obj_set_style_border_color(wifi,lv_palette_darken(LV_PALETTE_GREY, 3),0); + // lv_label_set_text(wifi,"Wifi Ok"); + // lv_label_bind_text(wifi, &wifiStatus, "Wifi %d"); + + lv_image_create(cont_status); + // lv_label_set_text(mqtt,"Mqtt Ok"); + // lv_label_bind_text(mqtt, &mqttStatus, "Mqtt %d"); + + lv_obj_t *scr = lv_scr_act(); + lv_obj_add_style(scr, &style_gradient, 0); + + /* Your LVGL objects code here .... */ + + /* Label */ + lv_obj_t *label = lv_label_create(scr); + lv_obj_set_width(label, lv_pct(100)); + lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0); + lv_obj_set_style_text_font(label,lv_theme_get_font_large(label),0); + lv_label_set_text(label, LV_SYMBOL_BELL "Bienvenue sur DomoTIC !" LV_SYMBOL_BELL); + lv_obj_align(label, LV_ALIGN_CENTER, 0, 20); +} + +bool display_lock(const char* TAG){ + ESP_LOGI(TAG,"Obtention mutexx"); + if(bsp_display_lock(5000)){ + ESP_LOGI(TAG, "Mutex obtenu"); + return true; + }else{ + ESP_LOGE(TAG, "Impossible d'obtenir le mutex"); + return false; + } +} +void display_unlock(const char* TAG){ + ESP_LOGI(TAG,"Libération mutexx"); + bsp_display_unlock(); +} + +// Ce callback est applé lorsque meteoStatus change +void meteo_obs_cb(lv_observer_t *observer, lv_subject_t *subject) +{ + ESP_LOGI(TAG, "On passe dans le callback de chgt de statut meteo; %li", lv_subject_get_int(subject)); + if (display_lock("meteo_obs_cb")) + { + lv_obj_t *meteoSt = observer->target; + switch (lv_subject_get_int(subject)) + { + case 0: + lv_obj_set_style_text_color(meteoSt, lv_color_make(0x00, 0xff, 0xff), 0); + break; + case 1: + lv_obj_set_style_text_color(meteoSt, lv_color_make(0xff, 0x00, 0x00), 0); + break; + } + display_unlock("meteo_obs_cb"); + }else{ + ESP_LOGE(TAG,"Impossible d'obtenir le mutex dans meteo_obs_cb"); + } +} + +LV_IMAGE_DECLARE(plan_rdc); +LV_IMAGE_DECLARE(plan_etage); + +static lv_style_t style_container; + +// Callback pour mettre à jour une météo journaliere +// On pointe sur un tableau de meteodailyforecast_data +static void weatherdata_obs_cb(lv_observer_t *observer, lv_subject_t *subject) +{ + + ESP_LOGE(TAG, "CB meteo jour declenché"); + // Retrieve weatherdata + const struct meteodailyforecast_data *data = subject->value.pointer; + // printffd(data); + // char buff[40] = {}; + // sprintf(buff,"%s %.1f %.1f", data->previsions.desc, data->previsions.min, data->previsions.max); + + lv_obj_t *parent = (lv_obj_t *)(observer->target); + lv_obj_t *datefld = lv_obj_get_child(parent, 0); + lv_obj_t *desc_icon = lv_obj_get_child(parent, 1); + lv_obj_t *temps = lv_obj_get_child(parent, 2); + showMeteoIcon(data->previsions.icon, desc_icon, 0); + char buffer[80]; + dtToString(data->datetime, buffer); + + lv_label_set_text(datefld, buffer); + lv_label_set_text(lv_obj_get_child(desc_icon, 1), data->previsions.desc); + lv_label_set_text_fmt(lv_obj_get_child(temps, 0), "%.1f°C", data->previsions.max); + lv_label_set_text_fmt(lv_obj_get_child(temps, 1), "%.1f°C", data->previsions.min); +} + +// Callback pour mettre à jour une météo horaire +// On pointe sur un tableau de meteoforecast_data +static void weatherdataH_obs_cb(lv_observer_t *observer, lv_subject_t *subject) +{ + ESP_LOGV("MeteoFrance", "CB meteo horaire declenché"); + // Retrieve weatherdata + const struct meteoforecast_data *data = subject->value.pointer; + if(data->isValid){ + + //printffd(data); + char buff[40] = {}; + sprintf(buff,"%.1f", data->previsions.value); + ESP_LOGV(TAG, "On a recu [%s]", buff); + + lv_obj_t *parent = (lv_obj_t *)(observer->target); + lv_obj_t *datefld = lv_obj_get_child(parent, 0); + lv_obj_t *temp_desc_icon = lv_obj_get_child(parent, 1); + showMeteoIcon(data->previsions.icon, temp_desc_icon, 1); + + char buffer[80]; + dtHToString(data->datetime, buffer); + + lv_label_set_text(datefld, buffer); + lv_label_set_text(lv_obj_get_child(temp_desc_icon, 2), data->previsions.desc); + lv_label_set_text_fmt(lv_obj_get_child(temp_desc_icon, 0), "%.1f°C", data->previsions.value); + + }else{ + ESP_LOGE(TAG, "Pas de odnnées valides"); + } + +} + +void showMeteoIcon(const char *icon, lv_obj_t *desc_icon, int childNr) +{ + lv_obj_t *img = lv_obj_get_child(desc_icon, childNr); + char *str1 = "A:/littlefs/"; + char *result = malloc(strlen(str1) + strlen(icon) + 6); + sprintf(result, "%s%s.png", str1, icon); + lv_image_set_src(img, result); +} +/* ------------------------------------------------------------ */ +/* Fragment meteo journaliere (date,icone, min et max) */ +/* ------------------------------------------------------------ */ + +// Structure meteo journaliere +struct weatherDay_fragment_t +{ + /* IMPORTANT: don't miss this part */ + lv_fragment_t base; + /* States, object references and data fields for this fragment */ + int dayNr; + bool showTitle; + const char *title; + float minTemp; + float maxTemp; +}; + +// Constructeur meteo journaliere +static void weatherDay_fragment_ctor(lv_fragment_t *self, void *args) +{ + int dayNo = ((int *)args)[0]; + bool showDate = ((int *)args)[1]; + ((struct weatherDay_fragment_t *)self)->dayNr = dayNo; + ((struct weatherDay_fragment_t *)self)->showTitle = showDate; + ESP_LOGI(TAG, "Fragment initialisé avec le jour n°%d - Afficher la date %d", dayNo, showDate); +} + +// Ce fragment affiche une prévision journaliere (date,icone, min et max) +static lv_obj_t *weatherDay_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) +{ + + lv_obj_t *sup = lv_obj_create(parent); + + lv_obj_t *title = lv_label_create(sup); + lv_label_set_text(title, "--"); + + lv_obj_set_flex_flow(sup, LV_FLEX_FLOW_ROW); + lv_obj_add_style(sup, &style_container, 0); + lv_obj_set_size(sup, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + + lv_obj_t *container = lv_obj_create(sup); + lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + lv_obj_add_style(container, &no_padding, 0); + lv_obj_set_width(container, 150); + lv_obj_set_height(container, 80); + + lv_obj_t *img1 = lv_image_create(container); + lv_obj_add_style(img1, &no_padding, 0); + lv_obj_set_style_bg_color(img1, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4), 0); + lv_image_set_inner_align(img1, LV_IMAGE_ALIGN_TOP_LEFT); + lv_image_set_offset_y(img1, -8); + lv_image_set_offset_x(img1, -5); + lv_obj_set_size(img1, 40, 32); + lv_image_set_src(img1, LV_SYMBOL_DUMMY); + // lv_obj_set_style_border_width(img1,2,0); + // lv_obj_set_style_border_color(img1, lv_palette_main(LV_PALETTE_BLUE_GREY), 0); + lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0); + + lv_obj_t *desc = lv_label_create(container); + lv_label_set_text(desc, "--"); + lv_obj_set_style_text_font(desc, lv_theme_get_font_normal(desc),0); + + lv_obj_t *container2 = lv_obj_create(sup); + lv_obj_set_width(container2, LV_SIZE_CONTENT); + lv_obj_set_height(container2, 80); + lv_obj_add_style(container2, &no_padding, 0); + lv_obj_set_style_pad_top(container2, 5, 0); + lv_obj_set_style_pad_bottom(container2, 5, 0); + lv_obj_set_flex_flow(container2, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container2, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + + static lv_style_t tempStyle; + lv_style_init(&tempStyle); + // lv_style_set_text_font(&tempStyle,¬omedium16); + + lv_obj_t *max = lv_label_create(container2); + lv_label_set_text(max, "--"); + lv_obj_add_style(max, &tempStyle, 0); + lv_obj_set_style_text_font(max,lv_theme_get_font_normal(max),0); + lv_obj_set_style_text_color(max, lv_color_hex(0xFF0000), 0); + + lv_obj_t *min = lv_label_create(container2); + lv_label_set_text(min, "--"); + lv_obj_add_style(min, &tempStyle, 0); + lv_obj_set_style_text_font(min,lv_theme_get_font_normal(max),0); + lv_obj_set_style_text_color(min, lv_color_hex(0x3000FF), 0); + + // On positionne un observer sur le subjet correspondant au jour du widget + lv_subject_add_observer_obj(tmpSubj[((struct weatherDay_fragment_t *)self)->dayNr], weatherdata_obs_cb, sup, NULL); + return container; +} + +// Fragment meteo journaliere +const lv_fragment_class_t meteoFragment = { + /* Initialize something needed */ + .constructor_cb = weatherDay_fragment_ctor, + /* Create view objects */ + .create_obj_cb = weatherDay_fragment_create_obj, + /* IMPORTANT: size of your fragment struct */ + .instance_size = sizeof(struct weatherDay_fragment_t), +}; + +/* ------------------------------------------------------------ */ +/* Fragment meteo horaire ("heure",icone, temp) */ +/* ------------------------------------------------------------ */ + +// Structure meteo horaire +struct weatherH_fragment_t +{ + /* IMPORTANT: don't miss this part */ + lv_fragment_t base; + /* States, object references and data fields for this fragment */ + int horaireNr; + bool showTitle; + const char *horaire; + float temp; +}; + +// Constructeur meteo horaire +static void weatherH_fragment_ctor(lv_fragment_t *self, void *args) +{ + // Represente le n° (index dans le tableau) a afficher + int horaireNr = ((int *)args)[0]; + bool showDate = ((int *)args)[1]; + ((struct weatherH_fragment_t *)self)->horaireNr = horaireNr; + ((struct weatherH_fragment_t *)self)->showTitle = showDate; + ESP_LOGI(TAG, "Fragment initialisé avec l'horaire %d", horaireNr); +} + +// Ce fragment affiche une prévision horaire (date,icone, temp moyenne) +static lv_obj_t *weatherH_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) +{ + + lv_obj_t *sup = lv_obj_create(parent); + + lv_obj_t *title = lv_label_create(sup); + lv_label_set_text(title, "--"); + + lv_obj_set_flex_flow(sup, LV_FLEX_FLOW_ROW); + lv_obj_add_style(sup, &style_container, 0); + lv_obj_set_size(sup, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + + lv_obj_t *container = lv_obj_create(sup); + lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + lv_obj_add_style(container, &no_padding, 0); + lv_obj_set_width(container, 150); + lv_obj_set_height(container, LV_SIZE_CONTENT); + + static lv_style_t tempStyle; + lv_style_init(&tempStyle); + // lv_style_set_text_font(&tempStyle,¬omedium16); + + lv_obj_t *temp = lv_label_create(container); + lv_label_set_text(temp, "--"); + lv_obj_add_style(temp, &tempStyle, 0); + lv_obj_set_style_text_font(temp,lv_theme_get_font_normal(temp),0); + // lv_obj_set_style_text_color(temp,lv_color_hex(0xFF0000),0); + + lv_obj_t *img1 = lv_image_create(container); + lv_obj_add_style(img1, &no_padding, 0); + lv_obj_set_style_bg_color(img1, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4), 0); + lv_image_set_inner_align(img1, LV_IMAGE_ALIGN_TOP_LEFT); + lv_image_set_offset_y(img1, -8); + lv_image_set_offset_x(img1, -5); + lv_obj_set_size(img1, 40, 32); + lv_image_set_src(img1, LV_SYMBOL_DUMMY); + // lv_obj_set_style_border_width(img1,2,0); + // lv_obj_set_style_border_color(img1, lv_palette_main(LV_PALETTE_BLUE_GREY), 0); + lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0); + + lv_obj_t *desc = lv_label_create(container); + lv_label_set_text(desc, "--"); + lv_obj_set_style_text_font(desc, lv_theme_get_font_normal(desc), 0); + + // On positionne un observer sur le subjet correspondant a l'horaire du widget + ESP_LOGE(TAG, "on positionne obs sur horaire %d", ((struct weatherH_fragment_t *)self)->horaireNr); + lv_subject_add_observer_obj(tmpHSubj[((struct weatherH_fragment_t *)self)->horaireNr], weatherdataH_obs_cb, sup, NULL); + return container; +} + +// Fragment meteo horaire +const lv_fragment_class_t meteoHFragment = { + /* Initialize something needed */ + .constructor_cb = weatherH_fragment_ctor, + /* Create view objects */ + .create_obj_cb = weatherH_fragment_create_obj, + /* IMPORTANT: size of your fragment struct */ + .instance_size = sizeof(struct weatherH_fragment_t), +}; + +/* -------------------------------------------------------------- */ +/* Fragment 3 meteo "jour" (aujourd'hui, demain, apres demain) */ +/* -------------------------------------------------------------- */ +struct meteodailyforecast_fragment_t +{ + /* IMPORTANT: don't miss this part */ + lv_fragment_t base; + /* States, object references and data fields for this fragment */ + const char *title; + bool showDate; +}; + +static void meteodailyforecast_fragment_ctor(lv_fragment_t *self, void *args) +{ + struct meteodailyforecast_fragment_t *myself = ((struct meteodailyforecast_fragment_t *)self); + myself->showDate = args; +} + +static lv_obj_t *meteodailyforecast_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) +{ + + lv_fragment_manager_t *manager = lv_fragment_manager_create(NULL); + + int args[2] = {0, ((struct meteodailyforecast_fragment_t *)self)->showDate}; + lv_fragment_t *fragment = lv_fragment_create(&meteoFragment, args); + lv_fragment_manager_add(manager, fragment, &parent); + + args[0] = 1; + fragment = lv_fragment_create(&meteoFragment, args); + lv_fragment_manager_add(manager, fragment, &parent); + + args[0] = 2; + fragment = lv_fragment_create(&meteoFragment, args); + lv_fragment_manager_add(manager, fragment, &parent); + + return parent; +} + +const lv_fragment_class_t meteodailyforecast_cls = { + /* Initialize something needed */ + .constructor_cb = meteodailyforecast_fragment_ctor, + /* Create view objects */ + .create_obj_cb = meteodailyforecast_fragment_create_obj, + /* IMPORTANT: size of your fragment struct */ + .instance_size = sizeof(struct meteodailyforecast_fragment_t), +}; +/* -------------------------------------------------------------------------------- */ +/* Fragment 3 meteo "horaire" - matin/midi/soir (icone, temp moyenne) */ +/* -------------------------------------------------------------------------------- */ + +struct meteoforecast_fragment_t +{ + /* IMPORTANT: don't miss this part */ + lv_fragment_t base; + /* States, object references and data fields for this fragment */ + const char *title; + bool showDate; +}; + +static void meteoforecast_fragment_ctor(lv_fragment_t *self, void *args) +{ + struct meteoforecast_fragment_t *myself = ((struct meteoforecast_fragment_t *)self); + myself->showDate = args; +} + +static lv_obj_t *meteoforecast_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) +{ + + lv_fragment_manager_t *manager = lv_fragment_manager_create(NULL); + + // On affiche 3 fragment meteo. 1 pour chaque "horaire" + int args[2] = {0, ((struct meteoforecast_fragment_t *)self)->showDate}; + lv_fragment_t *fragment = lv_fragment_create(&meteoHFragment, args); + lv_fragment_manager_add(manager, fragment, &parent); + + args[0] = 1; + fragment = lv_fragment_create(&meteoHFragment, args); + lv_fragment_manager_add(manager, fragment, &parent); + + args[0] = 2; + fragment = lv_fragment_create(&meteoHFragment, args); + lv_fragment_manager_add(manager, fragment, &parent); + + return parent; +} + +const lv_fragment_class_t meteoforecast_cls = { + /* Initialize something needed */ + .constructor_cb = meteoforecast_fragment_ctor, + /* Create view objects */ + .create_obj_cb = meteoforecast_fragment_create_obj, + /* IMPORTANT: size of your fragment struct */ + .instance_size = sizeof(struct meteoforecast_fragment_t), +}; + +lv_obj_t *tab0; +lv_obj_t *tabVolets; +lv_obj_t *tabMeteo; +lv_obj_t *tabCuve; +lv_obj_t *tabSettings; +uint32_t oldTab; +lv_fragment_manager_t *manager2; +lv_fragment_t *fragment2; + +void tabChgEvt(lv_event_t *event) +{ + + uint32_t tabNr = lv_tabview_get_tab_active(event->user_data); + switch (oldTab) + { + case 1: + lv_obj_clean(tabVolets); + break; + case 2: + //lv_fragment_delete_obj(fragment2);; + //lv_fragment_manager_remove(manager2,fragment2); + ESP_LOGE(TAG, "On appelle lv_fragment_delete_obj sur l'onglet"); + lv_fragment_delete_obj(fragment2); + ESP_LOGE(TAG, "On appelle lv_fragment_manager_pop sur l'onglet"); + lv_fragment_manager_pop(manager2); + ESP_LOGE(TAG, "On appelle obj_clean sur l'onglet"); + lv_obj_clean(tabMeteo); + break; + case 3: + lv_obj_clean(tabCuve); + break; + + default: + break; + } + + oldTab = tabNr; + + printf("Tab change %lu\n", tabNr); + switch (tabNr) + { + case 1: + draw_tabVolets(); + break; + case 2: // Onglet Météo + draw_tabMeteo(); + break; + + case 3: // Onglet Cuve + draw_tabCuve(); + break; + + case 4: // Onglet Settings + draw_tabSettings(); + break; + + default: + break; + } +} + +void btnRestart_cb(lv_event_t * e){ + lv_event_code_t code = lv_event_get_code(e); + + if(code == LV_EVENT_CLICKED) { + esp_restart(); + } + +} + +static void log_event_handler(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * obj = lv_event_get_target(e); + if(code == LV_EVENT_VALUE_CHANGED) { + LV_UNUSED(obj); + char *tag=lv_event_get_user_data(e); + if(lv_obj_has_state(obj, LV_STATE_CHECKED)){ + esp_log_level_set(tag,ESP_LOG_DEBUG); + }else{ + esp_log_level_set(tag,ESP_LOG_INFO); + } + LV_LOG_USER("State for %s: %s\n", tag, lv_obj_has_state(obj, LV_STATE_CHECKED) ? "On" : "Off"); + } +} + +static lv_style_t style_lbvValue; +static lv_style_t style_btn; + +void draw_tabSettings() +{ + lv_obj_t *btnGrp = lv_obj_create(tabSettings); + lv_obj_set_height(btnGrp, 400); + lv_obj_set_flex_flow(btnGrp, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(btnGrp, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + + lv_obj_align(btnGrp,LV_ALIGN_BOTTOM_MID,0,0); + lv_obj_t *btnRestart = lv_button_create(btnGrp); + lv_obj_t *lblRestart = lv_label_create(btnRestart); + lv_label_set_text(lblRestart,"Restart"); + lv_obj_add_event_cb(btnRestart, btnRestart_cb, LV_EVENT_CLICKED, NULL); + + lv_label_set_text(lv_label_create(btnGrp),"Meteo Debug"); + lv_obj_t *sw = lv_switch_create(btnGrp); + lv_obj_add_state(sw, LV_STATE_DEFAULT); + lv_obj_add_event_cb(sw, log_event_handler, LV_EVENT_ALL, "MeteoFrance"); + + lv_label_set_text(lv_label_create(btnGrp),"Cuve"); + sw = lv_switch_create(btnGrp); + lv_obj_add_state(sw, LV_STATE_DEFAULT); + lv_obj_add_event_cb(sw, log_event_handler, LV_EVENT_ALL, "ImgDwn"); + + lv_label_set_text(lv_label_create(btnGrp),"MQTT"); + sw = lv_switch_create(btnGrp); + lv_obj_add_state(sw, LV_STATE_DEFAULT); + lv_obj_add_event_cb(sw, log_event_handler, LV_EVENT_ALL, "domo_mqtt"); + + +} + + +void draw_tabHome(){ + lv_obj_t *supmain = tab0; + lv_obj_set_flex_flow(supmain, LV_FLEX_FLOW_COLUMN); + + lv_obj_t *main = lv_obj_create(supmain); + lv_obj_add_style(main, &no_padding, 0); + lv_obj_set_size(main, lv_pct(100), lv_pct(100)); + + lv_obj_set_flex_flow(main, LV_FLEX_FLOW_ROW); + lv_obj_set_style_pad_column(main, 1, 0); + + /*Conteneur Colonne: Températures*/ + lv_obj_t *cont_colTemp = lv_obj_create(main); + lv_obj_set_style_pad_all(cont_colTemp, 5, 0); + lv_obj_set_size(cont_colTemp, lv_pct(40), lv_pct(100)); + lv_obj_align(cont_colTemp, LV_ALIGN_TOP_LEFT, 0, 0); + lv_obj_set_flex_flow(cont_colTemp, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(cont_colTemp, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + + /*Create a container with COLUMN flex direction*/ + lv_obj_t *cont_colVolets = lv_obj_create(main); + lv_obj_set_style_pad_all(cont_colVolets, 5, 0); + lv_obj_set_flex_align(cont_colVolets, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + lv_obj_set_size(cont_colVolets, lv_pct(20), lv_pct(100)); + lv_obj_align_to(cont_colVolets, cont_colTemp, LV_ALIGN_OUT_TOP_RIGHT, 0, 0); + lv_obj_set_flex_flow(cont_colVolets, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(cont_colVolets, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER); + + /*Conteneur Colonne: Meteo*/ + lv_obj_t *cont_col3 = lv_obj_create(main); + lv_obj_set_style_pad_all(cont_col3, 5, 0); + lv_obj_set_size(cont_col3, lv_pct(40), lv_pct(100)); + lv_obj_set_flex_flow(cont_col3, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(cont_col3, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + + + lv_obj_t *label1 = lv_label_create(cont_colTemp); + lv_obj_set_style_text_font(label1, lv_theme_get_font_small(label1), 0); + lv_label_set_text(label1, "Températures"); + lv_obj_set_pos(label1, 0, 0); + + //Create a container with COLUMN flex direction + lv_obj_t *cont_tempExt = lv_obj_create(cont_colTemp); + lv_obj_add_style(cont_tempExt, &style_container, 0); + // lv_obj_set_height(cont_tempExt,50); + lv_obj_set_flex_flow(cont_tempExt, LV_FLEX_FLOW_ROW); + lv_obj_t *lblExt = lv_label_create(cont_tempExt); + lv_label_set_text(lblExt, "ext."); + lv_obj_t *lblTempExt = lv_label_create(cont_tempExt); + + lv_obj_add_style(lblTempExt, &style_lbvValue, 0); + lv_label_set_text(lblTempExt, ""); + lv_label_bind_text(lblTempExt, &tempExtSubj, "%s °C"); + + //Create a container with COLUMN flex direction + lv_obj_t *cont_tempInt = lv_obj_create(cont_colTemp); + lv_obj_add_style(cont_tempInt, &style_container, 0); + // lv_obj_set_height(cont_tempInt,50); + lv_obj_set_flex_flow(cont_tempInt, LV_FLEX_FLOW_ROW); + lv_obj_t *lblInt = lv_label_create(cont_tempInt); + lv_label_set_text(lblInt, "int."); + lv_obj_t *lblTempInt = lv_label_create(cont_tempInt); + lv_obj_add_style(lblTempInt, &style_lbvValue, 0); + lv_label_set_text(lblTempInt, ""); + lv_label_bind_text(lblTempInt, &tempIntSubj, "%s °C"); + + //Create a container with COLUMN flex direction + lv_obj_t *cont_tempInt2 = lv_obj_create(cont_colTemp); + lv_obj_add_style(cont_tempInt2, &style_container, 0); + // lv_obj_set_height(cont_tempInt,50); + lv_obj_set_flex_flow(cont_tempInt2, LV_FLEX_FLOW_ROW); + lblInt = lv_label_create(cont_tempInt2); + lv_label_set_text(lblInt, "int."); + lblTempInt2 = lv_label_create(cont_tempInt2); + lv_obj_add_style(lblTempInt2, &style_lbvValue, 0); + lv_obj_set_style_text_font(lblTempInt2,lv_theme_get_font_large(lblTempInt2),0); + + lv_label_set_text(lblTempInt2, ""); + + //Create a container with COLUMN flex direction + lv_obj_t *cont_Cuve = lv_obj_create(cont_colTemp); + 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); + + lv_obj_t *lblHauteurEau = lv_label_create(cont_Cuve); + lv_label_set_text(lblHauteurEau, "Cuve: "); + lv_obj_t *lblHauteurCuve = lv_label_create(cont_Cuve); + lv_obj_add_style(lblHauteurCuve, &style_lbvValue, 0); + lv_label_bind_text(lblHauteurCuve, &hauteurCuveSubj, "%s cm"); + + lv_obj_t *btnUp = lv_button_create(cont_colVolets); + lv_obj_add_style(btnUp, &style_btn, 0); + lv_obj_add_event_cb(btnUp, event_handler, LV_EVENT_ALL, upEvent); + lv_obj_align(btnUp, LV_ALIGN_CENTER, 0, -40); + lv_obj_remove_flag(btnUp, LV_OBJ_FLAG_PRESS_LOCK); + lv_obj_t *label = lv_label_create(btnUp); + lv_obj_add_style(label, &style_lbvValue, 0); + lv_label_set_text(label, LV_SYMBOL_UP); + lv_obj_center(label); + + lv_obj_t *btnDwn = lv_button_create(cont_colVolets); + lv_obj_add_style(btnDwn, &style_btn, 0); + lv_obj_add_event_cb(btnDwn, event_handler, LV_EVENT_ALL, downEvent); + lv_obj_align(btnDwn, LV_ALIGN_CENTER, 0, -40); + lv_obj_remove_flag(btnDwn, LV_OBJ_FLAG_PRESS_LOCK); + label = lv_label_create(btnDwn); + lv_obj_add_style(label, &style_lbvValue, 0); + lv_label_set_text(label, LV_SYMBOL_DOWN); + lv_obj_center(label); + + lv_fragment_manager_t *manager = lv_fragment_manager_create(NULL); + lv_fragment_t *fragment = lv_fragment_create(&meteoforecast_cls, 0); + lv_fragment_manager_add(manager, fragment, &cont_col3); +} + +void draw_tabCuve() +{ + lv_obj_t *imgGraf = lv_image_create(tabCuve); + lv_image_set_src(imgGraf, "A:/sdcard/hello2.png"); +} + +void draw_tabMeteo() +{ + manager2 = lv_fragment_manager_create(NULL); + fragment2 = lv_fragment_create(&meteodailyforecast_cls, (void *)1); + lv_fragment_manager_add(manager2, fragment2, &tabMeteo); +} + +void draw_tabVolets() +{ + lv_obj_t *tabMeteo = lv_obj_create(tabVolets); + lv_obj_set_flex_flow(tabMeteo, LV_FLEX_FLOW_COLUMN); + lv_obj_add_style(tabMeteo, &no_padding, 0); + + lv_obj_set_size(tabMeteo, lv_pct(85), lv_pct(100)); + lv_obj_t *cont_rdc = lv_obj_create(tabMeteo); + lv_obj_set_size(cont_rdc, lv_pct(100), lv_pct(100)); + lv_obj_add_style(cont_rdc, &no_padding, 0); + lv_obj_add_style(tabMeteo, &no_padding, 0); + lv_point_t positions_rdc[] = { + {5, 105}, + {55, 45}, + {110, 20}, + {155, 25}, + {225, 45}, + {275, 115}, + {295, 185}}; + lv_obj_t *img = lv_image_create(cont_rdc); + lv_img_set_src(img, &plan_rdc); + float coef = 1.5; + for (size_t i = 1; i < 8; i++) + { + lv_obj_t *btnVolet = lv_checkbox_create(cont_rdc); + lv_obj_set_pos(btnVolet, positions_rdc[i - 1].x * coef, positions_rdc[i - 1].y * coef); + lv_obj_set_style_text_font(btnVolet,lv_theme_get_font_normal(btnVolet),0); + + // lv_obj_set_size(btnVolet,100,24); + + // char *nom[10]; + // sprintf(nom,"%d", i); + lv_checkbox_set_text(btnVolet, ""); + } + + lv_obj_t *cont_btn_volets = lv_obj_create(tabVolets); + lv_obj_add_style(cont_btn_volets, &no_padding, 0); + lv_obj_set_size(cont_btn_volets, lv_pct(15), lv_pct(100)); + + lv_obj_set_layout(cont_btn_volets, LV_LAYOUT_GRID); + static int32_t column_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; /*2 columns */ + static int32_t row_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; + lv_obj_set_grid_dsc_array(cont_btn_volets, column_dsc, row_dsc); + + lv_obj_t *btnUp_bis = lv_button_create(cont_btn_volets); + lv_obj_t *lblButtonUp = lv_label_create(btnUp_bis); + lv_label_set_text(lblButtonUp, LV_SYMBOL_UP); + + lv_obj_t *btnDwn_bis = lv_button_create(cont_btn_volets); + lv_obj_t *lblButtonDwn = lv_label_create(btnDwn_bis); + lv_label_set_text(lblButtonDwn, LV_SYMBOL_DOWN); + + lv_obj_set_grid_cell(btnUp_bis, LV_GRID_ALIGN_STRETCH, 0, 1, + LV_GRID_ALIGN_STRETCH, 0, 1); + lv_obj_set_grid_cell(btnDwn_bis, LV_GRID_ALIGN_STRETCH, 0, 1, + LV_GRID_ALIGN_STRETCH, 1, 1); + + lv_obj_t *cont_etage = lv_obj_create(tabMeteo); + lv_obj_set_size(cont_etage, lv_pct(100), lv_pct(100)); + lv_obj_add_style(cont_etage, &no_padding, 0); + + img = lv_image_create(cont_etage); + lv_img_set_src(img, &plan_etage); + + lv_point_t positions_etage[] = { + {100, 15}, + {250, 15}, + {400, 15}, + {480, 300}, + {460, 360}, + {320, 415}}; + for (size_t i = 1; i < 7; i++) + { + lv_obj_t *btnVolet = lv_checkbox_create(cont_etage); + lv_obj_set_pos(btnVolet, positions_etage[i - 1].x, positions_etage[i - 1].y); + lv_obj_set_style_text_font(btnVolet,lv_theme_get_font_large(btnVolet),0); + // lv_obj_set_size(btnVolet,100,24); + + // char *nom[10]; + // sprintf(nom,"%d", i); + lv_checkbox_set_text(btnVolet, ""); + } +} + +/* ------------------------------------------------------------ */ +/* Dessin IHM */ +/* ------------------------------------------------------------ */ +void draw_ihm() +{ + lv_subject_init_string(&tempExtSubj, tempExtStr, NULL, 6, "--"); + lv_subject_init_string(&tempIntSubj, tempIntStr, NULL, 6, "--"); + lv_subject_init_string(&hauteurCuveSubj, hauteurCuveStr, NULL, 9, "--"); + lv_subject_init_string(&hauteurCuveEvolSubj, hauteurCuveEvolStr, NULL, 9, "--"); + + struct meteodailyforecast_data d; + struct dailyforecast_prev p; + lv_strcpy(p.desc, ""); + d.previsions = p; + lv_subject_init_pointer(&forecastD1Subj, &d); + lv_subject_init_pointer(&forecastD2Subj, &d); + lv_subject_init_pointer(&forecastD3Subj, &d); + + struct meteoforecast_data d1; + struct forecast_prev p1; + lv_strcpy(p1.desc, ""); + + d1.previsions = p1; + lv_subject_init_pointer(&forecastH1Subj, &d1); + lv_subject_init_pointer(&forecastH2Subj, &d1); + lv_subject_init_pointer(&forecastH3Subj, &d1); + + // keys.clear(); + 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); + lv_obj_add_event_cb(tabview, tabChgEvt, LV_EVENT_VALUE_CHANGED, tabview); // Assign an event callback + // lv_obj_set_style_bg_color(tabview, lv_palette_lighten(LV_PALETTE_RED, 2), 0); + + lv_obj_t *tab_buttons = lv_tabview_get_tab_bar(tabview); + lv_obj_set_width(tab_buttons, 100); + lv_obj_set_style_text_font(tab_buttons, lv_theme_get_font_large(tab_buttons), 0); + lv_obj_set_style_bg_color(tab_buttons, lv_palette_darken(LV_PALETTE_GREY, 3), 0); + lv_obj_set_style_text_color(tab_buttons, lv_palette_lighten(LV_PALETTE_GREY, 5), 0); + lv_obj_set_style_border_side(tab_buttons, LV_BORDER_SIDE_RIGHT, LV_PART_ITEMS | LV_STATE_CHECKED); + + //Add 3 tabs (the tabs are page (lv_page) and can be scrolled + tab0 = lv_tabview_add_tab(tabview, LV_SYMBOL_HOME); + tabVolets = lv_tabview_add_tab(tabview, "Volets"); + tabMeteo = lv_tabview_add_tab(tabview, "Météo"); + tabCuve = lv_tabview_add_tab(tabview, "\xEF\x95\xB5" + "Cuve"); + tabSettings = lv_tabview_add_tab(tabview, "Settings"); + + // lv_obj_set_style_bg_color(tab2b, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0); + lv_obj_set_style_bg_opa(tabVolets, LV_OPA_COVER, 0); + + lv_style_init(&style_btn); + + // lv_style_set_bg_color(&style_btn, lv_color_hex(0x115588)); + // lv_style_set_bg_opa(&style_btn, LV_OPA_50); + // lv_style_set_border_width(&style_btn, 2); + // lv_style_set_border_color(&style_btn, lv_color_black()); + lv_style_set_width(&style_btn, 80); + lv_style_set_height(&style_btn, 100); + + // Un style pour les conteneurs (température, cuve ...) + lv_style_init(&style_container); + lv_style_set_pad_all(&style_container, 5); + // lv_style_set_height(&style_container,LV_SIZE_CONTENT); + lv_style_set_height(&style_container, 80); + lv_style_set_width(&style_container, lv_pct(80)); + lv_style_set_bg_color(&style_container, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4)); + lv_style_set_align(&style_container, LV_ALIGN_BOTTOM_LEFT); + lv_style_set_flex_cross_place(&style_container, LV_FLEX_ALIGN_END); + + static lv_style_t no_padding; + lv_style_init(&no_padding); + lv_style_set_pad_all(&no_padding, 0); + + lv_style_init(&style_lbvValue); + lv_style_set_text_font(&style_lbvValue, &lv_font_montserrat_40); + + draw_tabHome(); + + lv_obj_set_flex_flow(tabVolets, LV_FLEX_FLOW_ROW); + + lv_obj_set_flex_flow(tabMeteo, LV_FLEX_FLOW_COLUMN); + } + +void weather_data_retreived_start() +{ + //if (display_lock("weather_data_retreived_start")) + //{ + //ESP_LOGE(TAG,"Mutex obtenu dans weather_data_retreived_start"); + lv_subject_set_int(&meteoStatus, 1); + ESP_LOGE(TAG,"Subject setted weather_data_retreived_start"); + //display_unlock("weather_data_retreived_start"); + //}else{ + // ESP_LOGE(TAG,"Impossible d'obtenir le mutex dans weather_data_retreived_start"); + //} +} + +void weather_data_retreived(struct meteodailyforecast_data dailyDatas[3], struct meteoforecast_data datas[3]) +{ + +/* ESP_LOGE(TAG, "debut debug"); + printf("%lld\n", datas[0].datetime); + printf("%s\n", datas[0].previsions.desc); + printf("%f\n", datas[0].previsions.value); + printf("%lld\n", datas[1].datetime); + printf("%s\n", datas[1].previsions.desc); + printf("%f\n", datas[1].previsions.value); + printf("%lld\n", datas[2].datetime); + printf("%s\n", datas[2].previsions.desc); + printf("%f\n", datas[2].previsions.value); + ESP_LOGE(TAG, "fin debug"); +*/ + if (display_lock("weather_data_retreived")) + { + ESP_LOGV("MeteoFrance", "------------------------------------- Set des subjects J --------------------------------"); + // Prévisions des 3 prochains jours + lv_subject_set_pointer(&forecastD1Subj, &dailyDatas[0]); + lv_subject_set_pointer(&forecastD2Subj, &dailyDatas[1]); + lv_subject_set_pointer(&forecastD3Subj, &dailyDatas[2]); + + ESP_LOGV("MeteoFrance", "------------------------------------- Set des subjects H--------------------------------"); + // Prévisions des 3 prochains jours + ESP_LOGV("MeteoFrance", "Pointeur %lli", datas[0].datetime); + lv_subject_set_pointer(&forecastH1Subj, &datas[0]); + lv_subject_set_pointer(&forecastH2Subj, &datas[1]); + lv_subject_set_pointer(&forecastH3Subj, &datas[2]); + + lv_subject_set_int(&meteoStatus, 0); + display_unlock("weather_data_retreived"); + ESP_LOGV(TAG, "------------------------------------- Fin Set des subjects --------------------------------"); + }else{ + ESP_LOGE(TAG, "Impossible d'obtenir le mutex dans weather_data_retreived"); + } +} +void log_cb(lv_log_level_t level, const char * buf){ + ESP_LOGE(TAG, "%s",buf); +} + +void show_temp(char * tempHumid){ + +} diff --git a/main/ihm.h b/main/ihm.h new file mode 100644 index 0000000..77b9588 --- /dev/null +++ b/main/ihm.h @@ -0,0 +1,31 @@ +#pragma once +#include "meteofrance.h" +#include "esp_lvgl_port.h" +#include "bsp/esp-bsp.h" + +void app_main_display(void); + +bool display_lock(const char *TAG); + +void display_unlock(const char *TAG); + +void meteo_obs_cb(lv_observer_t *observer, lv_subject_t *subject); + +void showMeteoIcon(const char *icon, lv_obj_t *desc_icon, int childNr); + +void draw_tabVolets(); +void draw_ihm(); + +void weather_data_retreived_start(); + +void weather_data_retreived(meteodailyforecast_data dailyDatas[3], meteoforecast_data datas[3]); + +void draw_time(char * dateHeure); +void show_temp(char * tempHumid); +void draw_tabMeteo(); + +void tabChgEvt(lv_event_t *event); + +void draw_tabCuve(); +void draw_tabHome(); +void draw_tabSettings(); diff --git a/main/include/fmeteod.h b/main/include/fmeteod.h deleted file mode 100644 index 0138963..0000000 --- a/main/include/fmeteod.h +++ /dev/null @@ -1,83 +0,0 @@ -static void weatherdata_obs_cb(lv_observer_t *observer, lv_subject_t *subject) -{ - // Retrieve weatherdata - struct meteodailyforecast_data *data = subject->value.pointer; - //printffd(data); - char buff[40] = {}; - // sprintf(buff,"%s %.1f %.1f", data->previsions.desc, data->previsions.min, data->previsions.max); - - lv_obj_t *parent = (lv_obj_t *)(observer->target); - lv_obj_t *datefld = lv_obj_get_child(parent, 0); - lv_obj_t *desc_icon = lv_obj_get_child(parent, 1); - lv_obj_t *temps = lv_obj_get_child(parent, 2); - if (strcmp(data->previsions.icon, "p1j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p1j); - }else if (strcmp(data->previsions.icon, "p2j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p2j); - }else if (strcmp(data->previsions.icon, "p3j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p3j); - }else if (strcmp(data->previsions.icon, "p5bisj") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p5bisj); - }else if (strcmp(data->previsions.icon, "p12j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p12j); - }else if (strcmp(data->previsions.icon, "p12bisj") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p12bisj); - }else if (strcmp(data->previsions.icon, "p14j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p14j); - }else if (strcmp(data->previsions.icon, "p24j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p24j); - }else if (strcmp(data->previsions.icon, "p25j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p25j); - }else if (strcmp(data->previsions.icon, "p26j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p26j); - }else if (strcmp(data->previsions.icon, "p27j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p27j); - }else if (strcmp(data->previsions.icon, "p28j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p28j); - }else if (strcmp(data->previsions.icon, "p29j") == 0) - { - lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p29j); - }else{ - ESP_LOGE(TAG, "Image %s non connue",data->previsions.icon); - } - - char buffer[80]; - dtToString(data->datetime,buffer); - - lv_label_set_text(datefld, buffer); - lv_label_set_text(lv_obj_get_child(desc_icon, 1), data->previsions.desc); - lv_label_set_text_fmt(lv_obj_get_child(temps, 0), "%.1f°C", data->previsions.max); - lv_label_set_text_fmt(lv_obj_get_child(temps, 1), "%.1f°C", data->previsions.min); -} - -struct weatherDay_fragment_t -{ - /* IMPORTANT: don't miss this part */ - lv_fragment_t base; - /* States, object references and data fields for this fragment */ - int dayNr; - bool showTitle; - const char *title; - float minTemp; - float maxTemp; -}; -static void weatherDay_fragment_ctor(lv_fragment_t *self, void * args) -{ - int dayNo = ((int *)args)[0]; - bool showDate = ((int*)args)[1]; - ((struct weatherDay_fragment_t *)self)->dayNr = dayNo; - ((struct weatherDay_fragment_t *)self)->showTitle = showDate; - ESP_LOGI(TAG, "Fragment initialisé avec le jour n°%d - Afficher la date %d",dayNo, showDate); -} diff --git a/main/lv_theme_domotic.c b/main/lv_theme_domotic.c new file mode 100644 index 0000000..8e6367f --- /dev/null +++ b/main/lv_theme_domotic.c @@ -0,0 +1,177 @@ +/** + * @file lv_theme_simple.c + * + */ + +#define LV_USE_THEME_SIMPLE_DOMOTIC 1 +/********************* + * INCLUDES + *********************/ +#if LV_USE_THEME_SIMPLE_DOMOTIC +#include "lv_theme_domotic.h" +#include "esp_lvgl_port.h" +/********************* + * DEFINES + *********************/ +LV_FONT_DECLARE(montserrat_medium_12) +LV_FONT_DECLARE(montserrat_medium_18) +LV_FONT_DECLARE(montserrat_medium_24) + + +struct _my_theme_t; +typedef struct _my_theme_t my_theme_t; + +#define theme_def (*(my_theme_t **)(&LV_GLOBAL_DEFAULT()->theme_simple)) + +#define COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4) +#define COLOR_WHITE lv_color_white() +#define COLOR_LIGHT lv_palette_lighten(LV_PALETTE_GREY, 2) +#define COLOR_DARK lv_palette_main(LV_PALETTE_GREY) +#define COLOR_DIM lv_palette_darken(LV_PALETTE_GREY, 2) +#define SCROLLBAR_WIDTH 2 + +/********************** + * TYPEDEFS + **********************/ +typedef struct { + lv_style_t scr; + lv_style_t transp; + lv_style_t white; + lv_style_t light; + lv_style_t dark; + lv_style_t dim; + lv_style_t scrollbar; +#if LV_USE_ARC + lv_style_t arc_line; + lv_style_t arc_knob; +#endif +#if LV_USE_TEXTAREA + lv_style_t ta_cursor; +#endif +} my_theme_styles_t; + +struct _my_theme_t { + lv_theme_t base; + my_theme_styles_t styles; + bool inited; +}; + +/********************** + * STATIC PROTOTYPES + **********************/ +static void style_init_reset(lv_style_t * style); +static void theme_apply(lv_theme_t * th, lv_obj_t * obj); + +/********************** + * STATIC VARIABLES + **********************/ + +/********************** + * MACROS + **********************/ + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void style_init(my_theme_t * theme) +{ +} + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +bool lv_theme_domotic_is_inited(void) +{ + my_theme_t * theme = theme_def; + if(theme == NULL) return false; + return theme->inited; +} + +lv_theme_t * lv_theme_domotic_get(void) +{ + if(!lv_theme_domotic_is_inited()) { + return NULL; + } + + return (lv_theme_t *)theme_def; +} + +void lv_theme_domotic_deinit(void) +{ + my_theme_t * theme = theme_def; + if(theme) { + if(theme->inited) { + lv_style_t * theme_styles = (lv_style_t *)(&(theme->styles)); + uint32_t i; + for(i = 0; i < sizeof(my_theme_styles_t) / sizeof(lv_style_t); i++) { + lv_style_reset(theme_styles + i); + } + } + lv_free(theme_def); + theme_def = NULL; + } +} + +lv_theme_t * lv_theme_domotic_init(lv_display_t * disp) +{ + /*This trick is required only to avoid the garbage collection of + *styles' data if LVGL is used in a binding (e.g. MicroPython) + *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ + if(!lv_theme_domotic_is_inited()) { + theme_def = lv_malloc_zeroed(sizeof(my_theme_t)); + } + + my_theme_t * theme = theme_def; + + theme->base.disp = disp; + theme->base.font_small = &montserrat_medium_12; + theme->base.font_normal = &montserrat_medium_18; + theme->base.font_large = &montserrat_medium_24; + theme->base.apply_cb = theme_apply; + + lv_theme_t * th_act = lv_display_get_theme(NULL); + lv_theme_set_parent((lv_theme_t *)theme, th_act); + + style_init(theme); + + if(disp == NULL || lv_display_get_theme(disp) == (lv_theme_t *)theme) { + lv_obj_report_style_change(NULL); + } + + theme->inited = true; + + return (lv_theme_t *)theme_def; +} + +static void theme_apply(lv_theme_t * th, lv_obj_t * obj) +{ + LV_UNUSED(th); + + my_theme_t * theme = theme_def; + lv_obj_t * parent = lv_obj_get_parent(obj); + + if(parent == NULL) { + lv_obj_add_style(obj, &theme->styles.scr, 0); + lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR); + return; + } + +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +static void style_init_reset(lv_style_t * style) +{ + if(lv_theme_simple_is_inited()) { + lv_style_reset(style); + } + else { + lv_style_init(style); + } +} + +#endif diff --git a/main/lv_theme_domotic.h b/main/lv_theme_domotic.h new file mode 100644 index 0000000..cc2d387 --- /dev/null +++ b/main/lv_theme_domotic.h @@ -0,0 +1,62 @@ +/** + * @file lv_theme_domotic.h + * + */ + +#ifndef LV_THEME_domotic_DOMOTIC_H +#define LV_THEME_domotic_DOMOTIC_H + +#ifdef __cplusplus +extern "C" { +#endif + +/********************* + * INCLUDES + *********************/ +#include "esp_lvgl_port.h" + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/********************** + * GLOBAL PROTOTYPES + **********************/ + +/** + * Initialize the theme + * @param disp pointer to display to attach the theme + * @return a pointer to reference this theme later + */ +lv_theme_t * lv_theme_domotic_init(lv_display_t * disp); + +/** +* Check if the theme is initialized +* @return true if default theme is initialized, false otherwise +*/ +bool lv_theme_domotic_is_inited(void); + +/** + * Get domotic theme + * @return a pointer to domotic theme, or NULL if this is not initialized + */ +lv_theme_t * lv_theme_domotic_get(void); + +/** + * Deinitialize the domotic theme + */ +void lv_theme_domotic_deinit(void); + +/********************** + * MACROS + **********************/ + +#endif + +#ifdef __cplusplus +} /*extern "C"*/ +#endif diff --git a/main/main.c b/main/main.c index 10244fc..c59b0fa 100644 --- a/main/main.c +++ b/main/main.c @@ -1,39 +1,36 @@ -#include "misc/lv_types.h" +#include "meteofrance.h" + #include "freertos/FreeRTOS.h" #include "freertos/event_groups.h" #include "esp_err.h" #include "esp_log.h" #include "esp_check.h" #include "driver/i2c.h" -#include "esp_lcd_panel_io.h" -#include "esp_lcd_panel_ops.h" -#include "esp_lcd_panel_rgb.h" -#include "esp_lcd_touch_gt911.h" -#include "esp_lvgl_port.h" #include "esp_event.h" #include "nvs_flash.h" #include #include "esp_vfs_fat.h" #include "sdmmc_cmd.h" #include + #include "bsp/esp-bsp.h" -#include "bsp/display.h" -#include "bsp_board_extra.h" + +#include "main.h" +#include "ihm.h" // OTA #include "esp_ota_ops.h" #include "esp_http_client.h" #include "esp_https_ota.h" - // Includes personnels #include "wifi_logger.h" #include "obtain_time.h" -#include "meteofrance.h" #include "image_downloader.h" #include "wifi.h" #include "mqtt.h" + #include "am2302_rmt.h" // GPIO assignment @@ -49,1041 +46,12 @@ #define PIN_NUM_CLK 12 #define PIN_NUM_CS 10 -#include "main.h" -LV_FONT_DECLARE(montserrat_medium_12) -LV_FONT_DECLARE(montserrat_medium_18) -LV_FONT_DECLARE(montserrat_medium_24) static const char *TAG = "domoTic"; -extern char *upEvent; -extern char *downEvent; - -// LVGL image declare -LV_IMG_DECLARE(esp_logo) - -/* LCD IO and panel */ -static esp_lcd_panel_handle_t lcd_panel = NULL; -static esp_lcd_touch_handle_t touch_handle = NULL; - -/* LVGL display and touch */ -static lv_display_t *lvgl_disp = NULL; -static lv_indev_t *lvgl_touch_indev = NULL; - -lv_obj_t *chart; -lv_chart_series_t *ser1; - -lv_subject_t meteoStatus; -lv_subject_t dateHeureSubj; -char dateHeureStr[30]; - -static lv_style_t no_padding; -static lv_style_t style_font_18; -static lv_style_t style_font_24; - -bool display_lock(const char* TAG){ - ESP_LOGI(TAG,"Obtention mutexx"); - if(bsp_display_lock(5000)){ - ESP_LOGI(TAG, "Mutex obtenu"); - return true; - }else{ - ESP_LOGE(TAG, "Impossible d'obtenir le mutex"); - return false; - } -} -void display_unlock(const char* TAG){ - ESP_LOGI(TAG,"Libération mutexx"); - bsp_display_unlock(); -} - -struct lv_observer_t -{ - lv_subject_t *subject; /**< The observed value */ - lv_observer_cb_t cb; /**< Callback that should be called when the value changes*/ - void *target; /**< A target for the observer, e.g. a widget or style*/ - void *user_data; /**< Additional parameter supplied when subscribing*/ - uint32_t auto_free_user_data : 1; /**< Automatically free user data when the observer is removed */ - uint32_t notified : 1; /**< Mark if this observer was already notified*/ - uint32_t for_obj : 1; /**< `target` is an `lv_obj_t *`*/ -}; - -// Ce callback est applé lorsque meteoStatus change -static void meteo_obs_cb(lv_observer_t *observer, lv_subject_t *subject) -{ - ESP_LOGI(TAG, "On passe dans le callback de chgt de statut meteo; %li", lv_subject_get_int(subject)); - if (display_lock("meteo_obs_cb")) - { - lv_obj_t *meteoSt = observer->target; - switch (lv_subject_get_int(subject)) - { - case 0: - lv_obj_set_style_text_color(meteoSt, lv_color_make(0x00, 0xff, 0xff), 0); - break; - case 1: - lv_obj_set_style_text_color(meteoSt, lv_color_make(0xff, 0x00, 0x00), 0); - break; - } - display_unlock("meteo_obs_cb"); - }else{ - ESP_LOGE(TAG,"Impossible d'obtenir le mutex dans meteo_obs_cb"); - } -} - -static void app_main_display(void) -{ - - lv_subject_init_string(&dateHeureSubj, dateHeureStr, NULL, 64, "--"); - - lv_style_init(&no_padding); - lv_style_set_pad_all(&no_padding, 0); - - lv_style_init(&style_font_18); - lv_style_set_text_font(&style_font_18, &montserrat_medium_18); - - lv_obj_t *cont_status = lv_obj_create(lv_layer_top()); - lv_obj_add_style(cont_status, &no_padding, 0); - lv_obj_align(cont_status, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_set_flex_flow(cont_status, LV_FLEX_FLOW_ROW); - lv_obj_set_height(cont_status, LV_SIZE_CONTENT); - lv_obj_set_width(cont_status, LV_SIZE_CONTENT); - - lv_obj_t *jour = lv_label_create(cont_status); - lv_obj_add_style(jour, &style_font_18, 0); - lv_obj_set_width(jour, LV_SIZE_CONTENT); - lv_label_bind_text(jour, &dateHeureSubj, NULL); - - lv_obj_refr_size(cont_status); - // lv_obj_align(jour, LV_ALIGN_CENTER,0,0); - - lv_obj_t *meteoR = lv_label_create(cont_status); - lv_obj_add_style(meteoR, &style_font_18, 0); - lv_label_set_text(meteoR, "\xEF\x83\x82"); - lv_obj_set_style_text_color(meteoR, lv_color_make(0x00, 0xff, 0xff), 0); - lv_subject_add_observer_obj(&meteoStatus, meteo_obs_cb, meteoR, NULL); - - // lv_label_bind_text(meteoR, &meteoStatus, "Meteo %d"); - - lv_obj_t *wifi = lv_image_create(cont_status); - // lv_obj_set_style_bg_color(wifi, lv_palette_darken(LV_PALETTE_GREY, 3), 0); - // lv_obj_set_style_border_width(wifi,1,0); - // lv_obj_set_style_border_color(wifi,lv_palette_darken(LV_PALETTE_GREY, 3),0); - // lv_label_set_text(wifi,"Wifi Ok"); - // lv_label_bind_text(wifi, &wifiStatus, "Wifi %d"); - - lv_image_create(cont_status); - // lv_label_set_text(mqtt,"Mqtt Ok"); - // lv_label_bind_text(mqtt, &mqttStatus, "Mqtt %d"); - - lv_obj_t *scr = lv_scr_act(); - - /* Your LVGL objects code here .... */ - - /* Create image */ - lv_obj_t *img_logo = lv_img_create(scr); - lv_img_set_src(img_logo, &esp_logo); - lv_obj_align(img_logo, LV_ALIGN_TOP_MID, 0, 20); - /* Label */ - lv_obj_t *label = lv_label_create(scr); - lv_obj_set_width(label, lv_pct(100)); - lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0); - lv_label_set_text(label, LV_SYMBOL_BELL "Bienvenue sur DomoTIC !" LV_SYMBOL_BELL); - lv_obj_align(label, LV_ALIGN_CENTER, 0, 20); -} - -char tempExtStr[6]; -char tempIntStr[6]; -char hauteurCuveStr[9]; -char hauteurCuveEvolStr[9]; -lv_subject_t tempIntSubj; -lv_subject_t tempExtSubj; -lv_subject_t hauteurCuveSubj; -lv_subject_t hauteurCuveEvolSubj; -lv_subject_t forecastD1Subj; -lv_subject_t forecastD2Subj; -lv_subject_t forecastD3Subj; -lv_subject_t *tmpSubj[3] = {&forecastD1Subj, &forecastD2Subj, &forecastD3Subj}; -lv_subject_t forecastH1Subj; -lv_subject_t forecastH2Subj; -lv_subject_t forecastH3Subj; -lv_subject_t *tmpHSubj[3] = {&forecastH1Subj, &forecastH2Subj, &forecastH3Subj}; extern esp_mqtt_client_handle_t client; -static void event_handler(lv_event_t *e) -{ - lv_event_code_t code = lv_event_get_code(e); - // lv_obj_t *obj = (lv_obj_t *)lv_event_get_target(e); - char *evtData = (char *)lv_event_get_user_data(e); - - switch (code) - { - case LV_EVENT_PRESSED: - // LV_LOG_USER("%s was pressed\n", evtData); - break; - case LV_EVENT_CLICKED: - ESP_LOGI(TAG, "%s was clicked\n", evtData); - 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); - break; - case LV_EVENT_LONG_PRESSED_REPEAT: - LV_LOG_USER("%s was long press repeat\n", evtData); - break; - default: - break; - } -} -LV_IMAGE_DECLARE(plan_rdc); -LV_IMAGE_DECLARE(plan_etage); - -static lv_style_t style_container; -static lv_style_t style_font_12; - -// Callback pour mettre à jour une météo journaliere -// On pointe sur un tableau de meteodailyforecast_data -static void weatherdata_obs_cb(lv_observer_t *observer, lv_subject_t *subject) -{ - - ESP_LOGE(TAG, "CB meteo jour declenché"); - // Retrieve weatherdata - const struct meteodailyforecast_data *data = subject->value.pointer; - // printffd(data); - // char buff[40] = {}; - // sprintf(buff,"%s %.1f %.1f", data->previsions.desc, data->previsions.min, data->previsions.max); - - lv_obj_t *parent = (lv_obj_t *)(observer->target); - lv_obj_t *datefld = lv_obj_get_child(parent, 0); - lv_obj_t *desc_icon = lv_obj_get_child(parent, 1); - lv_obj_t *temps = lv_obj_get_child(parent, 2); - showMeteoIcon(data->previsions.icon, desc_icon, 0); - char buffer[80]; - dtToString(data->datetime, buffer); - - lv_label_set_text(datefld, buffer); - lv_label_set_text(lv_obj_get_child(desc_icon, 1), data->previsions.desc); - lv_label_set_text_fmt(lv_obj_get_child(temps, 0), "%.1f°C", data->previsions.max); - lv_label_set_text_fmt(lv_obj_get_child(temps, 1), "%.1f°C", data->previsions.min); -} - -// Callback pour mettre à jour une météo horaire -// On pointe sur un tableau de meteoforecast_data -static void weatherdataH_obs_cb(lv_observer_t *observer, lv_subject_t *subject) -{ - ESP_LOGV("MeteoFrance", "CB meteo horaire declenché"); - // Retrieve weatherdata - const struct meteoforecast_data *data = subject->value.pointer; - if(data->isValid){ - - //printffd(data); - char buff[40] = {}; - sprintf(buff,"%.1f", data->previsions.value); - ESP_LOGV(TAG, "On a recu [%s]", buff); - - lv_obj_t *parent = (lv_obj_t *)(observer->target); - lv_obj_t *datefld = lv_obj_get_child(parent, 0); - lv_obj_t *temp_desc_icon = lv_obj_get_child(parent, 1); - showMeteoIcon(data->previsions.icon, temp_desc_icon, 1); - - char buffer[80]; - dtHToString(data->datetime, buffer); - - lv_label_set_text(datefld, buffer); - lv_label_set_text(lv_obj_get_child(temp_desc_icon, 2), data->previsions.desc); - lv_label_set_text_fmt(lv_obj_get_child(temp_desc_icon, 0), "%.1f°C", data->previsions.value); - - }else{ - ESP_LOGE(TAG, "Pas de odnnées valides"); - } - -} - -void showMeteoIcon(const char *icon, lv_obj_t *desc_icon, int childNr) -{ - lv_obj_t *img = lv_obj_get_child(desc_icon, childNr); - char *str1 = "A:/littlefs/"; - char *result = malloc(strlen(str1) + strlen(icon) + 6); - sprintf(result, "%s%s.png", str1, icon); - lv_image_set_src(img, result); -} -/* ------------------------------------------------------------ */ -/* Fragment meteo journaliere (date,icone, min et max) */ -/* ------------------------------------------------------------ */ - -// Structure meteo journaliere -struct weatherDay_fragment_t -{ - /* IMPORTANT: don't miss this part */ - lv_fragment_t base; - /* States, object references and data fields for this fragment */ - int dayNr; - bool showTitle; - const char *title; - float minTemp; - float maxTemp; -}; - -// Constructeur meteo journaliere -static void weatherDay_fragment_ctor(lv_fragment_t *self, void *args) -{ - int dayNo = ((int *)args)[0]; - bool showDate = ((int *)args)[1]; - ((struct weatherDay_fragment_t *)self)->dayNr = dayNo; - ((struct weatherDay_fragment_t *)self)->showTitle = showDate; - ESP_LOGI(TAG, "Fragment initialisé avec le jour n°%d - Afficher la date %d", dayNo, showDate); -} - -// Ce fragment affiche une prévision journaliere (date,icone, min et max) -static lv_obj_t *weatherDay_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) -{ - - lv_obj_t *sup = lv_obj_create(parent); - - lv_obj_t *title = lv_label_create(sup); - lv_label_set_text(title, "--"); - - lv_obj_set_flex_flow(sup, LV_FLEX_FLOW_ROW); - lv_obj_add_style(sup, &style_container, 0); - lv_obj_set_size(sup, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - - lv_obj_t *container = lv_obj_create(sup); - lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - lv_obj_add_style(container, &no_padding, 0); - lv_obj_set_width(container, 150); - lv_obj_set_height(container, 80); - - lv_obj_t *img1 = lv_image_create(container); - lv_obj_add_style(img1, &no_padding, 0); - lv_obj_set_style_bg_color(img1, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4), 0); - lv_image_set_inner_align(img1, LV_IMAGE_ALIGN_TOP_LEFT); - lv_image_set_offset_y(img1, -8); - lv_image_set_offset_x(img1, -5); - lv_obj_set_size(img1, 40, 32); - lv_image_set_src(img1, LV_SYMBOL_DUMMY); - // lv_obj_set_style_border_width(img1,2,0); - // lv_obj_set_style_border_color(img1, lv_palette_main(LV_PALETTE_BLUE_GREY), 0); - lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *desc = lv_label_create(container); - lv_label_set_text(desc, "--"); - lv_obj_add_style(desc, &style_font_12, 0); - - lv_obj_t *container2 = lv_obj_create(sup); - lv_obj_set_width(container2, LV_SIZE_CONTENT); - lv_obj_set_height(container2, 80); - lv_obj_add_style(container2, &no_padding, 0); - lv_obj_set_style_pad_top(container2, 5, 0); - lv_obj_set_style_pad_bottom(container2, 5, 0); - lv_obj_set_flex_flow(container2, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container2, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); - - static lv_style_t tempStyle; - lv_style_init(&tempStyle); - // lv_style_set_text_font(&tempStyle,¬omedium16); - - lv_obj_t *max = lv_label_create(container2); - lv_label_set_text(max, "--"); - lv_obj_add_style(max, &tempStyle, 0); - lv_obj_add_style(max, &style_font_18, 0); - lv_obj_set_style_text_color(max, lv_color_hex(0xFF0000), 0); - lv_obj_add_style(max, &style_font_18, 0); - - lv_obj_t *min = lv_label_create(container2); - lv_label_set_text(min, "--"); - lv_obj_add_style(min, &tempStyle, 0); - lv_obj_add_style(min, &style_font_18, 0); - lv_obj_set_style_text_color(min, lv_color_hex(0x3000FF), 0); - lv_obj_add_style(min, &style_font_18, 0); - - // On positionne un observer sur le subjet correspondant au jour du widget - lv_subject_add_observer_obj(tmpSubj[((struct weatherDay_fragment_t *)self)->dayNr], weatherdata_obs_cb, sup, NULL); - return container; -} - -// Fragment meteo journaliere -const lv_fragment_class_t meteoFragment = { - /* Initialize something needed */ - .constructor_cb = weatherDay_fragment_ctor, - /* Create view objects */ - .create_obj_cb = weatherDay_fragment_create_obj, - /* IMPORTANT: size of your fragment struct */ - .instance_size = sizeof(struct weatherDay_fragment_t), -}; - -/* ------------------------------------------------------------ */ -/* Fragment meteo horaire ("heure",icone, temp) */ -/* ------------------------------------------------------------ */ - -// Structure meteo horaire -struct weatherH_fragment_t -{ - /* IMPORTANT: don't miss this part */ - lv_fragment_t base; - /* States, object references and data fields for this fragment */ - int horaireNr; - bool showTitle; - const char *horaire; - float temp; -}; - -// Constructeur meteo horaire -static void weatherH_fragment_ctor(lv_fragment_t *self, void *args) -{ - // Represente le n° (index dans le tableau) a afficher - int horaireNr = ((int *)args)[0]; - bool showDate = ((int *)args)[1]; - ((struct weatherH_fragment_t *)self)->horaireNr = horaireNr; - ((struct weatherH_fragment_t *)self)->showTitle = showDate; - ESP_LOGI(TAG, "Fragment initialisé avec l'horaire %d", horaireNr); -} - -// Ce fragment affiche une prévision horaire (date,icone, temp moyenne) -static lv_obj_t *weatherH_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) -{ - - lv_obj_t *sup = lv_obj_create(parent); - - lv_obj_t *title = lv_label_create(sup); - lv_label_set_text(title, "--"); - - lv_obj_set_flex_flow(sup, LV_FLEX_FLOW_ROW); - lv_obj_add_style(sup, &style_container, 0); - lv_obj_set_size(sup, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - - lv_obj_t *container = lv_obj_create(sup); - lv_obj_set_flex_flow(container, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - lv_obj_add_style(container, &no_padding, 0); - lv_obj_set_width(container, 150); - lv_obj_set_height(container, LV_SIZE_CONTENT); - - static lv_style_t tempStyle; - lv_style_init(&tempStyle); - // lv_style_set_text_font(&tempStyle,¬omedium16); - - lv_obj_t *temp = lv_label_create(container); - lv_label_set_text(temp, "--"); - lv_obj_add_style(temp, &tempStyle, 0); - lv_obj_add_style(temp, &style_font_18, 0); - // lv_obj_set_style_text_color(temp,lv_color_hex(0xFF0000),0); - lv_obj_add_style(temp, &style_font_18, 0); - - lv_obj_t *img1 = lv_image_create(container); - lv_obj_add_style(img1, &no_padding, 0); - lv_obj_set_style_bg_color(img1, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4), 0); - lv_image_set_inner_align(img1, LV_IMAGE_ALIGN_TOP_LEFT); - lv_image_set_offset_y(img1, -8); - lv_image_set_offset_x(img1, -5); - lv_obj_set_size(img1, 40, 32); - lv_image_set_src(img1, LV_SYMBOL_DUMMY); - // lv_obj_set_style_border_width(img1,2,0); - // lv_obj_set_style_border_color(img1, lv_palette_main(LV_PALETTE_BLUE_GREY), 0); - lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0); - - lv_obj_t *desc = lv_label_create(container); - lv_label_set_text(desc, "--"); - lv_obj_add_style(desc, &style_font_12, 0); - - // On positionne un observer sur le subjet correspondant a l'horaire du widget - ESP_LOGE(TAG, "on positionne obs sur horaire %d", ((struct weatherH_fragment_t *)self)->horaireNr); - lv_subject_add_observer_obj(tmpHSubj[((struct weatherH_fragment_t *)self)->horaireNr], weatherdataH_obs_cb, sup, NULL); - return container; -} - -// Fragment meteo horaire -const lv_fragment_class_t meteoHFragment = { - /* Initialize something needed */ - .constructor_cb = weatherH_fragment_ctor, - /* Create view objects */ - .create_obj_cb = weatherH_fragment_create_obj, - /* IMPORTANT: size of your fragment struct */ - .instance_size = sizeof(struct weatherH_fragment_t), -}; - -/* -------------------------------------------------------------- */ -/* Fragment 3 meteo "jour" (aujourd'hui, demain, apres demain) */ -/* -------------------------------------------------------------- */ -struct meteodailyforecast_fragment_t -{ - /* IMPORTANT: don't miss this part */ - lv_fragment_t base; - /* States, object references and data fields for this fragment */ - const char *title; - bool showDate; -}; - -static void meteodailyforecast_fragment_ctor(lv_fragment_t *self, void *args) -{ - struct meteodailyforecast_fragment_t *myself = ((struct meteodailyforecast_fragment_t *)self); - myself->showDate = args; -} - -static lv_obj_t *meteodailyforecast_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) -{ - - lv_fragment_manager_t *manager = lv_fragment_manager_create(NULL); - - int args[2] = {0, ((struct meteodailyforecast_fragment_t *)self)->showDate}; - lv_fragment_t *fragment = lv_fragment_create(&meteoFragment, args); - lv_fragment_manager_add(manager, fragment, &parent); - - args[0] = 1; - fragment = lv_fragment_create(&meteoFragment, args); - lv_fragment_manager_add(manager, fragment, &parent); - - args[0] = 2; - fragment = lv_fragment_create(&meteoFragment, args); - lv_fragment_manager_add(manager, fragment, &parent); - - return parent; -} - -const lv_fragment_class_t meteodailyforecast_cls = { - /* Initialize something needed */ - .constructor_cb = meteodailyforecast_fragment_ctor, - /* Create view objects */ - .create_obj_cb = meteodailyforecast_fragment_create_obj, - /* IMPORTANT: size of your fragment struct */ - .instance_size = sizeof(struct meteodailyforecast_fragment_t), -}; -/* -------------------------------------------------------------------------------- */ -/* Fragment 3 meteo "horaire" - matin/midi/soir (icone, temp moyenne) */ -/* -------------------------------------------------------------------------------- */ - -struct meteoforecast_fragment_t -{ - /* IMPORTANT: don't miss this part */ - lv_fragment_t base; - /* States, object references and data fields for this fragment */ - const char *title; - bool showDate; -}; - -static void meteoforecast_fragment_ctor(lv_fragment_t *self, void *args) -{ - struct meteoforecast_fragment_t *myself = ((struct meteoforecast_fragment_t *)self); - myself->showDate = args; -} - -static lv_obj_t *meteoforecast_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent) -{ - - lv_fragment_manager_t *manager = lv_fragment_manager_create(NULL); - - // On affiche 3 fragment meteo. 1 pour chaque "horaire" - int args[2] = {0, ((struct meteoforecast_fragment_t *)self)->showDate}; - lv_fragment_t *fragment = lv_fragment_create(&meteoHFragment, args); - lv_fragment_manager_add(manager, fragment, &parent); - - args[0] = 1; - fragment = lv_fragment_create(&meteoHFragment, args); - lv_fragment_manager_add(manager, fragment, &parent); - - args[0] = 2; - fragment = lv_fragment_create(&meteoHFragment, args); - lv_fragment_manager_add(manager, fragment, &parent); - - return parent; -} - -const lv_fragment_class_t meteoforecast_cls = { - /* Initialize something needed */ - .constructor_cb = meteoforecast_fragment_ctor, - /* Create view objects */ - .create_obj_cb = meteoforecast_fragment_create_obj, - /* IMPORTANT: size of your fragment struct */ - .instance_size = sizeof(struct meteoforecast_fragment_t), -}; - -struct lv_event_t -{ - void *current_target; - void *original_target; - lv_event_code_t code; - void *user_data; - void *param; - lv_event_t *prev; - uint8_t deleted : 1; - uint8_t stop_processing : 1; - uint8_t stop_bubbling : 1; -}; - -lv_obj_t *tab0; -lv_obj_t *tabVolets; -lv_obj_t *tabMeteo; -lv_obj_t *tabCuve; -lv_obj_t *tabSettings; -uint32_t oldTab; -lv_fragment_manager_t *manager2; -lv_fragment_t *fragment2; - -static void tabChgEvt(lv_event_t *event) -{ - - uint32_t tabNr = lv_tabview_get_tab_active(event->user_data); - switch (oldTab) - { - case 1: - lv_obj_clean(tabVolets); - break; - case 2: - // lv_fragment_delete_obj(fragment2);; - // lv_fragment_manager_delete(manager2); - // lv_obj_clean(tab3); - break; - case 3: - lv_obj_clean(tabCuve); - break; - - default: - break; - } - - oldTab = tabNr; - - printf("Tab change %lu\n", tabNr); - switch (tabNr) - { - case 1: - draw_tabVolets(); - break; - case 2: // Onglet Météo - draw_tabMeteo(); - break; - - case 3: // Onglet Cuve - draw_tabCuve(); - break; - - case 4: // Onglet Settings - draw_tabSettings(); - break; - - default: - break; - } -} - -void btnRestart_cb(lv_event_t * e){ - lv_event_code_t code = lv_event_get_code(e); - - if(code == LV_EVENT_CLICKED) { - esp_restart(); - } - -} - -static void log_event_handler(lv_event_t * e) -{ - lv_event_code_t code = lv_event_get_code(e); - lv_obj_t * obj = lv_event_get_target(e); - if(code == LV_EVENT_VALUE_CHANGED) { - LV_UNUSED(obj); - char *tag=lv_event_get_user_data(e); - if(lv_obj_has_state(obj, LV_STATE_CHECKED)){ - esp_log_level_set(tag,ESP_LOG_DEBUG); - }else{ - esp_log_level_set(tag,ESP_LOG_INFO); - } - LV_LOG_USER("State for %s: %s\n", tag, lv_obj_has_state(obj, LV_STATE_CHECKED) ? "On" : "Off"); - } -} - -static lv_style_t style_lbvValue; -static lv_style_t style_btn; - -void draw_tabSettings() -{ - lv_obj_t *btnGrp = lv_obj_create(tabSettings); - lv_obj_set_height(btnGrp, 400); - lv_obj_set_flex_flow(btnGrp, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(btnGrp, LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - - lv_obj_align(btnGrp,LV_ALIGN_BOTTOM_MID,0,0); - lv_obj_t *btnRestart = lv_button_create(btnGrp); - lv_obj_t *lblRestart = lv_label_create(btnRestart); - lv_label_set_text(lblRestart,"Restart"); - lv_obj_add_event_cb(btnRestart, btnRestart_cb, LV_EVENT_CLICKED, NULL); - - lv_label_set_text(lv_label_create(btnGrp),"Meteo Debug"); - lv_obj_t *sw = lv_switch_create(btnGrp); - lv_obj_add_state(sw, LV_STATE_DEFAULT); - lv_obj_add_event_cb(sw, log_event_handler, LV_EVENT_ALL, "MeteoFrance"); - - lv_label_set_text(lv_label_create(btnGrp),"Cuve"); - sw = lv_switch_create(btnGrp); - lv_obj_add_state(sw, LV_STATE_DEFAULT); - lv_obj_add_event_cb(sw, log_event_handler, LV_EVENT_ALL, "ImgDwn"); - - lv_label_set_text(lv_label_create(btnGrp),"MQTT"); - sw = lv_switch_create(btnGrp); - lv_obj_add_state(sw, LV_STATE_DEFAULT); - lv_obj_add_event_cb(sw, log_event_handler, LV_EVENT_ALL, "domo_mqtt"); - - -} - -lv_obj_t *lblTempInt2; - -void draw_tabHome(){ - lv_obj_t *supmain = tab0; - lv_obj_set_flex_flow(supmain, LV_FLEX_FLOW_COLUMN); - - lv_obj_t *main = lv_obj_create(supmain); - lv_obj_add_style(main, &no_padding, 0); - lv_obj_set_size(main, lv_pct(100), lv_pct(100)); - - lv_obj_set_flex_flow(main, LV_FLEX_FLOW_ROW); - lv_obj_set_style_pad_column(main, 1, 0); - - /*Conteneur Colonne: Températures*/ - lv_obj_t *cont_colTemp = lv_obj_create(main); - lv_obj_set_style_pad_all(cont_colTemp, 5, 0); - lv_obj_set_size(cont_colTemp, lv_pct(40), lv_pct(100)); - lv_obj_align(cont_colTemp, LV_ALIGN_TOP_LEFT, 0, 0); - lv_obj_set_flex_flow(cont_colTemp, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(cont_colTemp, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - - /*Create a container with COLUMN flex direction*/ - lv_obj_t *cont_colVolets = lv_obj_create(main); - lv_obj_set_style_pad_all(cont_colVolets, 5, 0); - lv_obj_set_flex_align(cont_colVolets, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - lv_obj_set_size(cont_colVolets, lv_pct(20), lv_pct(100)); - lv_obj_align_to(cont_colVolets, cont_colTemp, LV_ALIGN_OUT_TOP_RIGHT, 0, 0); - lv_obj_set_flex_flow(cont_colVolets, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(cont_colVolets, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_BETWEEN, LV_FLEX_ALIGN_CENTER); - - /*Conteneur Colonne: Meteo*/ - lv_obj_t *cont_col3 = lv_obj_create(main); - lv_obj_set_style_pad_all(cont_col3, 5, 0); - lv_obj_set_size(cont_col3, lv_pct(40), lv_pct(100)); - lv_obj_set_flex_flow(cont_col3, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(cont_col3, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - - - lv_obj_t *label1 = lv_label_create(cont_colTemp); - lv_obj_set_style_text_font(label1, &montserrat_medium_18, 0); - lv_label_set_text(label1, "Températures"); - lv_obj_set_pos(label1, 0, 0); - - //Create a container with COLUMN flex direction - lv_obj_t *cont_tempExt = lv_obj_create(cont_colTemp); - lv_obj_add_style(cont_tempExt, &style_container, 0); - // lv_obj_set_height(cont_tempExt,50); - lv_obj_set_flex_flow(cont_tempExt, LV_FLEX_FLOW_ROW); - lv_obj_t *lblExt = lv_label_create(cont_tempExt); - lv_label_set_text(lblExt, "ext."); - lv_obj_t *lblTempExt = lv_label_create(cont_tempExt); - - lv_obj_add_style(lblTempExt, &style_lbvValue, 0); - lv_label_set_text(lblTempExt, ""); - lv_label_bind_text(lblTempExt, &tempExtSubj, "%s °C"); - - //Create a container with COLUMN flex direction - lv_obj_t *cont_tempInt = lv_obj_create(cont_colTemp); - lv_obj_add_style(cont_tempInt, &style_container, 0); - // lv_obj_set_height(cont_tempInt,50); - lv_obj_set_flex_flow(cont_tempInt, LV_FLEX_FLOW_ROW); - lv_obj_t *lblInt = lv_label_create(cont_tempInt); - lv_label_set_text(lblInt, "int."); - lv_obj_t *lblTempInt = lv_label_create(cont_tempInt); - lv_obj_add_style(lblTempInt, &style_lbvValue, 0); - lv_label_set_text(lblTempInt, ""); - lv_label_bind_text(lblTempInt, &tempIntSubj, "%s °C"); - - //Create a container with COLUMN flex direction - lv_obj_t *cont_tempInt2 = lv_obj_create(cont_colTemp); - lv_obj_add_style(cont_tempInt2, &style_container, 0); - // lv_obj_set_height(cont_tempInt,50); - lv_obj_set_flex_flow(cont_tempInt2, LV_FLEX_FLOW_ROW); - lblInt = lv_label_create(cont_tempInt2); - lv_label_set_text(lblInt, "int."); - lblTempInt2 = lv_label_create(cont_tempInt2); - lv_obj_add_style(lblTempInt2, &style_lbvValue, 0); - lv_obj_set_style_text_font(lblTempInt2,&montserrat_medium_24,0); - - lv_label_set_text(lblTempInt2, ""); - - //Create a container with COLUMN flex direction - lv_obj_t *cont_Cuve = lv_obj_create(cont_colTemp); - 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); - - lv_obj_t *lblHauteurEau = lv_label_create(cont_Cuve); - lv_label_set_text(lblHauteurEau, "Cuve: "); - lv_obj_t *lblHauteurCuve = lv_label_create(cont_Cuve); - lv_obj_add_style(lblHauteurCuve, &style_lbvValue, 0); - lv_label_bind_text(lblHauteurCuve, &hauteurCuveSubj, "%s cm"); - - lv_obj_t *btnUp = lv_button_create(cont_colVolets); - lv_obj_add_style(btnUp, &style_btn, 0); - lv_obj_add_event_cb(btnUp, event_handler, LV_EVENT_ALL, upEvent); - lv_obj_align(btnUp, LV_ALIGN_CENTER, 0, -40); - lv_obj_remove_flag(btnUp, LV_OBJ_FLAG_PRESS_LOCK); - lv_obj_t *label = lv_label_create(btnUp); - lv_obj_add_style(label, &style_lbvValue, 0); - lv_label_set_text(label, LV_SYMBOL_UP); - lv_obj_center(label); - - lv_obj_t *btnDwn = lv_button_create(cont_colVolets); - lv_obj_add_style(btnDwn, &style_btn, 0); - lv_obj_add_event_cb(btnDwn, event_handler, LV_EVENT_ALL, downEvent); - lv_obj_align(btnDwn, LV_ALIGN_CENTER, 0, -40); - lv_obj_remove_flag(btnDwn, LV_OBJ_FLAG_PRESS_LOCK); - label = lv_label_create(btnDwn); - lv_obj_add_style(label, &style_lbvValue, 0); - lv_label_set_text(label, LV_SYMBOL_DOWN); - lv_obj_center(label); - - lv_fragment_manager_t *manager = lv_fragment_manager_create(NULL); - lv_fragment_t *fragment = lv_fragment_create(&meteoforecast_cls, 0); - lv_fragment_manager_add(manager, fragment, &cont_col3); -} - -void draw_tabCuve() -{ - lv_obj_t *imgGraf = lv_image_create(tabCuve); - lv_image_set_src(imgGraf, "A:/sdcard/hello2.png"); -} - -void draw_tabMeteo() -{ - manager2 = lv_fragment_manager_create(NULL); - fragment2 = lv_fragment_create(&meteodailyforecast_cls, (void *)1); - lv_fragment_manager_add(manager2, fragment2, &tabCuve); -} - -void draw_tabVolets() -{ - lv_obj_t *tabMeteo = lv_obj_create(tabVolets); - lv_obj_set_flex_flow(tabMeteo, LV_FLEX_FLOW_COLUMN); - lv_obj_add_style(tabMeteo, &no_padding, 0); - - lv_obj_set_size(tabMeteo, lv_pct(85), lv_pct(100)); - lv_obj_t *cont_rdc = lv_obj_create(tabMeteo); - lv_obj_set_size(cont_rdc, lv_pct(100), lv_pct(100)); - lv_obj_add_style(cont_rdc, &no_padding, 0); - lv_obj_add_style(tabMeteo, &no_padding, 0); - lv_point_t positions_rdc[] = { - {5, 105}, - {55, 45}, - {110, 20}, - {155, 25}, - {225, 45}, - {275, 115}, - {295, 185}}; - lv_obj_t *img = lv_image_create(cont_rdc); - lv_img_set_src(img, &plan_rdc); - float coef = 1.5; - for (size_t i = 1; i < 8; i++) - { - lv_obj_t *btnVolet = lv_checkbox_create(cont_rdc); - lv_obj_set_pos(btnVolet, positions_rdc[i - 1].x * coef, positions_rdc[i - 1].y * coef); - lv_obj_add_style(btnVolet, &style_font_24, 0); - // lv_obj_set_size(btnVolet,100,24); - - // char *nom[10]; - // sprintf(nom,"%d", i); - lv_checkbox_set_text(btnVolet, ""); - } - - lv_obj_t *cont_btn_volets = lv_obj_create(tabVolets); - lv_obj_add_style(cont_btn_volets, &no_padding, 0); - lv_obj_set_size(cont_btn_volets, lv_pct(15), lv_pct(100)); - - lv_obj_set_layout(cont_btn_volets, LV_LAYOUT_GRID); - static int32_t column_dsc[] = {LV_GRID_CONTENT, LV_GRID_TEMPLATE_LAST}; /*2 columns */ - static int32_t row_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST}; - lv_obj_set_grid_dsc_array(cont_btn_volets, column_dsc, row_dsc); - - lv_obj_t *btnUp_bis = lv_button_create(cont_btn_volets); - lv_obj_t *lblButtonUp = lv_label_create(btnUp_bis); - lv_label_set_text(lblButtonUp, LV_SYMBOL_UP); - - lv_obj_t *btnDwn_bis = lv_button_create(cont_btn_volets); - lv_obj_t *lblButtonDwn = lv_label_create(btnDwn_bis); - lv_label_set_text(lblButtonDwn, LV_SYMBOL_DOWN); - - lv_obj_set_grid_cell(btnUp_bis, LV_GRID_ALIGN_STRETCH, 0, 1, - LV_GRID_ALIGN_STRETCH, 0, 1); - lv_obj_set_grid_cell(btnDwn_bis, LV_GRID_ALIGN_STRETCH, 0, 1, - LV_GRID_ALIGN_STRETCH, 1, 1); - - lv_obj_t *cont_etage = lv_obj_create(tabMeteo); - lv_obj_set_size(cont_etage, lv_pct(100), lv_pct(100)); - lv_obj_add_style(cont_etage, &no_padding, 0); - - img = lv_image_create(cont_etage); - lv_img_set_src(img, &plan_etage); - - lv_point_t positions_etage[] = { - {100, 15}, - {250, 15}, - {400, 15}, - {480, 300}, - {460, 360}, - {320, 415}}; - for (size_t i = 1; i < 7; i++) - { - lv_obj_t *btnVolet = lv_checkbox_create(cont_etage); - lv_obj_set_pos(btnVolet, positions_etage[i - 1].x, positions_etage[i - 1].y); - lv_obj_add_style(btnVolet, &style_font_24, 0); - // lv_obj_set_size(btnVolet,100,24); - - // char *nom[10]; - // sprintf(nom,"%d", i); - lv_checkbox_set_text(btnVolet, ""); - } -} - -/* ------------------------------------------------------------ */ -/* Dessin IHM */ -/* ------------------------------------------------------------ */ -void draw_ihm() -{ - lv_subject_init_string(&tempExtSubj, tempExtStr, NULL, 6, "--"); - lv_subject_init_string(&tempIntSubj, tempIntStr, NULL, 6, "--"); - lv_subject_init_string(&hauteurCuveSubj, hauteurCuveStr, NULL, 9, "--"); - lv_subject_init_string(&hauteurCuveEvolSubj, hauteurCuveEvolStr, NULL, 9, "--"); - - struct meteodailyforecast_data d; - struct dailyforecast_prev p; - lv_strcpy(p.desc, ""); - d.previsions = p; - lv_subject_init_pointer(&forecastD1Subj, &d); - lv_subject_init_pointer(&forecastD2Subj, &d); - lv_subject_init_pointer(&forecastD3Subj, &d); - - struct meteoforecast_data d1; - struct forecast_prev p1; - lv_strcpy(p1.desc, ""); - - d1.previsions = p1; - lv_subject_init_pointer(&forecastH1Subj, &d1); - lv_subject_init_pointer(&forecastH2Subj, &d1); - lv_subject_init_pointer(&forecastH3Subj, &d1); - - // keys.clear(); - 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); - lv_obj_add_event_cb(tabview, tabChgEvt, LV_EVENT_VALUE_CHANGED, tabview); // Assign an event callback - // lv_obj_set_style_bg_color(tabview, lv_palette_lighten(LV_PALETTE_RED, 2), 0); - - lv_obj_t *tab_buttons = lv_tabview_get_tab_bar(tabview); - lv_obj_set_width(tab_buttons, 100); - lv_obj_set_style_text_font(tab_buttons, &montserrat_medium_24, 0); - lv_obj_set_style_bg_color(tab_buttons, lv_palette_darken(LV_PALETTE_GREY, 3), 0); - lv_obj_set_style_text_color(tab_buttons, lv_palette_lighten(LV_PALETTE_GREY, 5), 0); - lv_obj_set_style_border_side(tab_buttons, LV_BORDER_SIDE_RIGHT, LV_PART_ITEMS | LV_STATE_CHECKED); - - //Add 3 tabs (the tabs are page (lv_page) and can be scrolled - tab0 = lv_tabview_add_tab(tabview, LV_SYMBOL_HOME); - tabVolets = lv_tabview_add_tab(tabview, "Volets"); - tabMeteo = lv_tabview_add_tab(tabview, "Météo"); - tabCuve = lv_tabview_add_tab(tabview, "\xEF\x95\xB5" - "Cuve"); - tabSettings = lv_tabview_add_tab(tabview, "Settings"); - - // lv_obj_set_style_bg_color(tab2b, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0); - lv_obj_set_style_bg_opa(tabVolets, LV_OPA_COVER, 0); - - lv_style_init(&style_btn); - - lv_style_init(&style_font_24); - lv_style_set_text_font(&style_font_24, &montserrat_medium_24); - - lv_style_init(&style_font_12); - lv_style_set_text_font(&style_font_12, &montserrat_medium_18); - - // lv_style_set_bg_color(&style_btn, lv_color_hex(0x115588)); - // lv_style_set_bg_opa(&style_btn, LV_OPA_50); - // lv_style_set_border_width(&style_btn, 2); - // lv_style_set_border_color(&style_btn, lv_color_black()); - lv_style_set_width(&style_btn, 80); - lv_style_set_height(&style_btn, 100); - - // Un style pour les conteneurs (température, cuve ...) - lv_style_init(&style_container); - lv_style_set_pad_all(&style_container, 5); - // lv_style_set_height(&style_container,LV_SIZE_CONTENT); - lv_style_set_height(&style_container, 80); - lv_style_set_width(&style_container, 200); - lv_style_set_bg_color(&style_container, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4)); - lv_style_set_align(&style_container, LV_ALIGN_BOTTOM_LEFT); - lv_style_set_flex_cross_place(&style_container, LV_FLEX_ALIGN_END); - - static lv_style_t no_padding; - lv_style_init(&no_padding); - lv_style_set_pad_all(&no_padding, 0); - - lv_style_init(&style_lbvValue); - lv_style_set_text_font(&style_lbvValue, &lv_font_montserrat_40); - - draw_tabHome(); - - lv_obj_set_flex_flow(tabVolets, LV_FLEX_FLOW_ROW); - - lv_obj_set_flex_flow(tabMeteo, LV_FLEX_FLOW_COLUMN); - } - -void weather_data_retreived_start() -{ - //if (display_lock("weather_data_retreived_start")) - //{ - //ESP_LOGE(TAG,"Mutex obtenu dans weather_data_retreived_start"); - lv_subject_set_int(&meteoStatus, 1); - ESP_LOGE(TAG,"Subject setted weather_data_retreived_start"); - //display_unlock("weather_data_retreived_start"); - //}else{ - // ESP_LOGE(TAG,"Impossible d'obtenir le mutex dans weather_data_retreived_start"); - //} -} - -void weather_data_retreived(struct meteodailyforecast_data dailyDatas[3], struct meteoforecast_data datas[3]) -{ - -/* ESP_LOGE(TAG, "debut debug"); - printf("%lld\n", datas[0].datetime); - printf("%s\n", datas[0].previsions.desc); - printf("%f\n", datas[0].previsions.value); - printf("%lld\n", datas[1].datetime); - printf("%s\n", datas[1].previsions.desc); - printf("%f\n", datas[1].previsions.value); - printf("%lld\n", datas[2].datetime); - printf("%s\n", datas[2].previsions.desc); - printf("%f\n", datas[2].previsions.value); - ESP_LOGE(TAG, "fin debug"); -*/ - //if (display_lock("weather_data_retreived")) - //{ - ESP_LOGV("MeteoFrance", "------------------------------------- Set des subjects J --------------------------------"); - // Prévisions des 3 prochains jours - lv_subject_set_pointer(&forecastD1Subj, &dailyDatas[0]); - lv_subject_set_pointer(&forecastD2Subj, &dailyDatas[1]); - lv_subject_set_pointer(&forecastD3Subj, &dailyDatas[2]); - - ESP_LOGV("MeteoFrance", "------------------------------------- Set des subjects H--------------------------------"); - // Prévisions des 3 prochains jours - ESP_LOGV("MeteoFrance", "Pointeur %lli", datas[0].datetime); - lv_subject_set_pointer(&forecastH1Subj, &datas[0]); - lv_subject_set_pointer(&forecastH2Subj, &datas[1]); - lv_subject_set_pointer(&forecastH3Subj, &datas[2]); - - lv_subject_set_int(&meteoStatus, 0); - //display_unlock("weather_data_retreived"); - ESP_LOGV(TAG, "------------------------------------- Fin Set des subjects --------------------------------"); - //}else{ - // ESP_LOGE(TAG, "Impossible d'obtenir le mutex dans weather_data_retreived"); - //} -} - void mount_sd_card() { // Options for mounting the filesystem. @@ -1158,11 +126,8 @@ static void updateTime(void *pvParameter) 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); - if(display_lock("updateTime")){ - lv_subject_copy_string(&dateHeureSubj, strftime_buf); - display_unlock("updateTime"); - } - /* + 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(); @@ -1275,18 +240,12 @@ void readTempHumid(void *pvParameter) char buff[40]; ESP_LOGI(TAG, "Temperature: %.1f °C, Humidity: %.1f %%", temperature, humidity); sprintf(buff,"%.1f °C, %.1f %%", temperature, humidity); - if(lvgl_port_lock(5)){ - lv_label_set_text(lblTempInt2,buff); - lvgl_port_unlock(); - } + show_temp(buff); vTaskDelay(60000 / portTICK_PERIOD_MS); } } -void log_cb(lv_log_level_t level, const char * buf){ - ESP_LOGE(TAG, "%s",buf); -} void app_main(void) { @@ -1303,20 +262,6 @@ void app_main(void) //mount_sd_card(); bsp_sdcard_mount(); - bsp_display_cfg_t cfg = { - .lvgl_port_cfg = ESP_LVGL_PORT_INIT_CONFIG(), - .buffer_size = BSP_LCD_DRAW_BUFF_SIZE, - .double_buffer = BSP_LCD_DRAW_BUFF_DOUBLE, - .flags = { - .buff_dma = true, - .buff_spiram = false, - .sw_rotate = false, - } - }; - lv_display_t *dsp = bsp_display_start_with_config(&cfg); - //bsp_display_rotate(dsp,LV_DISP_ROTATION_180); - - bsp_display_backlight_on(); //lv_log_register_print_cb(log_cb); @@ -1333,7 +278,6 @@ void app_main(void) printf("6 - Free heap after buffers allocation: %d\n", xPortGetFreeHeapSize()); - lv_subject_init_int(&meteoStatus, -1); // On affiche au plus tot l'ecran de démarrage // ESP_ERROR_CHECK(esp_lcd_panel_mirror(lcd_panel,true,true)); @@ -1414,16 +358,6 @@ void app_main(void) mqtt_app_start(); - on_weather_data_retrieval(weather_data_retreived); - on_weather_data_retrieval_start(weather_data_retreived_start); - initialise_weather_data_retrieval(600000); - ESP_LOGW(TAG, "Weather data retrieval initialized"); - - - printf("13. Free heap after buffers allocation: %d\n", xPortGetFreeHeapSize()); - printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size()); - printf("Free heap size: %" PRIu32 " bytes\n", esp_get_free_heap_size()); - LV_ASSERT_MEM_INTEGRITY(); ESP_LOGI(TAG, "Initializing LittleFS"); diff --git a/main/main.h b/main/main.h index d95dfb1..0856623 100644 --- a/main/main.h +++ b/main/main.h @@ -1,13 +1,2 @@ #pragma once #include "mqtt_client.h" -static void showMeteoIcon(const char *icon, lv_obj_t *desc_icon, int childNr); - -static void draw_tabVolets(); - -static void draw_tabMeteo(); - -static void tabChgEvt(lv_event_t *event); - -static void draw_tabCuve(); -static void draw_tabHome(); -static void draw_tabSettings(); diff --git a/sdkconfig b/sdkconfig index 503eeeb..1dcd0a9 100644 --- a/sdkconfig +++ b/sdkconfig @@ -2562,7 +2562,7 @@ CONFIG_LV_DRAW_SW_DRAW_UNIT_CNT=1 # CONFIG_LV_USE_DRAW_ARM2D_SYNC is not set # CONFIG_LV_USE_NATIVE_HELIUM_ASM is not set CONFIG_LV_DRAW_SW_COMPLEX=y -# CONFIG_LV_USE_DRAW_SW_COMPLEX_GRADIENTS is not set +CONFIG_LV_USE_DRAW_SW_COMPLEX_GRADIENTS=y CONFIG_LV_DRAW_SW_SHADOW_CACHE_SIZE=0 CONFIG_LV_DRAW_SW_CIRCLE_CACHE_SIZE=4 CONFIG_LV_DRAW_SW_ASM_NONE=y @@ -2632,7 +2632,7 @@ CONFIG_LV_ASSERT_HANDLER_INCLUDE="assert.h" # CONFIG_LV_ENABLE_GLOBAL_CUSTOM is not set CONFIG_LV_CACHE_DEF_SIZE=0 CONFIG_LV_IMAGE_HEADER_CACHE_DEF_CNT=0 -CONFIG_LV_GRADIENT_MAX_STOPS=2 +CONFIG_LV_GRADIENT_MAX_STOPS=50 CONFIG_LV_COLOR_MIX_ROUND_OFS=128 # CONFIG_LV_OBJ_STYLE_CACHE is not set # CONFIG_LV_USE_OBJ_ID is not set @@ -2648,7 +2648,7 @@ CONFIG_LV_ATTRIBUTE_MEM_ALIGN_SIZE=1 CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y # CONFIG_LV_USE_FLOAT is not set # CONFIG_LV_USE_MATRIX is not set -# CONFIG_LV_USE_PRIVATE_API is not set +CONFIG_LV_USE_PRIVATE_API=y # end of Compiler Settings # @@ -2658,27 +2658,27 @@ CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y # # Enable built-in fonts # -CONFIG_LV_FONT_MONTSERRAT_8=y -CONFIG_LV_FONT_MONTSERRAT_10=y +# CONFIG_LV_FONT_MONTSERRAT_8 is not set +# CONFIG_LV_FONT_MONTSERRAT_10 is not set CONFIG_LV_FONT_MONTSERRAT_12=y CONFIG_LV_FONT_MONTSERRAT_14=y CONFIG_LV_FONT_MONTSERRAT_16=y CONFIG_LV_FONT_MONTSERRAT_18=y CONFIG_LV_FONT_MONTSERRAT_20=y CONFIG_LV_FONT_MONTSERRAT_22=y -CONFIG_LV_FONT_MONTSERRAT_24=y -CONFIG_LV_FONT_MONTSERRAT_26=y -CONFIG_LV_FONT_MONTSERRAT_28=y -CONFIG_LV_FONT_MONTSERRAT_30=y -CONFIG_LV_FONT_MONTSERRAT_32=y -CONFIG_LV_FONT_MONTSERRAT_34=y -CONFIG_LV_FONT_MONTSERRAT_36=y -CONFIG_LV_FONT_MONTSERRAT_38=y +# CONFIG_LV_FONT_MONTSERRAT_24 is not set +# CONFIG_LV_FONT_MONTSERRAT_26 is not set +# CONFIG_LV_FONT_MONTSERRAT_28 is not set +# CONFIG_LV_FONT_MONTSERRAT_30 is not set +# CONFIG_LV_FONT_MONTSERRAT_32 is not set +# CONFIG_LV_FONT_MONTSERRAT_34 is not set +# CONFIG_LV_FONT_MONTSERRAT_36 is not set +# CONFIG_LV_FONT_MONTSERRAT_38 is not set CONFIG_LV_FONT_MONTSERRAT_40=y -CONFIG_LV_FONT_MONTSERRAT_42=y -CONFIG_LV_FONT_MONTSERRAT_44=y -CONFIG_LV_FONT_MONTSERRAT_46=y -CONFIG_LV_FONT_MONTSERRAT_48=y +# CONFIG_LV_FONT_MONTSERRAT_42 is not set +# CONFIG_LV_FONT_MONTSERRAT_44 is not set +# CONFIG_LV_FONT_MONTSERRAT_46 is not set +# CONFIG_LV_FONT_MONTSERRAT_48 is not set # CONFIG_LV_FONT_MONTSERRAT_28_COMPRESSED is not set # CONFIG_LV_FONT_DEJAVU_16_PERSIAN_HEBREW is not set # CONFIG_LV_FONT_SIMSUN_14_CJK is not set @@ -2734,46 +2734,41 @@ CONFIG_LV_TXT_LINE_BREAK_LONG_LEN=0 # Widget Usage # CONFIG_LV_WIDGETS_HAS_DEFAULT_VALUE=y -CONFIG_LV_USE_ANIMIMG=y -CONFIG_LV_USE_ARC=y +# CONFIG_LV_USE_ANIMIMG is not set +# CONFIG_LV_USE_ARC is not set CONFIG_LV_USE_BAR=y CONFIG_LV_USE_BUTTON=y CONFIG_LV_USE_BUTTONMATRIX=y -CONFIG_LV_USE_CALENDAR=y -# CONFIG_LV_CALENDAR_WEEK_STARTS_MONDAY is not set -CONFIG_LV_USE_CALENDAR_HEADER_ARROW=y -CONFIG_LV_USE_CALENDAR_HEADER_DROPDOWN=y -# CONFIG_LV_USE_CALENDAR_CHINESE is not set +# CONFIG_LV_USE_CALENDAR is not set CONFIG_LV_USE_CANVAS=y CONFIG_LV_USE_CHART=y CONFIG_LV_USE_CHECKBOX=y -CONFIG_LV_USE_DROPDOWN=y +# CONFIG_LV_USE_DROPDOWN is not set CONFIG_LV_USE_IMAGE=y CONFIG_LV_USE_IMAGEBUTTON=y -CONFIG_LV_USE_KEYBOARD=y +# CONFIG_LV_USE_KEYBOARD is not set CONFIG_LV_USE_LABEL=y CONFIG_LV_LABEL_TEXT_SELECTION=y CONFIG_LV_LABEL_LONG_TXT_HINT=y CONFIG_LV_LABEL_WAIT_CHAR_COUNT=3 -CONFIG_LV_USE_LED=y -CONFIG_LV_USE_LINE=y -CONFIG_LV_USE_LIST=y -CONFIG_LV_USE_MENU=y -CONFIG_LV_USE_MSGBOX=y +# CONFIG_LV_USE_LED is not set +# CONFIG_LV_USE_LINE is not set +# CONFIG_LV_USE_LIST is not set +# CONFIG_LV_USE_MENU is not set +# CONFIG_LV_USE_MSGBOX is not set CONFIG_LV_USE_ROLLER=y -CONFIG_LV_USE_SCALE=y +# CONFIG_LV_USE_SCALE is not set CONFIG_LV_USE_SLIDER=y -CONFIG_LV_USE_SPAN=y -CONFIG_LV_SPAN_SNIPPET_STACK_SIZE=64 -CONFIG_LV_USE_SPINBOX=y -CONFIG_LV_USE_SPINNER=y +# CONFIG_LV_USE_SPAN is not set +# CONFIG_LV_USE_SPINBOX is not set +# CONFIG_LV_USE_SPINNER is not set CONFIG_LV_USE_SWITCH=y CONFIG_LV_USE_TEXTAREA=y CONFIG_LV_TEXTAREA_DEF_PWD_SHOW_TIME=1500 -CONFIG_LV_USE_TABLE=y +# CONFIG_LV_USE_TABLE is not set CONFIG_LV_USE_TABVIEW=y -CONFIG_LV_USE_TILEVIEW=y -CONFIG_LV_USE_WIN=y +# CONFIG_LV_USE_TILEVIEW is not set +# CONFIG_LV_USE_WIN is not set # end of Widget Usage # @@ -2867,7 +2862,7 @@ CONFIG_LV_USE_OBSERVER=y # # Examples # -CONFIG_LV_BUILD_EXAMPLES=y +# CONFIG_LV_BUILD_EXAMPLES is not set # end of Examples #