menage
This commit is contained in:
parent
ba266479dd
commit
dfbd28861e
3
components/test_host/.vscode/settings.json
vendored
3
components/test_host/.vscode/settings.json
vendored
@ -1,3 +0,0 @@
|
||||
{
|
||||
"idf.pythonInstallPath": "/usr/bin/python3"
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
idf_component_register(SRC_DIRS main REQUIRES domotic_display)
|
||||
@ -1,14 +0,0 @@
|
||||
[
|
||||
{
|
||||
"evenement": "Fête",
|
||||
"affichage": "Noel est dans %d jour(s)",
|
||||
"date": "2025-12-25",
|
||||
"type": "remaining_days"
|
||||
},
|
||||
{
|
||||
"evenement": "Ecole",
|
||||
"affichage": "La rentrée est dans %d jour(s)",
|
||||
"date": "2026-01-05",
|
||||
"type": "remaining_days"
|
||||
}
|
||||
]
|
||||
@ -1,5 +0,0 @@
|
||||
dependencies:
|
||||
lvgl/lvgl:
|
||||
version: 9.4.0
|
||||
#espressif/esp32_p4_function_ev_board:
|
||||
# version: "4.1.*"
|
||||
@ -1,45 +0,0 @@
|
||||
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"
|
||||
"sdl.c"
|
||||
"../../fonts/montserrat_medium_12.c"
|
||||
"../../fonts/montserrat_medium_18.c"
|
||||
"../../fonts/montserrat_medium_24.c"
|
||||
"../../fonts/roboto_medium_36.c"
|
||||
"../../fonts/roboto_medium_72.c"
|
||||
"../../fonts/vlump_96.c"
|
||||
"../../fonts/super_malibu_80.c"
|
||||
"../../images/wifi_ko.c"
|
||||
"../../images/wifi_ok.c"
|
||||
INCLUDE_DIRS
|
||||
"../../include"
|
||||
"../mock"
|
||||
WHOLE_ARCHIVE
|
||||
REQUIRES lvgl meteofrance RemindMe)
|
||||
|
||||
message("Including SDL2 support")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SDL2 REQUIRED sdl2)
|
||||
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image)
|
||||
|
||||
list(APPEND PKG_CONFIG_LIB ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
|
||||
list(APPEND PKG_CONFIG_INC ${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PUBLIC --coverage -DLV_LVGL_H_INCLUDE_SIMPLE )
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC ${PKG_CONFIG_LIB} --coverage)
|
||||
target_include_directories(${COMPONENT_LIB} PRIVATE ${CMAKE_SOURCE_DIR}/mock ${PKG_CONFIG_INC})
|
||||
target_link_libraries(${COMPONENT_LIB} PRIVATE bsd)
|
||||
|
||||
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)
|
||||
@ -1,97 +0,0 @@
|
||||
/**
|
||||
* @file backends.h
|
||||
*
|
||||
* Interface for abstration layer of a device backend
|
||||
*
|
||||
* Copyright (c) 2025 EDGEMTech Ltd.
|
||||
*
|
||||
* Author: EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
|
||||
*
|
||||
*/
|
||||
#ifndef BACKENDS_H
|
||||
#define BACKENDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/* Prototype of the display initialization functions */
|
||||
typedef lv_display_t *(*display_init_t)(void);
|
||||
|
||||
/* Prototype of the run loop */
|
||||
typedef void (*run_loop_t)(void);
|
||||
|
||||
/* Represents a display driver handle */
|
||||
typedef struct {
|
||||
display_init_t init_display; /* The display creation/initialization function */
|
||||
run_loop_t run_loop; /* The run loop of the driver handle */
|
||||
lv_display_t *display; /* The LVGL display that was created */
|
||||
} display_backend_t;
|
||||
|
||||
/* Prototype for the initialization of an indev driver backend */
|
||||
typedef lv_indev_t *(*indev_init_t)(lv_display_t *display);
|
||||
|
||||
/* Represents an indev driver backend */
|
||||
typedef struct {
|
||||
indev_init_t init_indev;
|
||||
} indev_backend_t;
|
||||
|
||||
/* Regroup all different types of driver backend */
|
||||
typedef union {
|
||||
display_backend_t *display;
|
||||
indev_backend_t *indev;
|
||||
} backend_handle_t;
|
||||
|
||||
/* Define each type of driver backend */
|
||||
typedef enum {
|
||||
BACKEND_DISPLAY,
|
||||
BACKEND_INDEV
|
||||
} backend_type_t;
|
||||
|
||||
/* Driver backend descriptor */
|
||||
typedef struct {
|
||||
backend_handle_t *handle;
|
||||
char *name;
|
||||
backend_type_t type;
|
||||
} backend_t;
|
||||
|
||||
/* Prototype used to register a backend */
|
||||
typedef int (*backend_init_t)(backend_t *);
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/* Graphics backends */
|
||||
int backend_init_fbdev(backend_t *backend);
|
||||
int backend_init_drm(backend_t *backend);
|
||||
int backend_init_sdl(backend_t *backend);
|
||||
int backend_init_glfw3(backend_t *backend);
|
||||
int backend_init_wayland(backend_t *backend);
|
||||
int backend_init_x11(backend_t *backend);
|
||||
|
||||
/* Input device driver backends */
|
||||
int backend_init_evdev(backend_t *backend);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*BACKEND_H*/
|
||||
|
||||
|
||||
@ -1,281 +0,0 @@
|
||||
/**
|
||||
* @file driver_backends.c
|
||||
*
|
||||
* Copyright (c) 2025 EDGEMTech Ltd.
|
||||
*
|
||||
* Author: EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
#include "simulator_util.h"
|
||||
#include "simulator_settings.h"
|
||||
#include "driver_backends.h"
|
||||
|
||||
#include "backends.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/* Catch configuration errors at compile time - checks if no backend was selected */
|
||||
#if LV_USE_SDL == 0 && \
|
||||
LV_USE_WAYLAND == 0 && \
|
||||
LV_USE_LINUX_DRM == 0 && \
|
||||
LV_USE_GLFW == 0 && \
|
||||
LV_USE_X11 == 0 && \
|
||||
LV_USE_LINUX_FBDEV == 0
|
||||
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/* The default backend is the one that will end up at index 0
|
||||
* To add support for a new driver backend add the declaration
|
||||
* and append an entry to the available_backends array
|
||||
*/
|
||||
backend_init_t available_backends[] = {
|
||||
|
||||
#if LV_USE_LINUX_FBDEV
|
||||
backend_init_fbdev,
|
||||
#endif
|
||||
|
||||
#if LV_USE_LINUX_DRM
|
||||
backend_init_drm,
|
||||
#endif
|
||||
|
||||
backend_init_sdl,
|
||||
|
||||
#if LV_USE_WAYLAND
|
||||
backend_init_wayland,
|
||||
#endif
|
||||
|
||||
#if LV_USE_X11
|
||||
backend_init_x11,
|
||||
#endif
|
||||
|
||||
#if LV_USE_GLFW
|
||||
backend_init_glfw3,
|
||||
#endif
|
||||
|
||||
#if LV_USE_EVDEV
|
||||
backend_init_evdev,
|
||||
#endif
|
||||
NULL /* Sentinel */
|
||||
};
|
||||
|
||||
/* Contains the backend descriptors */
|
||||
static backend_t *backends[sizeof(available_backends) / sizeof(available_backends[0])];
|
||||
|
||||
/* Set once the user selects a backend - or it is set to the default backend */
|
||||
static backend_t *sel_display_backend = NULL;
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
/* Contains global simulator settings common to each backend */
|
||||
simulator_settings_t settings;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void driver_backends_register(void)
|
||||
{
|
||||
int i;
|
||||
backend_init_t init_backend;
|
||||
backend_t *b;
|
||||
|
||||
i = 0;
|
||||
if (backends[i] != NULL) {
|
||||
/* backends are already registered - leave */
|
||||
return;
|
||||
}
|
||||
|
||||
while ((init_backend = available_backends[i]) != NULL) {
|
||||
|
||||
b = malloc(sizeof(backend_t));
|
||||
LV_ASSERT_NULL(b);
|
||||
|
||||
b->handle = malloc(sizeof(backend_handle_t));
|
||||
|
||||
init_backend = available_backends[i];
|
||||
LV_ASSERT_NULL(init_backend);
|
||||
|
||||
init_backend(b);
|
||||
backends[i] = b;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
int driver_backends_init_backend(char *backend_name)
|
||||
{
|
||||
backend_t *b;
|
||||
int i;
|
||||
display_backend_t *dispb;
|
||||
indev_backend_t *indevb;
|
||||
|
||||
if (backends[0] == NULL) {
|
||||
LV_LOG_ERROR("Please call driver_backends_register first");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (backend_name == NULL) {
|
||||
|
||||
/*
|
||||
* Set default display backend - which is the first defined
|
||||
* item in available_backends array
|
||||
*/
|
||||
LV_ASSERT_NULL(backends[0]);
|
||||
b = backends[0];
|
||||
|
||||
if (b->type != BACKEND_DISPLAY) {
|
||||
LV_LOG_ERROR("The default backend: %s is not a display driver backend", b->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
backend_name = backends[0]->name;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while ((b = backends[i]) != NULL) {
|
||||
|
||||
/* Check if such a backend exists */
|
||||
if (strcmp(b->name, backend_name) == 0) {
|
||||
|
||||
if (b->type == BACKEND_DISPLAY) {
|
||||
/* Initialize the display */
|
||||
|
||||
dispb = b->handle->display;
|
||||
LV_ASSERT_NULL(dispb->init_display);
|
||||
dispb->display = dispb->init_display();
|
||||
|
||||
if (dispb->display == NULL) {
|
||||
LV_LOG_ERROR("Failed to init display with %s backend", b->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sel_display_backend = b;
|
||||
LV_LOG_INFO("Initialized %s display backend", b->name);
|
||||
break;
|
||||
|
||||
} else if (b->type == BACKEND_INDEV) {
|
||||
/* Initialize input device */
|
||||
|
||||
indevb = b->handle->indev;
|
||||
LV_ASSERT_NULL(indevb->init_indev);
|
||||
|
||||
/* The display driver backend - has to be initialized first */
|
||||
if (sel_display_backend == NULL) {
|
||||
LV_LOG_ERROR(
|
||||
"Failed to init indev backend: %s - display needs to be initialized",
|
||||
b->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
LV_LOG_INFO("Initialized %s indev backend", b->name);
|
||||
|
||||
dispb = sel_display_backend->handle->display;
|
||||
|
||||
LV_ASSERT_NULL(dispb->display);
|
||||
indevb->init_indev(dispb->display);
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int driver_backends_print_supported(void)
|
||||
{
|
||||
int i;
|
||||
backend_t *b;
|
||||
|
||||
i = 0;
|
||||
if (backends[i] == NULL) {
|
||||
LV_LOG_ERROR("Please call driver_backends_register first");
|
||||
return -1;
|
||||
}
|
||||
|
||||
b = backends[i];
|
||||
|
||||
fprintf(stdout, "Default backend: %s\n", b->name);
|
||||
fprintf(stdout, "Supported backends: ");
|
||||
|
||||
while ((b = backends[i++]) != NULL) {
|
||||
fprintf(stdout, "%s ", b->name);
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int driver_backends_is_supported(char *backend_name)
|
||||
{
|
||||
char c;
|
||||
backend_t *b;
|
||||
char *name = backend_name;
|
||||
int i = 0;
|
||||
|
||||
while ((c = *backend_name) != '\0') {
|
||||
*backend_name = toupper(c);
|
||||
backend_name++;
|
||||
}
|
||||
|
||||
while ((b = backends[i++]) != NULL) {
|
||||
if (strcmp(b->name, name) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void driver_backends_run_loop(void)
|
||||
{
|
||||
display_backend_t *dispb;
|
||||
|
||||
if (sel_display_backend != NULL && sel_display_backend->handle->display != NULL) {
|
||||
|
||||
dispb = sel_display_backend->handle->display;
|
||||
dispb->run_loop();
|
||||
|
||||
} else {
|
||||
LV_LOG_ERROR("No backend has been selected - initialize the backend first");
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
/**
|
||||
* @file driver_backends.h
|
||||
*
|
||||
* provides an abstration to support multiple graphical
|
||||
* driver backends at the same time whitout recompiling everything
|
||||
* each time
|
||||
*
|
||||
* E.g: this means LVGL can be compiled with both SDL or X11
|
||||
*
|
||||
* - see backend.h for the details on the interface.
|
||||
* - see the files in display_backends directory for examples
|
||||
* on how to use each driver
|
||||
*
|
||||
* Copyright (c) 2025 EDGEMTech Ltd.
|
||||
*
|
||||
* Author: EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
|
||||
*/
|
||||
|
||||
#ifndef DRIVER_BACKENDS_H
|
||||
#define DRIVER_BACKENDS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*
|
||||
* Register all available backends
|
||||
* This function must be called first before any other
|
||||
* function
|
||||
*/
|
||||
void driver_backends_register(void);
|
||||
|
||||
/**
|
||||
* Initialize the specified backend
|
||||
* @description in case of a display driver backend
|
||||
* - create the lv_display, in case of a indev driver backend
|
||||
* create an input device
|
||||
*
|
||||
* @param backend_name the name of the backend to initialize FBDEV,DRM etc
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int driver_backends_init_backend(char *backend_name);
|
||||
|
||||
/**
|
||||
* @brief Checks if a backend exists and is supported
|
||||
* @param backend_name the backend name to check
|
||||
* @return 1 is supported, 0 not supported or invalid name
|
||||
*/
|
||||
int driver_backends_is_supported(char *backend_name);
|
||||
|
||||
/**
|
||||
* @brief Print supported backends
|
||||
* @description Prints a list of supported backends
|
||||
*
|
||||
* @return -1 if an error occurred, 0 on success
|
||||
*/
|
||||
int driver_backends_print_supported(void);
|
||||
|
||||
/**
|
||||
* @brief Enter the run loop
|
||||
* @description enter the run loop of the selected backend
|
||||
*/
|
||||
void driver_backends_run_loop(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*DRIVER_BACKENDS_H*/
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
dependencies:
|
||||
lvgl/lvgl:
|
||||
version: 9.4.0
|
||||
#espressif/esp32_p4_function_ev_board:
|
||||
# version: "4.1.*"
|
||||
@ -1,115 +0,0 @@
|
||||
/**
|
||||
* @file sdl.c
|
||||
*
|
||||
* The backend for the SDL simulator
|
||||
*
|
||||
* Based on the original file from the repository
|
||||
*
|
||||
* - Move to a separate file
|
||||
* 2025 EDGEMTech Ltd.
|
||||
*
|
||||
* Author: EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "simulator_util.h"
|
||||
#include "simulator_settings.h"
|
||||
#include "backends.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* EXTERNAL VARIABLES
|
||||
**********************/
|
||||
extern simulator_settings_t settings;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void run_loop_sdl(void);
|
||||
static lv_display_t *init_sdl(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
static char *backend_name = "SDL";
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register the backend
|
||||
* @param backend the backend descriptor
|
||||
* @description configures the descriptor
|
||||
*/
|
||||
int backend_init_sdl(backend_t *backend)
|
||||
{
|
||||
LV_ASSERT_NULL(backend);
|
||||
|
||||
backend->handle->display = malloc(sizeof(display_backend_t));
|
||||
LV_ASSERT_NULL(backend->handle->display);
|
||||
|
||||
backend->handle->display->init_display = init_sdl;
|
||||
backend->handle->display->run_loop = run_loop_sdl;
|
||||
backend->name = backend_name;
|
||||
backend->type = BACKEND_DISPLAY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the SDL display driver
|
||||
*
|
||||
* @return the LVGL display
|
||||
*/
|
||||
static lv_display_t *init_sdl(void)
|
||||
{
|
||||
lv_display_t *disp;
|
||||
|
||||
disp = lv_sdl_window_create(settings.window_width, settings.window_height);
|
||||
|
||||
if (disp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return disp;
|
||||
}
|
||||
|
||||
/**
|
||||
* The run loop of the SDL driver
|
||||
*/
|
||||
static void run_loop_sdl(void)
|
||||
{
|
||||
uint32_t idle_time;
|
||||
|
||||
/* Handle LVGL tasks */
|
||||
while (true) {
|
||||
/* Returns the time to the next timer execution */
|
||||
idle_time = lv_timer_handler();
|
||||
usleep(idle_time * 1000);
|
||||
}
|
||||
}
|
||||
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* @file simulator_settings.h
|
||||
*
|
||||
* global simulator settings
|
||||
*
|
||||
* The simulator settings is a global variable defined in
|
||||
* simulator_settings.c
|
||||
*
|
||||
* Copyright (c) 2025 EDGEMTech Ltd.
|
||||
*
|
||||
* Author: EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SIMULATOR_SETTINGS_H
|
||||
#define SIMULATOR_SETTINGS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
uint32_t window_width;
|
||||
uint32_t window_height;
|
||||
bool maximize;
|
||||
bool fullscreen;
|
||||
} simulator_settings_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*SIMULATOR_SETTINGS_H*/
|
||||
@ -1,66 +0,0 @@
|
||||
/**
|
||||
* @file simulator_util.c
|
||||
*
|
||||
* Utility functions
|
||||
* Copyright (c) 2025 EDGEMTech Ltd.
|
||||
*
|
||||
* Based on the original file from the repo
|
||||
*
|
||||
* Author: EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
const char *getenv_default(const char *name, const char *default_val)
|
||||
{
|
||||
const char* value = getenv(name);
|
||||
return value ? value : default_val;
|
||||
}
|
||||
|
||||
|
||||
void die(const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
@ -1,62 +0,0 @@
|
||||
/**
|
||||
* @file simulator_util.h
|
||||
*
|
||||
* simulator_util.h - Header file for the utility functions
|
||||
* used by the simulator
|
||||
*
|
||||
* Copyright (c) 2025 EDGEMTech Ltd.
|
||||
*
|
||||
* Author: EDGEMTech Ltd, Erik Tagirov (erik.tagirov@edgemtech.ch)
|
||||
*/
|
||||
|
||||
#ifndef SIMULATOR_UTIL_H
|
||||
#define SIMULATOR_UTIL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* @description Wrapper around getenv(3), allowing to set a default value
|
||||
* @param name The name of the environment variable
|
||||
* @param dflt The default value to set if the variable is not present.
|
||||
* @return default value or value of environment variable.
|
||||
*/
|
||||
const char *getenv_default(const char *name, const char *default_val);
|
||||
|
||||
|
||||
/**
|
||||
* @description Centralized exit point, called due to an error
|
||||
* @param msg The message to display on stderr before killing the program
|
||||
* @param ... Values for the format string.
|
||||
*/
|
||||
void die(const char *msg, ...);
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*SIMULATOR_UTIL_H*/
|
||||
@ -1,229 +0,0 @@
|
||||
|
||||
#define LV_USE_SDL 1
|
||||
#define LV_FONT_DEFAULT &roboto_medium_36
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ihm.h"
|
||||
#include "mqtt_client.h"
|
||||
#include "backends.h"
|
||||
#include <unistd.h>
|
||||
#include "driver_backends.h"
|
||||
#include "simulator_util.h"
|
||||
#include "simulator_settings.h"
|
||||
#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;
|
||||
|
||||
/* contains the name of the selected backend if user
|
||||
* has specified one on the command line */
|
||||
static char *selected_backend;
|
||||
|
||||
/* Global simulator settings, defined in lv_linux_backend.c */
|
||||
extern simulator_settings_t settings;
|
||||
|
||||
void die(const char *msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, msg);
|
||||
vfprintf(stderr, msg, args);
|
||||
va_end(args);
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Print LVGL version
|
||||
*/
|
||||
static void print_lvgl_version(void)
|
||||
{
|
||||
fprintf(stdout, "%d.%d.%d-%s\n",
|
||||
LVGL_VERSION_MAJOR,
|
||||
LVGL_VERSION_MINOR,
|
||||
LVGL_VERSION_PATCH,
|
||||
LVGL_VERSION_INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Print usage information
|
||||
*/
|
||||
static void print_usage(void)
|
||||
{
|
||||
fprintf(stdout, "\nlvglsim [-V] [-B] [-b backend_name] [-W window_width] [-H window_height]\n\n");
|
||||
fprintf(stdout, "-V print LVGL version\n");
|
||||
fprintf(stdout, "-B list supported backends\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configure simulator
|
||||
* @description process arguments recieved by the program to select
|
||||
* appropriate options
|
||||
* @param argc the count of arguments in argv
|
||||
* @param argv The arguments
|
||||
*/
|
||||
static void configure_simulator(int argc, char **argv)
|
||||
{
|
||||
int opt = 0;
|
||||
|
||||
selected_backend = NULL;
|
||||
driver_backends_register();
|
||||
|
||||
const char *env_w = getenv("LV_SIM_WINDOW_WIDTH");
|
||||
const char *env_h = getenv("LV_SIM_WINDOW_HEIGHT");
|
||||
/* Default values */
|
||||
settings.window_width = atoi(env_w ? env_w : "1024");
|
||||
settings.window_height = atoi(env_h ? env_h : "600");
|
||||
|
||||
/* Parse the command-line options. */
|
||||
while ((opt = getopt (argc, argv, "b:fmW:H:BVh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
print_usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'V':
|
||||
print_lvgl_version();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'B':
|
||||
driver_backends_print_supported();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'b':
|
||||
if (driver_backends_is_supported(optarg) == 0) {
|
||||
die("error no such backend: %s\n", optarg);
|
||||
}
|
||||
selected_backend = strdup(optarg);
|
||||
break;
|
||||
case 'W':
|
||||
settings.window_width = atoi(optarg);
|
||||
break;
|
||||
case 'H':
|
||||
settings.window_height = atoi(optarg);
|
||||
break;
|
||||
case ':':
|
||||
print_usage();
|
||||
die("Option -%c requires an argument.\n", optopt);
|
||||
break;
|
||||
case '?':
|
||||
print_usage();
|
||||
die("Unknown option -%c.\n", optopt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int app_main1(int argc, char *argv[]) {
|
||||
// Détecte la plateforme
|
||||
bool isPC = platform_is_pc();
|
||||
|
||||
// Init gateway
|
||||
ihm_gateway_init();
|
||||
startEvtManager();
|
||||
|
||||
if (isPC) {
|
||||
// PC / SDL : loop dans le thread principal
|
||||
/* Initialize LVGL. */
|
||||
lv_init();
|
||||
configure_simulator(argc, argv);
|
||||
/* Initialize the configured backend */
|
||||
if (driver_backends_init_backend(selected_backend) == -1) {
|
||||
die("Failed to initialize display backend");
|
||||
}
|
||||
lv_sdl_mouse_create();
|
||||
lv_sdl_keyboard_create();
|
||||
lv_sdl_mousewheel_create();
|
||||
lv_sdl_mousewheel_create();
|
||||
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
|
||||
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_main2(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();
|
||||
startEvtManager();
|
||||
|
||||
int count=0;
|
||||
events=get_events(&count);
|
||||
if (!events)
|
||||
{
|
||||
ESP_LOGE("test", "Aucun événement chargé");
|
||||
//return 0;
|
||||
} // Parcourir tous les événements
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
ESP_LOGI("test", "%s", events[i].affichage);
|
||||
}
|
||||
|
||||
xTaskCreate(drawIhm, "LVGL", 14 * 1024, getIHMQueueHandle(), 3, NULL);
|
||||
//drawIhm(getIHMQueueHandle());
|
||||
send_event(EVT_WIFI_CONNECTED,NULL);
|
||||
meteodailyforecast_data dts = {
|
||||
.datetime= time(NULL),
|
||||
.isValid= true,
|
||||
.previsions = {
|
||||
.desc = "Ensoleillé",
|
||||
.icon = "p4j",
|
||||
.max = 12.40f,
|
||||
.min = 3.30f
|
||||
}
|
||||
};
|
||||
/*
|
||||
extern lv_subject_t forecastD1Subj;
|
||||
extern lv_subject_t forecastD2Subj;
|
||||
extern lv_subject_t forecastD3Subj;
|
||||
ESP_LOGI("test_ihm", "Setting forecastD1Subj");
|
||||
|
||||
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();
|
||||
|
||||
//drawIhm(getIHMQueueHandle());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
int bsp_display_lock(int arg){
|
||||
return 1;
|
||||
}
|
||||
void bsp_display_unlock(){
|
||||
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
#define BIT0 0x00000001
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
|
||||
typedef enum {
|
||||
WIFI_EVENT_WIFI_READY = 0, /**< WiFi ready */
|
||||
WIFI_EVENT_SCAN_DONE, /**< finish scanning AP */
|
||||
WIFI_EVENT_STA_START, /**< station start */
|
||||
WIFI_EVENT_STA_STOP, /**< station stop */
|
||||
WIFI_EVENT_STA_CONNECTED, /**< station connected to AP */
|
||||
WIFI_EVENT_STA_DISCONNECTED, /**< station disconnected from AP */
|
||||
WIFI_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by station changed */
|
||||
WIFI_EVENT_STA_GOT_IP, /**< station got IP from connected AP */
|
||||
WIFI_EVENT_STA_WPS_ER_SUCCESS, /**< station wps succeeds in enrollee mode */
|
||||
WIFI_EVENT_STA_WPS_ER_FAILED, /**< station wps fails in enrollee mode */
|
||||
WIFI_EVENT_STA_WPS_ER_TIMEOUT, /**< station wps timeout in enrollee mode */
|
||||
WIFI_EVENT_STA_WPS_ER_PIN, /**< station wps pin code in enrollee mode */
|
||||
WIFI_EVENT_AP_START, /**< soft-AP start */
|
||||
WIFI_EVENT_AP_STOP, /**< soft-AP stop */
|
||||
WIFI_EVENT_AP_STACONNECTED, /**< a station connected to soft-AP */
|
||||
WIFI_EVENT_AP_STADISCONNECTED, /**< a station disconnected from soft-AP */
|
||||
WIFI_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
|
||||
WIFI_EVENT_AP_STA_GOT_IP6, /**< station or ap interface v6IP addr is preferred */
|
||||
WIFI_EVENT_ETH_START, /**< ethernet start */
|
||||
WIFI_EVENT_ETH_STOP, /**< ethernet stop */
|
||||
WIFI_EVENT_ETH_CONNECTED, /**< ethernet phy link up */
|
||||
WIFI_EVENT_ETH_DISCONNECTED, /**< ethernet phy link down */
|
||||
WIFI_EVENT_ETH_GOT_IP, /**< ethernet got IP from connected AP */
|
||||
WIFI_EVENT_MAX
|
||||
} wifi_event_id_t;
|
||||
Loading…
x
Reference in New Issue
Block a user