amelioration volets

This commit is contained in:
Marc 2024-09-07 20:20:12 +02:00
parent ca459f1475
commit 7f2a5633d5
8 changed files with 279 additions and 66 deletions

View File

@ -1,19 +1,7 @@
# ESP LVGL RGB Screen Example
18px Montserrat + Home de FontAwesome
Very simple example for demonstration of initialization and usage of the `esp_lvgl_port` component with RGB LCD. This example contains four main parts:
``` docker run -v $PWD:/app -w /app lvfontconv lv_font_conv --bpp 4 --size 18 --no-compress --font Montserrat-Medium.ttf --symbols "0123456789.°éûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '" --format lvgl -o montserrat_medium_18.c --font fa-solid-900.ttf --range 61461 ```
## 1. LCD HW initialization - `app_lcd_init()`
12px Montserrat
Standard HW initialization of the LCD using [`esp_lcd`](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) component. Settings of this example are fully compatible with [ESP32-S3-LCD-EV-Board-2](https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s3_lcd_ev_board) board.
## 2. Touch HW initialization - `app_touch_init()`
Standard HW initialization of the LCD touch using [`esp_lcd_touch`](https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch) component. Settings of this example are fully compatible with [ESP32-S3-LCD-EV-Board-2](https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s3_lcd_ev_board) board.
## 3. LVGL port initialization - `app_lvgl_init()`
Initialization of the LVGL port.
## 4. LVGL objects example usage - `app_main_display()`
Very simple demonstration code of using LVGL objects after LVGL port initialization.
``` docker run -v $PWD:/app -w /app lvfontconv lv_font_conv --bpp 4 --size 12 --no-compress --font Montserrat-Medium.ttf --symbols "0123456789.°èéêûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz '" --format lvgl -o montserrat_medium_12.c ```

View File

