ok on host
This commit is contained in:
parent
c7b46b5bfe
commit
93bffe925f
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@ -41,12 +41,13 @@
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
/*
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Load LVGL GDB helpers",
|
||||
"text": "source /home/marc/domotic/components/domotic_display/test_host/managed_components/lvgl__lvgl/scripts/gdb/gdbinit.py"
|
||||
}
|
||||
],
|
||||
],*/
|
||||
"linux": {
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "/usr/bin/gdb"
|
||||
|
||||
9
.vscode/settings.json
vendored
9
.vscode/settings.json
vendored
@ -1,13 +1,13 @@
|
||||
{
|
||||
"C_Cpp.intelliSenseEngine": "default",
|
||||
"idf.espIdfPath": "/home/marc/esp/v5.5.1/esp-idf",
|
||||
"idf.espIdfPath": "/home/marc/esp/esp-idf",
|
||||
"idf.pythonBinPath": "/home/marc/.espressif/python_env/idf5.5_py3.10_env/bin/python",
|
||||
"idf.toolsPath": "/home/marc/.espressif",
|
||||
"idf.customExtraPaths": "/home/marc/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin:/home/marc/.espressif/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin:/home/marc/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin:/home/marc/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin:/home/marc/.espressif/tools/esp32ulp-elf/2.38_20240113/esp32ulp-elf/bin:/home/marc/.espressif/tools/cmake/3.24.0/bin:/home/marc/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin:/home/marc/.espressif/tools/ninja/1.11.1:/home/marc/.espressif/tools/esp-rom-elfs/20240305",
|
||||
"idf.customExtraVars": {
|
||||
"OPENOCD_SCRIPTS": "/home/marc/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts",
|
||||
"OPENOCD_SCRIPTS": "/home/marc/.espressif/tools/openocd-esp32/v0.12.0-esp32-20251215/openocd-esp32/share/openocd/scripts",
|
||||
"ESP_ROM_ELF_DIR": "/home/marc/.espressif/tools/esp-rom-elfs/20240305/",
|
||||
"IDF_TARGET": "esp32"
|
||||
"IDF_TARGET": "linux"
|
||||
},
|
||||
"idf.gitPath": "git",
|
||||
"idf.adapterTargetName": "esp32s3",
|
||||
@ -115,5 +115,6 @@
|
||||
"--background-index",
|
||||
"--query-driver=/home/marc/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc",
|
||||
"--compile-commands-dir=/home/marc/domotic/build"
|
||||
]
|
||||
],
|
||||
"idf.currentSetup": "/home/marc/.espressif/v5.5.2/esp-idf"
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ lv_obj_t *jour;
|
||||
|
||||
static lv_style_t no_padding;
|
||||
static const char *TAG = "IHM";
|
||||
static lv_subject_t wifiStatus;
|
||||
lv_subject_t wifiStatus;
|
||||
|
||||
LV_IMAGE_DECLARE(wifi_ok);
|
||||
LV_IMAGE_DECLARE(wifi_ko);
|
||||
@ -84,19 +84,18 @@ static void wifiStatus_obs_cb(lv_observer_t * observer, lv_subject_t * subject)
|
||||
//lv_obj_t * btn = lv_observer_get_target(observer);
|
||||
}
|
||||
|
||||
static void draw_time(struct tm *dateHeure){
|
||||
if(display_lock("updateTime")){
|
||||
void draw_time(struct tm *dateHeure){
|
||||
//if(display_lock("updateTime")){
|
||||
//lv_label_set_text(jour, dateHeure);
|
||||
|
||||
lv_subject_set_pointer(&timeSubj, dateHeure);
|
||||
display_unlock("updateTime");
|
||||
}
|
||||
//display_unlock("updateTime");
|
||||
//}
|
||||
}
|
||||
|
||||
static void draw_temp(char * tempHumid){
|
||||
void draw_temp(char * tempHumid){
|
||||
if(display_lock("draw_temp")){
|
||||
lv_label_set_text(lblTempInt2,tempHumid);
|
||||
display_unlock("updateTime");
|
||||
display_unlock("draw_temp");
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,140 +122,61 @@ void lv_theme_copy(lv_theme_t *dst, const lv_theme_t *src)
|
||||
}
|
||||
lv_memcpy(dst, src, sizeof(*src));
|
||||
}
|
||||
|
||||
|
||||
void drawIhm(void *xIHMEventQueueParam) {
|
||||
QueueHandle_t xIHMEventQueue = (QueueHandle_t)xIHMEventQueueParam;
|
||||
|
||||
display_lock("app_main");
|
||||
init_display_ihm();
|
||||
|
||||
/* Initialize the new theme with the current theme as its parent
|
||||
* The user is responsible for freeing the theme when it's no longer needed */
|
||||
//lv_theme_t *th_act = lv_display_get_theme(NULL);
|
||||
//lv_theme_t *th_new = lv_theme_create();
|
||||
//lv_theme_copy(th_new, th_act);
|
||||
//th_new->font_small = &montserrat_medium_12;
|
||||
//th_new->font_normal = &montserrat_medium_18;
|
||||
//th_new->font_large = &roboto_medium_36;
|
||||
// lv_theme_default_deinit();
|
||||
static void create_ui(void)
|
||||
{
|
||||
// Initialisation du thème
|
||||
lv_theme_t *th_new = lv_theme_domotic_init(lv_display_get_default());
|
||||
//lv_theme_t *th_simple = lv_theme_simple_init(lv_display_get_default());
|
||||
|
||||
//lv_theme_set_parent(th_simple, NULL);
|
||||
|
||||
//lv_theme_set_parent(th_new, th_simple);
|
||||
|
||||
/*Set the style apply callback for the new theme*/
|
||||
//lv_theme_set_apply_cb(th_new, new_theme_apply_cb);
|
||||
|
||||
/*Assign the new theme to the current display*/
|
||||
lv_display_set_theme(lv_display_get_default(), th_new);
|
||||
|
||||
// Initialisation des sujets / observers
|
||||
lv_subject_init_int(&wifiStatus, 0);
|
||||
lv_subject_add_observer_obj(&wifiStatus, wifiStatus_obs_cb, NULL, NULL);
|
||||
|
||||
|
||||
//lv_example_style_17();
|
||||
app_main_display();
|
||||
display_unlock("app_main");
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(200));
|
||||
|
||||
if (display_lock("draw_ihm")) {
|
||||
drawHome();
|
||||
display_unlock("draw_ihm");
|
||||
// Création des écrans / widgets
|
||||
app_main_display(); // ton écran principal
|
||||
drawHome(); // écran Home
|
||||
// chart, labels, boutons, etc.
|
||||
// par exemple : lblEtatMachine, lblHauteurCuve, myChart, ser...
|
||||
}
|
||||
|
||||
lv_obj_dump_tree(lv_scr_act());
|
||||
|
||||
while (1)
|
||||
static void ihm_process_queue(QueueHandle_t xIHMEventQueue)
|
||||
{
|
||||
xIHMEvent_t *xReceivedEvent = NULL;
|
||||
|
||||
if (xQueueReceive(xIHMEventQueue, &xReceivedEvent, portMAX_DELAY) == pdTRUE && xReceivedEvent) {
|
||||
ESP_LOGE(TAG,"Evt IHM Recu");
|
||||
switch (xReceivedEvent->eEventType) {
|
||||
case IHM_EVT_WIFI_STATUS:
|
||||
lv_subject_set_int(&wifiStatus, *(bool *)xReceivedEvent->pvData);
|
||||
break;
|
||||
while (xQueueReceive(xIHMEventQueue, &xReceivedEvent, 0) == pdTRUE && xReceivedEvent) {
|
||||
|
||||
case IHM_EVT_TIME_SETTED:
|
||||
draw_time(xReceivedEvent->pvData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case IHM_EVT_OTA_STARTED:
|
||||
app_ota_display();
|
||||
break;
|
||||
// draw_ihm.c
|
||||
#include "ihm_gateway.h"
|
||||
#include <unistd.h> // usleep
|
||||
#include "platform_detect.h"
|
||||
|
||||
case IHM_EVT_OTA_PROGRESS:
|
||||
//setOTAProgress((int)xReceivedEvent->pvData);
|
||||
break;
|
||||
void drawIhm(void *param) {
|
||||
// Init display + LVGL
|
||||
init_display_ihm();
|
||||
//lv_init();
|
||||
lv_theme_t *th_new = lv_theme_domotic_init(lv_display_get_default());
|
||||
lv_display_set_theme(lv_display_get_default(), th_new);
|
||||
|
||||
case IHM_EVT_HUMID_TEMP:
|
||||
draw_temp((char *)xReceivedEvent->pvData);
|
||||
break;
|
||||
// Init queue
|
||||
//ihm_gateway_init();
|
||||
|
||||
case IHM_EVT_PUISSANCE_EMISE:
|
||||
if (display_lock("updateChart")) {
|
||||
int val = *(int*)xReceivedEvent->pvData;
|
||||
ESP_LOGE(TAG, "On a recu %i", val);
|
||||
if (val == 0) {
|
||||
lv_chart_set_next_value(myChart, ser, LV_CHART_POINT_NONE);
|
||||
create_ui();
|
||||
|
||||
// Loop unifiée
|
||||
while (1) {
|
||||
ihm_gateway_process_queue();
|
||||
uint32_t idle_time = lv_timer_handler();
|
||||
|
||||
if (platform_is_pc()) {
|
||||
// SDL backend
|
||||
usleep(idle_time * 1000);
|
||||
} else {
|
||||
lv_chart_set_next_value(myChart, ser, val);
|
||||
// ESP32 : task FreeRTOS
|
||||
vTaskDelay(pdMS_TO_TICKS(idle_time));
|
||||
}
|
||||
display_unlock("updateChart");
|
||||
}
|
||||
break;
|
||||
case IHM_EVT_ETAT_MACHINE:
|
||||
if (display_lock("updateChart")) {
|
||||
char * etatMachine = xReceivedEvent->pvData;
|
||||
ESP_LOGE(TAG,"Etat Machine : %s", etatMachine);
|
||||
cJSON *root = cJSON_Parse(etatMachine);
|
||||
bool enRoute = cJSON_GetObjectItem(root,"state")->valueint;
|
||||
int depuisQuand= cJSON_GetObjectItem(root,"timestamp")->valueint;
|
||||
ESP_LOGE(TAG,"Timestamp lu : %i", depuisQuand);
|
||||
time_t rawtime = (time_t)(depuisQuand);
|
||||
struct tm *heure_locale = localtime(&rawtime);
|
||||
char heureFormattee[50];
|
||||
strftime(heureFormattee, sizeof(heureFormattee), "%d/%m/%Y %H:%M:%S", heure_locale);
|
||||
ESP_LOGE(TAG,"Heure: %s", heureFormattee);
|
||||
char etatFormate[90];
|
||||
if(enRoute){
|
||||
sprintf(etatFormate,"Machine en route depuis %s", heureFormattee);
|
||||
}else{
|
||||
sprintf(etatFormate,"Machine : Arrêt détecté depuis %s", heureFormattee);
|
||||
}
|
||||
ESP_LOGE(TAG,"%s", etatFormate);
|
||||
lv_label_set_text(lblEtatMachine,etatFormate);
|
||||
display_unlock("updateChart");
|
||||
}
|
||||
break;
|
||||
|
||||
case IHM_EVT_HAUTEUR_CUVE:
|
||||
if (display_lock("updateCuve")) {
|
||||
float hauteur = *(float *)xReceivedEvent->pvData;
|
||||
lv_label_set_text_fmt(lblHauteurCuve, "%.0f cm", hauteur);
|
||||
display_unlock("updateCuve");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ESP_LOGE(TAG, "Evt inconnu");
|
||||
break;
|
||||
}
|
||||
|
||||
ESP_LOGE(TAG,"Evt IHM Traité on nettoie la memoire");
|
||||
// Nettoyage mémoire sécurisé
|
||||
if (xReceivedEvent->bNeedToFreeData && xReceivedEvent->pvData) {
|
||||
free(xReceivedEvent->pvData);
|
||||
}
|
||||
free(xReceivedEvent);
|
||||
ESP_LOGE(TAG,"Evt IHM Traité !");
|
||||
}
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,6 +229,14 @@ void init_display_ihm(){
|
||||
bsp_display_brightness_set(50);
|
||||
*/
|
||||
mainState.display_init=true;
|
||||
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
|
||||
lv_subject_init_pointer(&timeSubj, &timeinfo);
|
||||
|
||||
}
|
||||
|
||||
lv_obj_t * otaStatus;
|
||||
@ -529,13 +457,17 @@ static void weatherdata_obs_cb(lv_observer_t *observer, lv_subject_t *subject)
|
||||
// Retrieve weatherdata
|
||||
const struct meteodailyforecast_data *data = subject->value.pointer;
|
||||
bool isMinimal = observer->user_data;
|
||||
ESP_LOGI(TAG, "CB meteo jour declenché. Meteo valide : %i - Mode minimal : %d", data->isValid, isMinimal);
|
||||
ESP_LOGI(TAG, "CB meteo jour declenché. Meteo valide : %b - Mode minimal : %d", data->isValid, isMinimal);
|
||||
if(!data->isValid){
|
||||
ESP_LOGI(TAG,"Données meteo non valides");
|
||||
return;
|
||||
}
|
||||
// printffd(data);
|
||||
char buff[40] = {};
|
||||
sprintf(buff,"%s %.1f %.1f", data->previsions.desc, data->previsions.min, data->previsions.max);
|
||||
ESP_LOGI(TAG, "CB meteo jour declenché. Meteo valide : %s", buff);
|
||||
if (data->isValid)
|
||||
{
|
||||
char buff[40] = {};
|
||||
snprintf(buff,sizeof(buff),"%s %.1f %.1f", data->previsions.desc, data->previsions.min, data->previsions.max);
|
||||
ESP_LOGI(TAG, "CB meteo jour declenché. Meteo valide : %s", buff);
|
||||
lv_obj_t *parent = (lv_obj_t *)(lv_observer_get_target(observer));
|
||||
lv_obj_dump_tree(parent->parent);
|
||||
ESP_LOGI(TAG, "On accede au parent %p %s", (void*)parent, lv_obj_get_name(parent));
|
||||
@ -576,7 +508,7 @@ static void weatherdataH_obs_cb(lv_observer_t *observer, lv_subject_t *subject)
|
||||
|
||||
//printffd(data);
|
||||
char buff[40] = {};
|
||||
sprintf(buff,"%.1f", data->previsions.value);
|
||||
snprintf(buff,sizeof(buff),"%.1f", data->previsions.value);
|
||||
ESP_LOGV(TAG, "On a recu [%s]", buff);
|
||||
|
||||
lv_obj_t *parent = (lv_obj_t *)(lv_observer_get_target(observer));
|
||||
@ -602,8 +534,10 @@ 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 *str1 = "A:/home/marc/domotic/components/domotic_display/images_meteo";
|
||||
char *result = malloc(strlen(str1) + strlen(icon) + 6);
|
||||
sprintf(result, "%s%s.png", str1, icon);
|
||||
int sizeOfStr;
|
||||
sizeOfStr = strlen(str1) + strlen(icon) + 6;
|
||||
char *result = malloc(sizeOfStr);
|
||||
snprintf(result,sizeOfStr, "%s%s.png", str1, icon);
|
||||
ESP_LOGV(TAG,"On affiche l'image %s", result);
|
||||
lv_image_set_src(img, "A:/home/marc/domotic/components/domotic_display/images_meteo/p4j.png");
|
||||
free(result);
|
||||
@ -1184,7 +1118,7 @@ static void time_observer_cb(lv_observer_t *observer, lv_subject_t *subject)
|
||||
LV_UNUSED(subject);
|
||||
lv_obj_t *dateTimeObj = lv_observer_get_target_obj(observer);
|
||||
|
||||
char buf[16];
|
||||
//char buf[16];
|
||||
|
||||
lv_obj_t *spangroup = lv_obj_find_by_name(dateTimeObj, "date"); //lv_obj_get_child_by_id(dateTimeObj, "date");
|
||||
|
||||
@ -1203,9 +1137,9 @@ static void time_observer_cb(lv_observer_t *observer, lv_subject_t *subject)
|
||||
lv_spangroup_refresh(spangroup);
|
||||
|
||||
spangroup = lv_obj_find_by_name(dateTimeObj, "time");
|
||||
sprintf(buff, "%02" LV_PRId32, dateHeure->tm_hour);
|
||||
snprintf(buff,sizeof(buff), "%02" LV_PRId32, dateHeure->tm_hour);
|
||||
lv_span_set_text(lv_spangroup_get_child(spangroup, 0), buff);
|
||||
sprintf(buff, ":%02" LV_PRId32, dateHeure->tm_min);
|
||||
snprintf(buff,sizeof(buff), ":%02" LV_PRId32, dateHeure->tm_min);
|
||||
lv_span_set_text(lv_spangroup_get_child(spangroup, 1), buff);
|
||||
lv_spangroup_refresh(spangroup);
|
||||
|
||||
@ -1662,13 +1596,13 @@ void messageCardContent(lv_obj_t *cont_messages)
|
||||
lv_label_set_text(lblTempExt, LV_SYMBOL_HOME "\xEF\x8B\x8A : 12°C");
|
||||
lv_obj_set_style_text_font(lblTempExt, lv_theme_get_font_large(lblTempExt),0);
|
||||
|
||||
for (size_t i = 0; i < 2; i++)
|
||||
/*for (size_t i = 0; i < 2; i++)
|
||||
{
|
||||
lv_obj_t *lblNextEvt = lv_label_create(subContent);
|
||||
lv_obj_set_style_margin_top(lblNextEvt, 15, 0);
|
||||
lv_label_set_text(lblNextEvt, events[i].affichage);
|
||||
lv_obj_set_style_text_font(lblNextEvt, &roboto_medium_36, 0);
|
||||
}
|
||||
}*/
|
||||
|
||||
lv_obj_t *apps = lv_obj_create(bg_cont);
|
||||
lv_obj_set_size(apps, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
|
||||
110
components/domotic_display/ihm_gateway.c
Normal file
110
components/domotic_display/ihm_gateway.c
Normal file
@ -0,0 +1,110 @@
|
||||
// ihm_gateway.c
|
||||
#include "ihm_gateway.h"
|
||||
#include "ihm.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "platform_detect.h"
|
||||
#include "cJSON.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char *TAG = "IHM_GW";
|
||||
|
||||
|
||||
static QueueHandle_t xIHMEventQueue = NULL;
|
||||
|
||||
QueueHandle_t getIHMQueueHandle(void) {
|
||||
return xIHMEventQueue;
|
||||
}
|
||||
|
||||
void ihm_gateway_init(void) {
|
||||
if (!xIHMEventQueue) {
|
||||
xIHMEventQueue = xQueueCreate(32, sizeof(xIHMEvent_t *));
|
||||
}
|
||||
}
|
||||
|
||||
void ihm_gateway_post_event(xIHMEvent_t *evt) {
|
||||
if (!xIHMEventQueue) return;
|
||||
|
||||
if (platform_is_pc()) {
|
||||
xQueueSend(xIHMEventQueue, &evt, 0); // non bloquant sur PC
|
||||
} else {
|
||||
xQueueSend(xIHMEventQueue, &evt, portMAX_DELAY); // bloquant ESP32
|
||||
}
|
||||
}
|
||||
|
||||
extern lv_subject_t wifiStatus;
|
||||
|
||||
void ihm_gateway_process_queue(void) {
|
||||
if (!xIHMEventQueue) return;
|
||||
|
||||
xIHMEvent_t *evt = NULL;
|
||||
|
||||
if (platform_is_pc()) {
|
||||
if (xQueueReceive(xIHMEventQueue, &evt, 0) != pdTRUE) return;
|
||||
} else {
|
||||
if (xQueueReceive(xIHMEventQueue, &evt, pdMS_TO_TICKS(10)) != pdTRUE) return;
|
||||
}
|
||||
|
||||
if (!evt) return;
|
||||
|
||||
switch (evt->eEventType) {
|
||||
case IHM_EVT_WIFI_STATUS:
|
||||
lv_subject_set_int(&wifiStatus, *(bool *)evt->pvData);
|
||||
break;
|
||||
|
||||
case IHM_EVT_TIME_SETTED:
|
||||
draw_time(evt->pvData);
|
||||
break;
|
||||
|
||||
case IHM_EVT_OTA_STARTED:
|
||||
app_ota_display();
|
||||
break;
|
||||
|
||||
case IHM_EVT_HUMID_TEMP:
|
||||
draw_temp((char *)evt->pvData);
|
||||
break;
|
||||
|
||||
case IHM_EVT_PUISSANCE_EMISE: {
|
||||
int val = *(int*)evt->pvData;
|
||||
//if(val == 0) lv_chart_set_next_value(myChart, ser, LV_CHART_POINT_NONE);
|
||||
//else lv_chart_set_next_value(myChart, ser, val);
|
||||
break;
|
||||
}
|
||||
|
||||
case IHM_EVT_ETAT_MACHINE: {
|
||||
char *etatMachine = evt->pvData;
|
||||
cJSON *root = cJSON_Parse(etatMachine);
|
||||
bool enRoute = cJSON_GetObjectItem(root,"state")->valueint;
|
||||
int timestamp = cJSON_GetObjectItem(root,"timestamp")->valueint;
|
||||
|
||||
time_t rawtime = (time_t)timestamp;
|
||||
struct tm *heure_locale = localtime(&rawtime);
|
||||
char heureFormattee[50];
|
||||
strftime(heureFormattee, sizeof(heureFormattee), "%d/%m/%Y %H:%M:%S", heure_locale);
|
||||
|
||||
char etatFormate[90];
|
||||
snprintf(etatFormate,sizeof(etatFormate),
|
||||
enRoute ? "Machine en route depuis %s" : "Machine : Arrêt détecté depuis %s",
|
||||
heureFormattee);
|
||||
|
||||
//lv_label_set_text(lblEtatMachine, etatFormate);
|
||||
cJSON_Delete(root);
|
||||
break;
|
||||
}
|
||||
|
||||
case IHM_EVT_HAUTEUR_CUVE: {
|
||||
float hauteur = *(float *)evt->pvData;
|
||||
//lv_label_set_text_fmt(lblHauteurCuve, "%.0f cm", hauteur);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ESP_LOGE(TAG, "Evt inconnu");
|
||||
break;
|
||||
}
|
||||
|
||||
// Nettoyage mémoire sécurisé
|
||||
if (evt->bNeedToFreeData && evt->pvData) free(evt->pvData);
|
||||
free(evt);
|
||||
|
||||
}
|
||||
@ -8,10 +8,10 @@ bool bsp_display_lock(int timeout_ms)
|
||||
// If `timeout_ms` is set to -1, the program will block until the condition is met
|
||||
//const TickType_t timeout_ticks = (timeout_ms == -1) ? portMAX_DELAY : pdMS_TO_TICKS(timeout_ms);
|
||||
//return xSemaphoreTakeRecursive(lvgl_mux, timeout_ticks) == pdTRUE;
|
||||
lv_lock();
|
||||
//lv_lock();
|
||||
return true;
|
||||
}
|
||||
void bsp_display_unlock() {
|
||||
//xSemaphoreGiveRecursive(lvgl_mux);
|
||||
lv_unlock();
|
||||
//lv_unlock();
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <time.h>
|
||||
#include "meteofrance.h"
|
||||
#include "lvgl.h"
|
||||
#include "model.h"
|
||||
@ -20,6 +21,9 @@ void draw_tabVolets();
|
||||
void meteoCb(lv_obj_t *base_obj);
|
||||
void drawHome();
|
||||
|
||||
void draw_time(struct tm *dateHeure);
|
||||
void draw_temp(char *tempHumid);
|
||||
|
||||
void create_card();
|
||||
|
||||
void weather_data_retreived_start();
|
||||
|
||||
12
components/domotic_display/include/ihm_gateway.h
Normal file
12
components/domotic_display/include/ihm_gateway.h
Normal file
@ -0,0 +1,12 @@
|
||||
// ihm_gateway.h
|
||||
#pragma once
|
||||
#include "lvgl.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include <stdbool.h>
|
||||
#include "eventsManager.h"
|
||||
|
||||
QueueHandle_t getIHMQueueHandle(void);
|
||||
void ihm_gateway_init(void);
|
||||
void ihm_gateway_post_event(xIHMEvent_t *evt);
|
||||
void ihm_gateway_process_queue(void);
|
||||
13
components/domotic_display/include/platform_detect.h
Normal file
13
components/domotic_display/include/platform_detect.h
Normal file
@ -0,0 +1,13 @@
|
||||
// platform_detect.h
|
||||
#pragma once
|
||||
|
||||
#include "esp_system.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static inline bool platform_is_pc(void) {
|
||||
#if CONFIG_IDF_TARGET_LINUX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@ -2,7 +2,7 @@ dependencies:
|
||||
idf:
|
||||
source:
|
||||
type: idf
|
||||
version: 5.5.1
|
||||
version: 5.5.2
|
||||
lvgl/lvgl:
|
||||
component_hash: 17e68bfd21f0edf4c3ee838e2273da840bf3930e5dbc3bfa6c1190c3aed41f9f
|
||||
dependencies: []
|
||||
|
||||
@ -2,6 +2,7 @@ set(LV_BUILD_USE_KCONFIG ON)
|
||||
idf_component_register(SRCS
|
||||
"test_ihm.c"
|
||||
"../../ihm.c"
|
||||
"../../ihm_gateway.c"
|
||||
"../../lv_theme_domotic.c"
|
||||
"../../model.c"
|
||||
"driver_backends.c"
|
||||
@ -38,6 +39,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -std=gnu++20)
|
||||
endif()
|
||||
|
||||
|
||||
# Currently 'main' for IDF_TARGET=linux is defined in freertos component.
|
||||
# Since we are using a freertos mock here, need to let Catch2 provide 'main'.
|
||||
#target_link_libraries(${COMPONENT_LIB} PRIVATE Catch2WithMain)
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
#include "esp_log.h"
|
||||
#include "eventsManager.h"
|
||||
#include "RemindMe.h"
|
||||
#include "ihm_gateway.h"
|
||||
#include "platform_detect.h"
|
||||
|
||||
esp_mqtt_client_handle_t client;
|
||||
SemaphoreHandle_t lvgl_mux;
|
||||
@ -117,17 +119,16 @@ static void configure_simulator(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
int app_main(int argc, char *argv[]) {
|
||||
// Détecte la plateforme
|
||||
bool isPC = platform_is_pc();
|
||||
|
||||
int app_main(int argc, char *argv[])
|
||||
{
|
||||
/* code */
|
||||
printf("hello\n");
|
||||
|
||||
lvgl_mux = xSemaphoreCreateRecursiveMutex();
|
||||
assert(lvgl_mux);
|
||||
|
||||
init_display_ihm();
|
||||
// Init gateway
|
||||
ihm_gateway_init();
|
||||
startEvtManager();
|
||||
|
||||
if (isPC) {
|
||||
// PC / SDL : loop dans le thread principal
|
||||
/* Initialize LVGL. */
|
||||
lv_init();
|
||||
configure_simulator(argc, argv);
|
||||
@ -140,9 +141,6 @@ int app_main(int argc, char *argv[])
|
||||
lv_sdl_mousewheel_create();
|
||||
lv_sdl_mousewheel_create();
|
||||
|
||||
//size_t watermark = uxTaskGetStackHighWaterMark(NULL);
|
||||
//ESP_LOGI("STACK", "Remaining stack: %d bytes", watermark);
|
||||
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
time(&now);
|
||||
@ -150,6 +148,37 @@ int app_main(int argc, char *argv[])
|
||||
|
||||
lv_subject_init_pointer(&timeSubj, &timeinfo);
|
||||
|
||||
drawIhm(NULL);
|
||||
} else {
|
||||
// ESP32 : créer task FreeRTOS
|
||||
xTaskCreate(drawIhm, "LVGL", 256*1024, NULL, 3, NULL);
|
||||
}
|
||||
|
||||
// Exemple : poster un événement
|
||||
xIHMEvent_t *evt = malloc(sizeof(*evt));
|
||||
evt->eEventType = 1;
|
||||
evt->pvData = strdup("Hello LVGL");
|
||||
evt->bNeedToFreeData = true;
|
||||
ihm_gateway_post_event(evt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int app_main1(int argc, char *argv[])
|
||||
{
|
||||
/* code */
|
||||
printf("hello\n");
|
||||
lvgl_mux = xSemaphoreCreateRecursiveMutex();
|
||||
assert(lvgl_mux);
|
||||
|
||||
init_display_ihm();
|
||||
|
||||
|
||||
//size_t watermark = uxTaskGetStackHighWaterMark(NULL);
|
||||
//ESP_LOGI("STACK", "Remaining stack: %d bytes", watermark);
|
||||
|
||||
|
||||
/*lv_timer_t *clock_timer = lv_timer_create(clock_timer_cb, 1000, NULL);*/
|
||||
|
||||
//draw_ihm();
|
||||
@ -160,14 +189,15 @@ int app_main(int argc, char *argv[])
|
||||
if (!events)
|
||||
{
|
||||
ESP_LOGE("test", "Aucun événement chargé");
|
||||
return 0;
|
||||
//return 0;
|
||||
} // Parcourir tous les événements
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
ESP_LOGI("test", "%s", events[i].affichage);
|
||||
}
|
||||
|
||||
xTaskCreate(drawIhm, "LVGL", 128 * 1024, getIHMQueueHandle(), 3, NULL);
|
||||
xTaskCreate(drawIhm, "LVGL", 14 * 1024, getIHMQueueHandle(), 3, NULL);
|
||||
//drawIhm(getIHMQueueHandle());
|
||||
send_event(EVT_WIFI_CONNECTED,NULL);
|
||||
meteodailyforecast_data dts = {
|
||||
.datetime= time(NULL),
|
||||
@ -179,6 +209,7 @@ int app_main(int argc, char *argv[])
|
||||
.min = 3.30f
|
||||
}
|
||||
};
|
||||
/*
|
||||
extern lv_subject_t forecastD1Subj;
|
||||
extern lv_subject_t forecastD2Subj;
|
||||
extern lv_subject_t forecastD3Subj;
|
||||
@ -187,6 +218,7 @@ int app_main(int argc, char *argv[])
|
||||
lv_subject_set_pointer(&forecastD1Subj, &dts);
|
||||
lv_subject_set_pointer(&forecastD2Subj, &dts);
|
||||
lv_subject_set_pointer(&forecastD3Subj, &dts);
|
||||
*/
|
||||
|
||||
/* Enter the run loop of the selected backend */
|
||||
driver_backends_run_loop();
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS "eventsManager.c" obtain_time.c
|
||||
idf_component_register(SRCS "obtain_time.c" "eventsManager.c" obtain_time.c
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES mqtt)
|
||||
|
||||
@ -14,7 +14,7 @@ static const char *TAG = "evtMgr";
|
||||
|
||||
void startEvtManager(){
|
||||
domotic_event_group = xEventGroupCreate();
|
||||
ihm_queue = xQueueCreate(10,sizeof(xIHMEvent_t *));
|
||||
ihm_queue = getIHMQueueHandle();
|
||||
|
||||
/* Tache updateTime */
|
||||
BaseType_t ret2 = xTaskCreate(&updateTime, "updateTimeTask", 3 * 1024, NULL, 5, NULL);
|
||||
@ -25,10 +25,6 @@ void startEvtManager(){
|
||||
/* Tache updateTime - FIN*/
|
||||
}
|
||||
|
||||
QueueHandle_t getIHMQueueHandle(){
|
||||
return ihm_queue;
|
||||
}
|
||||
|
||||
void send_event(domo_events evt, void* pDatas) {
|
||||
ESP_LOGE(TAG,"On est dans l'event handler %i", evt);
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ void updateTime(void *pvParameter)
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
// strftime(strftime_buf, sizeof(strftime_buf), "%c", &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);
|
||||
snprintf(strftime_buf,sizeof(strftime_buf), "%s %d %s %02d:%02d", days[timeinfo.tm_wday], timeinfo.tm_mday, months[timeinfo.tm_mon], timeinfo.tm_hour, timeinfo.tm_min);
|
||||
localtime_r(&now, &timeinfo);
|
||||
ESP_LOGE(TAG, "%s", strftime_buf);
|
||||
send_event(EVT_TIME_SETTED, &timeinfo);
|
||||
|
||||
@ -4,6 +4,5 @@ issues: https://github.com/lvgl/lvgl/issues
|
||||
repository: git://github.com/lvgl/lvgl.git
|
||||
repository_info:
|
||||
commit_sha: c016f72d4c125098287be5e83c0f1abed4706ee5
|
||||
path: .
|
||||
url: https://lvgl.io/
|
||||
version: 9.4.0
|
||||
|
||||
@ -5,8 +5,8 @@ set(comps heap nvs_flash esp_netif image_downloader fatfs protocol_examples_comm
|
||||
|
||||
if(${IDF_TARGET} STREQUAL "esp32p4")
|
||||
message(STATUS "SIMULATION_QEMU = OOF --> main standard")
|
||||
list(APPEND comps bsp_extra esp32_p4_function_ev_board sdmmc vfs littlefs wifi_logger app_update esp_https_ota espcoredump esp_http_server esp_wifi )
|
||||
idf_component_register(SRCS main.c obtain_time.c communication.c
|
||||
list(APPEND comps esp32_p4_function_ev_board sdmmc vfs littlefs app_update esp_https_ota espcoredump esp_http_server esp_wifi )
|
||||
idf_component_register(SRCS main.c communication.c
|
||||
INCLUDE_DIRS "./include"
|
||||
REQUIRES ${comps}
|
||||
EMBED_TXTFILES ${PROJECT_DIR}/main/ca_cert.pem
|
||||
|
||||
@ -19,14 +19,10 @@ dependencies:
|
||||
esp_lcd_touch_gt911:
|
||||
rules:
|
||||
- if: target in ["esp32p4"]
|
||||
esp_lvgl_port:
|
||||
rules:
|
||||
- if: target in ["esp32p4"]
|
||||
version: 2.6.0
|
||||
idf:
|
||||
version: 5.5.*
|
||||
lvgl/lvgl:
|
||||
version: 9.4.0
|
||||
#espressif/esp32_p4_function_ev_board:
|
||||
# version: "4.1.*"
|
||||
#espressif/esp32_p4_function_ev_board: '*'
|
||||
espressif/esp32_p4_function_ev_board: '*'
|
||||
|
||||
@ -76,6 +76,7 @@ static void wifiStatus_obs_cb(lv_observer_t * observer, lv_subject_t * subject);
|
||||
|
||||
|
||||
lv_subject_t mqttStatus;
|
||||
lv_subject_t wifiStatus;
|
||||
|
||||
extern lv_subject_t tempIntSubj;
|
||||
extern lv_subject_t tempExtSubj;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user