@ -14,7 +14,7 @@ struct forecast_temp{
float min;
float max;
char desc[25];
char icon[8];
char icon[9];
};
struct meteoforecast_data{

View File

@ -186,7 +186,7 @@ void JSON_Parse(const cJSON * const root) {
cJSON *weather12=cJSON_GetObjectItem(current_element,"weather12H");
strncpy(datasT.previsions.desc,cJSON_GetObjectItem(weather12,"desc")->valuestring,24);
strncpy(datasT.previsions.icon,cJSON_GetObjectItem(weather12,"icon")->valuestring,7);
strncpy(datasT.previsions.icon,cJSON_GetObjectItem(weather12,"icon")->valuestring,8);
datasT.isValid=true;
//ESP_LOGE(TAG,"Donnees lues");
//printffd(&datasT);
@ -245,8 +245,7 @@ static void http_request_task(void *pvParameter)
}
//ESP_LOGE(TAG, "%s",local_response_buffer);
bool weather_data_phrased = false;
weather_data_phrased = process_response_body(local_response_buffer);
process_response_body(local_response_buffer);
weather.data_retreived_cb(datas);
esp_http_client_cleanup(client);

View File

@ -1,13 +1,13 @@
idf_component_register(SRC_DIRS . fonts
INCLUDE_DIRS "."
REQUIRES esp_wifi nvs_flash mqtt meteofrance esp_netif)
lvgl_port_create_c_image("images/esp_logo.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p10j.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p10n.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p11j.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p11n.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p12j.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p12bisj.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p12n.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p13j.png" "images/" "ARGB8888" "NONE")
lvgl_port_create_c_image("images/p13n.png" "images/" "ARGB8888" "NONE")
@ -75,5 +75,5 @@ lvgl_port_add_images(${COMPONENT_LIB} "images/")
set_source_files_properties(
PROPERTIES COMPILE_OPTIONS
"-DLV_LVGL_H_INCLUDE_SIMPLE;-Wno-format;-DLV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(montserrat_medium_12) LV_FONT_DECLARE(montserrat_medium_18)"
"-DLV_LVGL_H_INCLUDE_SIMPLE;-Wno-format;-DLV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(montserrat_medium_12) LV_FONT_DECLARE(montserrat_medium_18) LV_FONT_DECLARE(montserrat_medium_24)"
)

BIN
main/images/p12bisj.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

49
main/images/p12bisj.svg Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Calque_17" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="50" height="50" x="0px" y="0px"
viewBox="0 0 85.2 85.2" style="enable-background:new 0 0 85.2 85.2;" xml:space="preserve">
<style type="text/css">
.p12bisj-0{opacity:0.51;fill:#EEEB61;enable-background:new ;}
.p12bisj-1{fill:#F5B21A;stroke:#FDE901;stroke-miterlimit:10;}
.p12bisj-2{opacity:0.3;}
.p12bisj-3{fill:#231F20;}
.p12bisj-4{fill:#D8D9D8;}
.p12bisj-5{fill:#79CCF1;}
.p12bisj-6{fill:#FFFFFF;}
</style>
<title>17Plan de travail 1</title>
<circle class="p12bisj-0" cx="58.5" cy="32.2" r="20.2"/>
<circle class="p12bisj-1" cx="58.5" cy="32.2" r="15.4"/>
<g class="p12bisj-2">
<path class="p12bisj-3" d="M68.8,41.9c-4.3-7-13.4-9.1-20.3-4.9c-3.5,2.2-6,5.7-6.8,9.7c2.8,0.3,5.3,1.8,6.7,4.3l-1.1,0.6
c-2-3.4-5.8-3.8-8.5-3.7c-4.4,1.7-6.6,6.6-4.9,11c1.3,3.3,4.4,5.5,7.9,5.5h25.7c6.3-0.3,11.1-5.6,10.8-11.9
C78,47.2,74,42.7,68.8,41.9L68.8,41.9z"/>
<path class="p12bisj-3" d="M33,35.9c-0.8-4.5-4.7-7.7-9.3-7.7c-2.9,0-5.7,1.3-7.5,3.6c2,0.3,4.5,1.2,5.6,3.6L20.6,36
c-1.4-3-6-3.1-6.7-3.1c-2.8,0.9-4.7,3.5-4.7,6.5c0.1,3.9,3.3,7,7.2,6.9c0,0,0,0,0,0h16.4c2.9,0,5.3-2.3,5.3-5.1S35.9,35.9,33,35.9
L33,35.9L33,35.9L33,35.9z"/>
</g>
<path class="p12bisj-4" d="M66.1,39.2c-4.3-7-13.4-9.1-20.3-4.9c-3.5,2.2-6,5.7-6.8,9.7c2.8,0.3,5.2,1.8,6.6,4.2L44.5,49
c-2-3.4-5.8-3.8-8.5-3.7c-4.4,1.7-6.6,6.6-4.9,11c1.3,3.3,4.4,5.5,7.9,5.5h25.8c6.3-0.3,11.1-5.7,10.8-11.9
C75.4,44.5,71.4,40.1,66.1,39.2L66.1,39.2z"/>
<path class="p12bisj-4" d="M30.4,33.3c-0.8-4.5-4.7-7.7-9.3-7.7c-2.9,0-5.7,1.3-7.5,3.6c2,0.3,4.5,1.2,5.6,3.6L18,33.4
c-1.4-3-6-3.1-6.7-3.1c-2.8,0.9-4.7,3.5-4.7,6.5c0.1,3.9,3.3,7,7.2,6.9c0,0,0,0,0,0h16.5c2.9,0,5.2-2.3,5.3-5.1
C35.6,35.6,33.3,33.3,30.4,33.3L30.4,33.3L30.4,33.3z"/>
<path class="p12bisj-5" d="M44,72.2l1.9-6.1c0.1-0.3,0.4-0.5,0.7-0.4l0.8,0.2c0.3,0.1,0.5,0.4,0.4,0.7l-1.9,6.1c-0.1,0.3-0.4,0.5-0.7,0.4
l-0.8-0.2C44.1,72.8,43.9,72.5,44,72.2z"/>
<path class="p12bisj-5" d="M53.7,72.2l1.8-6.1c0.1-0.3,0.4-0.5,0.7-0.4L57,66c0.3,0.1,0.5,0.4,0.4,0.7l-1.8,6.1c-0.1,0.3-0.4,0.5-0.7,0.4
L54,72.9C53.7,72.8,53.6,72.5,53.7,72.2z"/>
<path class="p12bisj-5" d="M33.7,72.2l1.9-6.1c0.1-0.3,0.4-0.5,0.7-0.4L37,66c0.3,0.1,0.5,0.4,0.4,0.7l-1.9,6.1c-0.1,0.3-0.4,0.5-0.7,0.4
l-0.8-0.2C33.8,72.8,33.6,72.5,33.7,72.2z"/>
<path class="p12bisj-5" d="M63.6,72.2l1.8-6.1c0.1-0.3,0.4-0.5,0.7-0.4L67,66c0.3,0.1,0.5,0.4,0.4,0.7l-1.8,6.1c-0.1,0.3-0.4,0.5-0.7,0.4
L64,72.9C63.7,72.8,63.5,72.5,63.6,72.2z"/>
<path class="p12bisj-5" d="M72.6,72.2l1.8-6.1c0.1-0.3,0.4-0.5,0.7-0.4L76,66c0.3,0.1,0.5,0.4,0.4,0.7l-1.8,6.1c-0.1,0.3-0.4,0.5-0.7,0.4
L73,72.9C72.7,72.8,72.6,72.5,72.6,72.2z"/>
<path class="p12bisj-6" d="M48.8,71.8l1.8-6.1c0.1-0.3,0.4-0.5,0.7-0.4l0.8,0.2c0.3,0.1,0.5,0.4,0.4,0.7l-1.8,6.1
c-0.1,0.3-0.4,0.5-0.7,0.4l-0.8-0.2C48.9,72.4,48.7,72.1,48.8,71.8z"/>
<path class="p12bisj-6" d="M58.7,72.2l1.9-6.1c0.1-0.3,0.4-0.5,0.7-0.4L62,66c0.3,0.1,0.5,0.4,0.4,0.7l-1.9,6.1c-0.1,0.3-0.4,0.5-0.7,0.4
L59,72.9C58.7,72.8,58.6,72.5,58.7,72.2z"/>
<path class="p12bisj-6" d="M38.9,72.2l1.9-6.1c0.1-0.3,0.4-0.5,0.7-0.4l0.8,0.2c0.3,0.1,0.5,0.4,0.4,0.7l-1.9,6.1
c-0.1,0.3-0.4,0.5-0.7,0.4l-0.8-0.2C39,72.8,38.9,72.5,38.9,72.2z"/>
<path class="p12bisj-6" d="M68.1,72.2l1.9-6.1c0.1-0.3,0.4-0.5,0.7-0.4l0.8,0.2c0.3,0.1,0.5,0.4,0.4,0.7L70,72.7c-0.1,0.3-0.4,0.5-0.7,0.4
l-0.8-0.2C68.2,72.8,68.1,72.5,68.1,72.2z"/>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -18,9 +18,11 @@
#include "esp_sntp.h"
#include <locale.h>
#include "esp_lcd_touch_gt911.h"
LV_FONT_DECLARE(montserrat_medium_12)
LV_FONT_DECLARE(montserrat_medium_18)
LV_FONT_DECLARE(montserrat_medium_24)
char *days[7]={"Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"};
char *months[12]={"Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"};
@ -72,19 +74,20 @@ char *months[12]={"Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Ao
#define EXAMPLE_LCD_PANEL_35HZ_RGB_TIMING() \
{ \
.pclk_hz = 18 * 1000 * 1000, \
.pclk_hz = 16 * 1000 * 1000, \
.h_res = EXAMPLE_LCD_H_RES, \
.v_res = EXAMPLE_LCD_V_RES, \
.hsync_pulse_width = 40, \
.hsync_back_porch = 40, \
.hsync_front_porch = 48, \
.vsync_pulse_width = 23, \
.vsync_back_porch = 32, \
.vsync_front_porch = 13, \
.hsync_pulse_width = 4, \
.hsync_back_porch = 8, \
.hsync_front_porch = 8, \
.vsync_pulse_width = 4, \
.vsync_back_porch = 8, \
.vsync_front_porch = 8, \
.flags.pclk_active_neg = true, \
.flags.hsync_idle_low =true, \
}
static const char *TAG = "EXAMPLE";
static const char *TAG = "domoTic";
// LVGL image declare
LV_IMG_DECLARE(esp_logo)
@ -280,6 +283,8 @@ lv_subject_t wifiStatus;
lv_subject_t mqttStatus;
lv_subject_t meteoStatus;
static lv_style_t no_padding;
static void app_main_display(void)
{
@ -288,7 +293,11 @@ static void app_main_display(void)
lv_subject_init_int(&mqttStatus,-1);
lv_subject_init_int(&meteoStatus,-1);
lv_style_init(&no_padding);
lv_style_set_pad_all(&no_padding, 0);
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);
@ -299,6 +308,9 @@ static void app_main_display(void)
lv_label_bind_text(meteoR, &meteoStatus, "Meteo %d");
lv_obj_t *wifi = lv_label_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");
@ -384,27 +396,45 @@ static void event_handler(lv_event_t *e)
break;
}
}
LV_IMAGE_DECLARE(plan_rdc);
LV_IMAGE_DECLARE(plan_etage);
LV_IMAGE_DECLARE(p1j);
LV_IMAGE_DECLARE(p2j);
LV_IMAGE_DECLARE(p3j);
LV_IMAGE_DECLARE(p5bisj);
LV_IMAGE_DECLARE(p12j);
LV_IMAGE_DECLARE(p12bisj);
LV_IMAGE_DECLARE(p14j);
LV_IMAGE_DECLARE(p24j);
LV_IMAGE_DECLARE(p25j);
LV_IMAGE_DECLARE(p26j);
LV_IMAGE_DECLARE(p27j);
LV_IMAGE_DECLARE(p28j);
LV_IMAGE_DECLARE(p29j);
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 *`*/
};
static void weatherdata_obs_cb(lv_observer_t *observer, lv_subject_t *subject)
{
// Retrieve weatherdata
struct meteoforecast_data *data = subject->value.pointer;
printffd(data);
//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 *desc_icon = lv_obj_get_child(parent, 0);
lv_obj_t *temps = lv_obj_get_child(parent, 1);
ESP_LOGE(TAG, "Affichagfe de l'image %s",data->previsions.icon);
if (strcmp(data->previsions.icon, "p1j") == 0)
{
lv_image_set_src(lv_obj_get_child(desc_icon, 0), &p1j);
@ -417,6 +447,12 @@ static void weatherdata_obs_cb(lv_observer_t *observer, lv_subject_t *subject)
}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);
@ -432,6 +468,9 @@ static void weatherdata_obs_cb(lv_observer_t *observer, lv_subject_t *subject)
}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);
@ -449,45 +488,47 @@ struct weatherDay_fragment_t
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, int args)
static void weatherDay_fragment_ctor(lv_fragment_t *self, void * args)
{
((struct weatherDay_fragment_t *)self)->dayNr = args;
int dayNo = ((int *)args)[0];
//bool showDate = ((int*)args)[1];
((struct weatherDay_fragment_t *)self)->dayNr = dayNo;
//ESP_LOGI(TAG, "Fragment initialisé avec le jour n°%d - Afficher la date %d",dayNo, showDate);
}
static lv_style_t style_font_16;
static lv_style_t style_font_18;
static lv_style_t style_font_24;
static lv_style_t style_font_12;
static lv_obj_t *weatherDay_fragment_create_obj(lv_fragment_t *self, lv_obj_t *parent)
{
lvgl_port_lock(0);
lv_obj_t *sup = lv_obj_create(parent);
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);
static lv_style_t no_padding;
lv_style_init(&no_padding);
lv_style_set_pad_all(&no_padding, 0);
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, 100);
lv_obj_set_height(container, 90);
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, -8);
lv_obj_set_size(img1,40,40);
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);
@ -499,7 +540,7 @@ static lv_obj_t *weatherDay_fragment_create_obj(lv_fragment_t *self, lv_obj_t *p
lv_obj_t *container2 = lv_obj_create(sup);
lv_obj_set_width(container2, LV_SIZE_CONTENT);
lv_obj_set_height(container2, 90);
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);
@ -513,15 +554,18 @@ static lv_obj_t *weatherDay_fragment_create_obj(lv_fragment_t *self, lv_obj_t *p
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_16, 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_16, 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);
lv_subject_add_observer_obj(tmpSubj[((struct weatherDay_fragment_t *)self)->dayNr], weatherdata_obs_cb, sup, NULL);
lvgl_port_unlock();
return container;
}
const lv_fragment_class_t sample_cls = {
@ -533,6 +577,27 @@ const lv_fragment_class_t sample_cls = {
.instance_size = sizeof(struct weatherDay_fragment_t),
};
static void meteoforecast_fragment_ctor(lv_fragment_t * self, void * args);
static lv_obj_t * meteoforecast_fragment_create_obj(lv_fragment_t * self, lv_obj_t * parent);
static void sample_container_delete(lv_event_t * e);
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;
};
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),
};
void draw_ihm()
{
lv_subject_init_string(&tempExtSubj, tempExtStr, NULL, 6, "--");
@ -567,20 +632,23 @@ void draw_ihm()
/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
lv_obj_t * tab1 = lv_tabview_add_tab(tabview, LV_SYMBOL_HOME);
lv_obj_t * tab2 = lv_tabview_add_tab(tabview, "Volets");
lv_obj_t * tab2b = lv_tabview_add_tab(tabview, "Volets");
lv_obj_t * tab3 = lv_tabview_add_tab(tabview, "Météo");
lv_obj_t * tab4 = lv_tabview_add_tab(tabview, "Cuve");
lv_obj_t * tab5 = lv_tabview_add_tab(tabview, "Réglages");
lv_obj_set_style_bg_color(tab2, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0);
lv_obj_set_style_bg_opa(tab2, LV_OPA_COVER, 0);
lv_obj_set_style_bg_color(tab2b, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0);
lv_obj_set_style_bg_opa(tab2b, LV_OPA_COVER, 0);
static lv_style_t style_btn;
lv_style_init(&style_btn);
lv_style_init(&style_font_16);
lv_style_set_text_font(&style_font_16, &montserrat_medium_18);
lv_style_init(&style_font_18);
lv_style_set_text_font(&style_font_18, &montserrat_medium_18);
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_12);
@ -614,7 +682,7 @@ void draw_ihm()
lv_obj_set_flex_flow(supmain, LV_FLEX_FLOW_COLUMN);
lv_obj_t *jour = lv_label_create(supmain);
lv_obj_add_style(jour,&style_font_16,0);
lv_obj_add_style(jour,&style_font_18,0);
setlocale(LC_ALL, "fr_FR");
char strftime_buf[64];
@ -754,15 +822,96 @@ void draw_ihm()
lv_subject_add_observer_obj(&tempD3Subj, weatherdata_obs_cb, tempD3, NULL);
*/
lv_fragment_manager_t *manager = lv_fragment_manager_create(NULL);
lv_fragment_t *fragment = lv_fragment_create(&sample_cls, 0);
lv_fragment_t *fragment = lv_fragment_create(&meteoforecast_cls, 0);
lv_fragment_manager_add(manager, fragment, &cont_col3);
fragment = lv_fragment_create(&sample_cls, 1);
lv_fragment_manager_add(manager, fragment, &cont_col3);
lv_obj_t * tab2=lv_obj_create(tab2b);
lv_obj_set_size(tab2, lv_pct(75),lv_pct(100));
fragment = lv_fragment_create(&sample_cls, 2);
lv_fragment_manager_add(manager, fragment, &cont_col3);
lv_obj_set_flex_flow(tab2b, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_flow(tab2, LV_FLEX_FLOW_COLUMN);
lv_obj_t * cont_rdc=lv_obj_create(tab2);
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(tab2,&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);
ESP_LOGI(TAG,"Recup pos %d", i-1);
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(tab2b);
lv_obj_set_size(cont_btn_volets,lv_pct(20), 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_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(tab2);
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);
ESP_LOGI(TAG,"Recup pos %d", i-1);
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,"");
}
lv_obj_set_flex_flow(tab3, LV_FLEX_FLOW_COLUMN);
lv_fragment_manager_t *manager2 = lv_fragment_manager_create(NULL);
lv_fragment_t *fragment2 = lv_fragment_create(&meteoforecast_cls, 1);
lv_fragment_manager_add(manager2, fragment2, &tab3);
}
/* The examples use WiFi configuration that you can set via project configuration menu
@ -1136,7 +1285,6 @@ static void mqtt_app_start(void)
void weather_data_retreived_start()
{
ESP_LOGE(TAG,"Début recup méteo");
if(lvgl_port_lock(0)){
lv_subject_set_int(&meteoStatus,1);
lvgl_port_unlock();
@ -1145,8 +1293,7 @@ void weather_data_retreived_start()
void weather_data_retreived(struct meteoforecast_data datas[3])
{
// struct meteoforecast_data* weather = (meteoforecast_data*) args;
struct meteoforecast_data j1 = {};
/*
ESP_LOGE(TAG, "debut debug");
printf("%lld\n", datas[0].datetime);
printf("%s\n", datas[0].previsions.desc);
@ -1158,16 +1305,16 @@ void weather_data_retreived(struct meteoforecast_data datas[3])
printf("%s\n", datas[2].previsions.desc);
printf("%f\n", datas[2].previsions.min);
ESP_LOGE(TAG, "fin debug");
*/
if (lvgl_port_lock(0))
{
ESP_LOGE(TAG, "------------------------------------- Set des subjects --------------------------------");
//ESP_LOGE(TAG, "------------------------------------- Set des subjects --------------------------------");
lv_subject_set_pointer(&tempD1Subj, &datas[0]);
lv_subject_set_pointer(&tempD2Subj, &datas[1]);
lv_subject_set_pointer(&tempD3Subj, &datas[2]);
lv_subject_set_int(&meteoStatus,0);
lvgl_port_unlock();
ESP_LOGE(TAG, "------------------------------------- Fin Set des subjects --------------------------------");
//ESP_LOGE(TAG, "------------------------------------- Fin Set des subjects --------------------------------");
}
}
static void obtain_time(void);
@ -1188,7 +1335,7 @@ void app_main(void)
/* LVGL initialization */
ESP_ERROR_CHECK(app_lvgl_init());
// Initialize NVS
// Initialize NVS
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
@ -1200,6 +1347,7 @@ void app_main(void)
/* Show LVGL objects */
if(lvgl_port_lock(0)){
//ESP_ERROR_CHECK(esp_lcd_panel_mirror(lcd_panel,true,true));
app_main_display();
lvgl_port_unlock();
}
@ -1236,6 +1384,8 @@ void app_main(void)
if(lvgl_port_lock(0)){
// app_main_display();
draw_ihm();
//lv_disp_set_rotation(lvgl_disp, LV_DISPLAY_ROTATION_180);
lvgl_port_unlock();
}
}
@ -1261,3 +1411,30 @@ static void obtain_time(void)
esp_netif_sntp_deinit();
}
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);
int args[2]={0,((struct meteoforecast_fragment_t*)self)->showDate};
lv_fragment_t *fragment = lv_fragment_create(&sample_cls, args);
lv_fragment_manager_add(manager, fragment, &parent);
args[0]=1;
fragment = lv_fragment_create(&sample_cls, args);
lv_fragment_manager_add(manager, fragment, &parent);
args[0]=2;
fragment = lv_fragment_create(&sample_cls, args);
lv_fragment_manager_add(manager, fragment, &parent);
return parent;
}