Compare commits
No commits in common. "5bd2ef288afd63b9e7a5ccf656e28c7850867afa" and "de8d9ede17e37d390258f73ae9c323fee49754db" have entirely different histories.
5bd2ef288a
...
de8d9ede17
@ -1,13 +0,0 @@
|
||||
ARG DOCKER_TAG=latest
|
||||
FROM espressif/idf:${DOCKER_TAG}
|
||||
|
||||
ENV LC_ALL=C.UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
RUN apt-get update -y && apt-get install udev -y
|
||||
|
||||
RUN echo "source /opt/esp/idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
|
||||
|
||||
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
|
||||
|
||||
CMD ["/bin/bash", "-c"]
|
||||
@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "ESP-IDF QEMU",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile"
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {
|
||||
"terminal.integrated.defaultProfile.linux": "bash",
|
||||
"idf.espIdfPath": "/opt/esp/idf",
|
||||
"idf.toolsPath": "/opt/esp",
|
||||
"idf.gitPath": "/usr/bin/git"
|
||||
},
|
||||
"extensions": [
|
||||
"espressif.esp-idf-extension",
|
||||
"espressif.esp-idf-web"
|
||||
]
|
||||
}
|
||||
},
|
||||
"runArgs": ["--privileged"]
|
||||
}
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,9 +1,2 @@
|
||||
build/
|
||||
managed_components/
|
||||
build_slave/
|
||||
CMakeFiles/
|
||||
esp-idf/
|
||||
gdbinit/
|
||||
sdkconfig
|
||||
sdkconfig.old
|
||||
components/domotic_display/test_host/sdkconfig
|
||||
|
||||
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
@ -2,7 +2,7 @@
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ESP-IDF",
|
||||
"compilerPath": "${config:idf.toolsPath}/tools/riscv32-esp-elf/esp-14.2.0_20251107/riscv32-esp-elf/bin/riscv32-esp-elf-gcc",
|
||||
"compilerPath": "${config:idf.toolsPath}/tools/riscv32-esp-elf/esp-14.2.0_20240906/riscv32-esp-elf/bin/riscv32-esp-elf-gcc",
|
||||
"compileCommands": "${config:idf.buildPath}/compile_commands.json",
|
||||
"includePath": [
|
||||
"${config:idf.espIdfPath}/components/**",
|
||||
|
||||
131
.vscode/launch.json
vendored
131
.vscode/launch.json
vendored
@ -16,7 +16,7 @@
|
||||
"name": "Debug LVGL demo with gdb",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/rgb_lcd",
|
||||
"program": "${workspaceFolder}/bin/rgb_lcd",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
@ -32,133 +32,6 @@
|
||||
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug ihm with gdb",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "Build - Build IHM",
|
||||
"program": "${workspaceFolder}/components/domotic_display/test_host/build/nvs_host_test.elf",
|
||||
"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"
|
||||
},
|
||||
"osx": {
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
"windows": {
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug meteofrance with gdb",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/components/meteofrance/testHost/build/my_custom_app.elf",
|
||||
"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"
|
||||
},
|
||||
"osx": {
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
"windows": {
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug main with gdb",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/rgb_lcd.elf",
|
||||
"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"
|
||||
},
|
||||
"osx": {
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
"windows": {
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug remindme with gdb",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "Build - Build IHM",
|
||||
"program": "${workspaceFolder}/components/RemindMe/test/build/remindme_host_test.elf",
|
||||
"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"
|
||||
},
|
||||
"osx": {
|
||||
"MIMode": "lldb"
|
||||
},
|
||||
"windows": {
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Debug comp2 (Linux)",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/components/domotic_display/test_host/build/comp2_test",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
"externalConsole": false,
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "/usr/bin/gdb",
|
||||
"setupCommands": [
|
||||
{
|
||||
"description": "Enable pretty printing",
|
||||
"text": "-enable-pretty-printing"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
18
.vscode/settings.json
vendored
18
.vscode/settings.json
vendored
@ -1,11 +1,11 @@
|
||||
{
|
||||
"C_Cpp.intelliSenseEngine": "default",
|
||||
"idf.espIdfPath": "/home/marc/esp/esp-idf",
|
||||
"idf.pythonBinPath": "/home/marc/.espressif/tools/python/v5.5.2/venv/bin/python3",
|
||||
"idf.espIdfPath": "/home/marc/esp/master/esp-idf",
|
||||
"idf.pythonBinPath": "/home/marc/.espressif/python_env/idf5.3_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-20251215/openocd-esp32/share/openocd/scripts",
|
||||
"OPENOCD_SCRIPTS": "/home/marc/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts",
|
||||
"ESP_ROM_ELF_DIR": "/home/marc/.espressif/tools/esp-rom-elfs/20240305/",
|
||||
"IDF_TARGET": "esp32p4"
|
||||
},
|
||||
@ -105,15 +105,7 @@
|
||||
"bsp_board_extra.h": "c",
|
||||
"display.h": "c",
|
||||
"statemanagement.h": "c",
|
||||
"communication.h": "c",
|
||||
"mqtt_client.h": "c"
|
||||
"communication.h": "c"
|
||||
},
|
||||
"idf.pythonInstallPath": "/usr/bin/python3",
|
||||
"clangd.path": "/home/marc/.espressif/tools/esp-clang/esp-19.1.2_20250312/esp-clang/bin/clangd",
|
||||
"clangd.arguments": [
|
||||
"--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"
|
||||
"idf.pythonInstallPath": "/usr/bin/python3"
|
||||
}
|
||||
|
||||
43
.vscode/tasks.json
vendored
43
.vscode/tasks.json
vendored
@ -33,7 +33,7 @@
|
||||
"isDefault": true
|
||||
},
|
||||
"dependsOn": "Build"
|
||||
},
|
||||
}
|
||||
{
|
||||
"label": "Build - Build project",
|
||||
"type": "shell",
|
||||
@ -73,47 +73,6 @@
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Build - Build IHM",
|
||||
"type": "shell",
|
||||
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py build",
|
||||
"windows": {
|
||||
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py build",
|
||||
"options": {
|
||||
"env": {
|
||||
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/components/domotic_display/test_host/",
|
||||
"env": {
|
||||
"IDF_TARGET": "linux",
|
||||
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
|
||||
}
|
||||
},
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "cpp",
|
||||
"fileLocation": [
|
||||
"autoDetect",
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"pattern": {
|
||||
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3,
|
||||
"severity": 4,
|
||||
"message": 5
|
||||
}
|
||||
}
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Set ESP-IDF Target",
|
||||
"type": "shell",
|
||||
|
||||
@ -1,63 +1,28 @@
|
||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
option(SIMULATION_QEMU "Build for QEMU simulation" OFF)
|
||||
message(STATUS "ROOT:: SIMULATION_QEMU = ${SIMULATION_QEMU}")
|
||||
# -------------------------------------------------
|
||||
# CONFIGURATION AVANT project() : uniquement CMake pur
|
||||
# -------------------------------------------------
|
||||
|
||||
|
||||
|
||||
if(SIMULATION_QEMU)
|
||||
message(STATUS "SIMULATION_QEMU = ON")
|
||||
option(SIMULATION_QEMU "Build for QEMU simulation" ON)
|
||||
set(COMPONENTS
|
||||
components/meteofrance
|
||||
components/domotic_display
|
||||
managed_components/lvgl_lvgl
|
||||
main
|
||||
esp-timer
|
||||
$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs
|
||||
)
|
||||
|
||||
else()
|
||||
message(STATUS "SIMULATION_QEMU = OFF")
|
||||
option(SIMULATION_QEMU "Build for QEMU simulation" OFF)
|
||||
# set(COMPONENTS
|
||||
# components/meteofrance
|
||||
# components/domotic_display
|
||||
# managed_components/lvgl_lvgl
|
||||
# main
|
||||
# $ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs
|
||||
# )
|
||||
endif()
|
||||
#list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/esp_timer")
|
||||
# "Trim" the build. Include the minimal set of components, main and anything it depends on.
|
||||
set(COMPONENTS main)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(rgb_lcd)
|
||||
|
||||
|
||||
# -------------------------------------------------
|
||||
# APRÈS project() : maintenant CONFIG_SIMULATION_QEMU existe
|
||||
# -------------------------------------------------
|
||||
|
||||
if(CONFIG_SIMULATION_QEMU)
|
||||
message(STATUS "Compilation IHM (simulation)")
|
||||
add_compile_definitions(CONFIG_SIMULATION_QEMU=1)
|
||||
|
||||
#add_custom_target(run_ihm
|
||||
# COMMAND ${CMAKE_COMMAND} -E echo "Building and launching IHM native..."
|
||||
# COMMAND ${CMAKE_COMMAND} --build ${CMAKE_SOURCE_DIR}/components/ihm --target all
|
||||
# COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR}/components/ihm ./ihm_simulator
|
||||
#)
|
||||
if(${IDF_TARGET} STREQUAL "esp32p4")
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
/home/marc/esp-dev-kits/examples/esp32-p4-function-ev-board/examples/common_components
|
||||
$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs
|
||||
)
|
||||
else()
|
||||
message(STATUS "Compilation standard")
|
||||
#add_link_options("-Wl,--disable-non-contiguous-regions")
|
||||
add_compile_options(
|
||||
-fsanitize=address
|
||||
-fno-omit-frame-pointer
|
||||
-O0
|
||||
-g
|
||||
)
|
||||
# PROJECT_PLATFORM_LINUX
|
||||
# PROJECT_PLATFORM_ESP32
|
||||
add_compile_definitions(PROJECT_PLATFORM_LINUX)
|
||||
|
||||
add_link_options(-fsanitize=address)
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
$ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/FreeRTOS
|
||||
"/home/marc/esp-protocols/common_components/linux_compat"
|
||||
"/home/marc/esp-protocols/components/mdns/tests/host_test/components"
|
||||
)
|
||||
endif()
|
||||
|
||||
project(rgb_lcd)
|
||||
@ -1,15 +0,0 @@
|
||||
#ifndef FREERTOS_CONFIG_H
|
||||
#define FREERTOS_CONFIG_H
|
||||
|
||||
#define configUSE_PREEMPTION 1
|
||||
#define configUSE_IDLE_HOOK 0
|
||||
#define configUSE_TICK_HOOK 0
|
||||
#define configCPU_CLOCK_HZ ( ( unsigned long ) 80000000 )
|
||||
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
||||
#define configMAX_PRIORITIES 5
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 64 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN 10
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
@ -1,7 +0,0 @@
|
||||
menu "Simulation options"
|
||||
|
||||
config SIMULATION_QEMU
|
||||
bool "Build with QEMU simulation stubs"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
@ -1,7 +1,3 @@
|
||||
docker run -v $PWD:/app -w /app lvfontconv lv_font_conv --bpp 4 --size 24 --no-compress --font Montserrat-Medium.ttf --symbols "0123456789.°èéêûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz :-%," --format lvgl -o montserrat_medium_24.c --font fa-solid-900.ttf --range 61461,0xf0c2,0xf575
|
||||
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,0xf0c2,0xf575
|
||||
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 --font fa-solid-900.ttf --range 61461,0xf0c2,0xf575
|
||||
|
||||
Pour lancer avec qemu:
|
||||
idf.py qemu --graphics --qemu-extra-args "-m 8M -global driver=ssi_psram,property=is_octal,value=true" monitor
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,5 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
idf_component_register(SRCS "RemindMe.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES json spiffs)
|
||||
@ -1,216 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "esp_log.h"
|
||||
#include "cJSON.h"
|
||||
#include "esp_spiffs.h"
|
||||
#include "RemindMe.h"
|
||||
#include <time.h>
|
||||
|
||||
static const char *TAG = "JSON_READER";
|
||||
|
||||
static void copy_json_string(cJSON *item,
|
||||
const char *key,
|
||||
char *dst,
|
||||
size_t dst_size)
|
||||
{
|
||||
cJSON *v = cJSON_GetObjectItem(item, key);
|
||||
if (cJSON_IsString(v) && v->valuestring)
|
||||
{
|
||||
strncpy(dst, v->valuestring, dst_size - 1);
|
||||
dst[dst_size - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
static RemindMeEvent *get_events_from_file(const char *filepath, int *count)
|
||||
{
|
||||
*count = 0;
|
||||
|
||||
FILE *f = fopen(filepath, "r");
|
||||
if (!f)
|
||||
{
|
||||
ESP_LOGE(TAG, "Impossible d'ouvrir le fichier");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
long size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
char *json_string = malloc(size + 1);
|
||||
if (!json_string)
|
||||
{
|
||||
fclose(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fread(json_string, 1, size, f);
|
||||
fclose(f);
|
||||
json_string[size] = 0;
|
||||
|
||||
cJSON *json = cJSON_Parse(json_string);
|
||||
free(json_string);
|
||||
|
||||
if (!cJSON_IsArray(json))
|
||||
{
|
||||
cJSON_Delete(json);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int n = cJSON_GetArraySize(json);
|
||||
if (n == 0)
|
||||
{
|
||||
cJSON_Delete(json);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RemindMeEvent *events = calloc(n, sizeof(RemindMeEvent));
|
||||
if (!events)
|
||||
{
|
||||
cJSON_Delete(json);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
cJSON *item = cJSON_GetArrayItem(json, i);
|
||||
copy_json_string(item, "evenement", events[i].evenement, sizeof(events[i].evenement));
|
||||
copy_json_string(item, "affichage", events[i].affichage, sizeof(events[i].affichage));
|
||||
copy_json_string(item, "date", events[i].date, sizeof(events[i].date));
|
||||
copy_json_string(item, "type", events[i].type, sizeof(events[i].type));
|
||||
}
|
||||
|
||||
cJSON_Delete(json);
|
||||
*count = n;
|
||||
return events;
|
||||
}
|
||||
|
||||
static void read_json_file(const char *filepath, cJSON **root)
|
||||
{
|
||||
|
||||
FILE *f = fopen(filepath, "r");
|
||||
if (!f)
|
||||
{
|
||||
ESP_LOGE(TAG, "Impossible d'ouvrir le fichier");
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(f, 0, SEEK_END);
|
||||
long size = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
char *json_string = malloc(size + 1);
|
||||
if (!json_string)
|
||||
{
|
||||
fclose(f);
|
||||
return;
|
||||
}
|
||||
|
||||
fread(json_string, 1, size, f);
|
||||
fclose(f);
|
||||
json_string[size] = 0;
|
||||
|
||||
*root = cJSON_Parse(json_string);
|
||||
free(json_string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse une date au format "YYYY-MM-DD" et retourne le timestamp
|
||||
*/
|
||||
time_t parse_date(const char *date_str)
|
||||
{
|
||||
struct tm tm = {0};
|
||||
|
||||
// Parser la date (format: YYYY-MM-DD)
|
||||
sscanf(date_str, "%d-%d-%d",
|
||||
&tm.tm_year, &tm.tm_mon, &tm.tm_mday);
|
||||
|
||||
tm.tm_year -= 1900; // Années depuis 1900
|
||||
tm.tm_mon -= 1; // Mois de 0 à 11
|
||||
tm.tm_hour = 0;
|
||||
tm.tm_min = 0;
|
||||
tm.tm_sec = 0;
|
||||
|
||||
return mktime(&tm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calcule le nombre de jours entre maintenant et la date donnée
|
||||
* Retourne un nombre négatif si la date est passée
|
||||
*/
|
||||
int days_until(const char *date_str)
|
||||
{
|
||||
// Obtenir l'heure actuelle
|
||||
time_t now;
|
||||
time(&now);
|
||||
|
||||
// Parser la date cible
|
||||
time_t target = parse_date(date_str);
|
||||
|
||||
// Calculer la différence en secondes
|
||||
double diff_seconds = difftime(target, now);
|
||||
|
||||
// Convertir en jours (arrondi)
|
||||
int days = (int)(diff_seconds / (60 * 60 * 24));
|
||||
|
||||
return days;
|
||||
}
|
||||
|
||||
RemindMeEvent *get_events(int *count)
|
||||
{
|
||||
RemindMeEvent *evts = get_events_from_file(
|
||||
"/spiffs/events.json",
|
||||
count);
|
||||
for (size_t i = 0; i < *count; i++)
|
||||
{
|
||||
sprintf(evts[i].affichage, evts[i].affichage, days_until(evts[i].date));
|
||||
}
|
||||
return evts;
|
||||
|
||||
}
|
||||
esp_err_t events_save_atomic(char *eventsJson)
|
||||
{
|
||||
FILE *f = fopen("/spiffs/events.tmp", "w");
|
||||
if (!f)
|
||||
goto error;
|
||||
|
||||
fwrite(eventsJson, 1, strlen(eventsJson), f);
|
||||
fclose(f);
|
||||
|
||||
rename("/spiffs/events.json", "/spiffs/events.bak");
|
||||
rename("/spiffs/events.tmp", "/spiffs/events.json");
|
||||
//unlink("/spiffs/events.bak");
|
||||
|
||||
free(eventsJson);
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
free(eventsJson);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
void add_event(RemindMeEvent e){
|
||||
int count=0;
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
read_json_file("/spiffs/events.json", &root);
|
||||
printf("%s","####################### AVANT\n");
|
||||
//printf("%s\n",cJSON_Print(root));
|
||||
if (!cJSON_IsArray(root))
|
||||
{
|
||||
ESP_LOGE(TAG, "'root' n'est pas un tableau");
|
||||
return;
|
||||
}else{
|
||||
cJSON *new_event = cJSON_CreateObject();
|
||||
if (!new_event)
|
||||
return;
|
||||
|
||||
cJSON_AddStringToObject(new_event, "evenement", e.evenement);
|
||||
cJSON_AddStringToObject(new_event, "affichage", e.affichage);
|
||||
cJSON_AddStringToObject(new_event, "date", e.date);
|
||||
cJSON_AddStringToObject(new_event, "type", e.type);
|
||||
cJSON_AddItemToArray(root, new_event);
|
||||
}
|
||||
printf("%s", "####################### APRES\n");
|
||||
//printf("%s\n", cJSON_Print(root));
|
||||
char *eventsJson=cJSON_Print(root);
|
||||
events_save_atomic(eventsJson);
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: '>=4.1.0'
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
typedef struct
|
||||
{
|
||||
char evenement[64];
|
||||
char affichage[128];
|
||||
char date[32];
|
||||
char type[40];
|
||||
} RemindMeEvent;
|
||||
|
||||
/**
|
||||
* Charge les événements depuis le fichier JSON
|
||||
* @param count (out) nombre d'événements chargés
|
||||
* @return pointeur vers tableau d'événements ou NULL en cas d'erreur
|
||||
*
|
||||
* ⚠️ L'appelant doit libérer la mémoire avec free()
|
||||
*/
|
||||
RemindMeEvent *get_events(int *count);
|
||||
|
||||
void add_event();
|
||||
@ -1,12 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set(COMPONENTS main)
|
||||
|
||||
list(APPEND EXTRA_COMPONENT_DIRS
|
||||
../../RemindMe
|
||||
)
|
||||
|
||||
|
||||
|
||||
project(remindme_host_test)
|
||||
@ -1,10 +0,0 @@
|
||||
dependencies:
|
||||
idf:
|
||||
source:
|
||||
type: idf
|
||||
version: 5.5.1
|
||||
direct_dependencies:
|
||||
- idf
|
||||
manifest_hash: 2fc18f414627b3fc737adcef5ecbfa3a4f7cff55fd5f96a20734c8d5302b79ed
|
||||
target: linux
|
||||
version: 2.0.0
|
||||
@ -1,4 +0,0 @@
|
||||
idf_component_register(
|
||||
SRCS "main.c"
|
||||
REQUIRES RemindMe
|
||||
)
|
||||
@ -1,28 +0,0 @@
|
||||
#include "RemindMe.h"
|
||||
#include "esp_log.h"
|
||||
int app_main(int argc, char *argv[])
|
||||
{
|
||||
int count=0;
|
||||
|
||||
RemindMeEvent *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);
|
||||
}
|
||||
|
||||
RemindMeEvent e = {
|
||||
.affichage = "Test dans %d jours",
|
||||
.date="2026-12-31",
|
||||
.type="remaining_days",
|
||||
.evenement="test"
|
||||
|
||||
};
|
||||
add_event(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
#include "unity.h"
|
||||
#include "RemindMe.h"
|
||||
|
||||
TEST_CASE("Test lecture JSON", "[RemindMe]")
|
||||
{
|
||||
Event event = {0};
|
||||
esp_err_t ret = read_json_file("/spiffs/test.json", &event);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
}
|
||||
@ -1,37 +0,0 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ESP-IDF",
|
||||
"compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp-elf/esp-14.2.0_20241119/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc",
|
||||
"compileCommands": [
|
||||
"${config:idf.buildPath}/compile_commands.json"
|
||||
],
|
||||
"includePath": [
|
||||
"${config:idf.espIdfPath}/components/**",
|
||||
"${config:idf.espIdfPathWin}/components/**",
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": ["LV_CONF_SKIP"],
|
||||
"browse": {
|
||||
"path": [
|
||||
"${config:idf.espIdfPath}/components",
|
||||
"${config:idf.espIdfPathWin}/components",
|
||||
"${workspaceFolder}"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "linux-host",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": ["LV_CONF_SKIP"],
|
||||
"compilerPath": "/usr/bin/gcc",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "gnu++17",
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
20
components/domotic_display/.vscode/launch.json
vendored
20
components/domotic_display/.vscode/launch.json
vendored
@ -1,20 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"name": "Eclipse CDT GDB Adapter",
|
||||
"program": "${workspaceFolder}/test_host/build/nvs_host_test.elf",
|
||||
"cwd": "${workspaceFolder}/test_host",
|
||||
"linux": {
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "/usr/bin/gdb"
|
||||
},
|
||||
}
|
||||
],
|
||||
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
{
|
||||
"idf.pythonInstallPath": "/usr/bin/python3",
|
||||
"files.associations": {
|
||||
"model.h": "c",
|
||||
"lvgl.h": "c",
|
||||
"lv_init.h": "c",
|
||||
"lv_conf_internal.h": "c"
|
||||
}
|
||||
}
|
||||
@ -1,50 +0,0 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/fonts_symbols.cmake)
|
||||
|
||||
string(JOIN "," LVGL_SYMBOLS ${LVGL_SYMBOLS_CLASSIQUES})
|
||||
message(STATUS "LVGL SYMBOL RANGE = ${LVGL_SYMBOLS}")
|
||||
|
||||
function (make_font fontName fileName fontSize)
|
||||
execute_process(COMMAND podman run -v ${PROJECT_DIR}/components/domotic_display/fonts:/app -w /app lvfontconv lv_font_conv --bpp 4 --size ${fontSize} --no-compress --font ${fontName}.ttf --symbols "0123456789.°àéèêëûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz %,'!? ():/-" --format lvgl -o ${fileName}_${fontSize}.c --font fa-solid-900.ttf --range ${LVGL_SYMBOLS})
|
||||
endfunction()
|
||||
|
||||
make_font(Montserrat-Medium montserrat_medium 12 )
|
||||
make_font(Montserrat-Medium montserrat_medium 18)
|
||||
make_font(Montserrat-Medium montserrat_medium 24)
|
||||
make_font(Roboto-Medium roboto_medium 36)
|
||||
make_font(Roboto-Medium roboto_medium 72)
|
||||
make_font(Super_Malibu super_malibu 80)
|
||||
|
||||
|
||||
#execute_process(COMMAND podman run -v /home/marc/rgb_lcd/components/domotic_display/fonts:/app -w /app lvfontconv lv_font_conv --bpp 4 --size 36 --no-compress --font Roboto-Medium.ttf --symbols "0123456789.°àéèûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz %,'():ê/-" --format lvgl -o roboto_medium_36.c --font fa-solid-900.ttf --range 61461,0xf0c2,0xf575)
|
||||
#execute_process(COMMAND podman run -v /home/marc/rgb_lcd/components/domotic_display/fonts:/app -w /app lvfontconv lv_font_conv --bpp 4 --size 72 --no-compress --font Roboto-Medium.ttf --symbols "0123456789.°àéèûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz %,'():ê/-" --format lvgl -o roboto_medium_72.c --font fa-solid-900.ttf --range 61461,0xf0c2,0xf575)
|
||||
|
||||
|
||||
SET(comps meteofrance eventsManager lvgl RemindMe washingMachineState)
|
||||
if(${IDF_TARGET} STREQUAL "esp32p4" OR ${IDF_TARGET} STREQUAL "esp32s3")
|
||||
#esp32_p4_function_ev_board
|
||||
idf_component_register(SRC_DIRS . fonts
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES ${comps} esp_lvgl_port esp32_p4_function_ev_board )
|
||||
target_compile_options(${COMPONENT_LIB} PUBLIC -DLV_LVGL_H_INCLUDE_SIMPLE)
|
||||
|
||||
lvgl_port_create_c_image("images/wifi_ok.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_create_c_image("images/wifi_ko.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_create_c_image("images/mqtt_ok.png" "images/" "AUTO" "NONE")
|
||||
lvgl_port_create_c_image("images/mqtt_ko.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_add_images(${COMPONENT_LIB} "images/")
|
||||
#littlefs_create_partition_image(littlefs images_meteo FLASH_IN_PROJECT)
|
||||
elseif(${IDF_TARGET} STREQUAL "linux")
|
||||
idf_component_register(SRC_DIRS . fonts images
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES ${comps})
|
||||
message("Including SDL2 support")
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC
|
||||
-Wl,--no-as-needed
|
||||
SDL2
|
||||
-Wl,--as-needed
|
||||
)
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PUBLIC -DLV_LVGL_H_INCLUDE_SIMPLE)
|
||||
endif()
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include "domotic_display.h"
|
||||
|
||||
void func(void)
|
||||
{
|
||||
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,110 +0,0 @@
|
||||
# Symboles perso
|
||||
# --- Weather ---
|
||||
set(MY_SYMBOL_CLOUD 0xf0c2) # cloud | UTF-8: "\xEF\x83\x82"
|
||||
set(MY_SYMBOL_CLOUD_SUN 0xf575) # cloud-sun | UTF-8: "\xEF\x95\xB5"
|
||||
|
||||
# --- Navigation ---
|
||||
set(MY_SYMBOL_UP 0xf077) # chevron-up | UTF-8: "\xEF\x81\xB7"
|
||||
set(MY_SYMBOL_DOWN 0xf078) # chevron-down | UTF-8: "\xEF\x81\xB8"
|
||||
|
||||
# --- Sensors ---
|
||||
set(MY_SYMBOL_THERMOMETER 0xf2ca) # thermometer | UTF-8: "\xEF\x89\xBA"
|
||||
set(MY_SYMBOL_MESSAGE 0xf27a) # message | UTF-8: "\xEF\x89\xBA"
|
||||
|
||||
# --- Location / House ---
|
||||
set(MY_THERMOMETER_IN_HOUSE 0xe1b0) # house-user | UTF-8: "\xEE\x86\xB0"
|
||||
set(MY_THERMOMETER_OUT_HOUSE 0xe1b0) # house-user | UTF-8: "\xEE\x86\xB0"
|
||||
|
||||
|
||||
# ======================================
|
||||
# LVGL symbols (FontAwesome solid mapped)
|
||||
# ======================================
|
||||
|
||||
# --- Base UI ---
|
||||
set(LV_SYMBOL_OK 0xf00c) # check
|
||||
set(LV_SYMBOL_CLOSE 0xf00d) # times
|
||||
set(LV_SYMBOL_POWER 0xf011) # power-off
|
||||
set(LV_SYMBOL_SETTINGS 0xf013) # gear
|
||||
set(LV_SYMBOL_HOME 0xf015) # home
|
||||
set(LV_SYMBOL_DOWNLOAD 0xf019) # download
|
||||
set(LV_SYMBOL_REFRESH 0xf021) # refresh
|
||||
set(LV_SYMBOL_LOCK 0xf023) # lock
|
||||
set(LV_SYMBOL_WIFI 0xf1eb) # wifi
|
||||
set(LV_SYMBOL_BELL 0xf0f3) # bell
|
||||
set(LV_SYMBOL_BATTERY_FULL 0xf240) # battery-full
|
||||
set(LV_SYMBOL_BATTERY_3 0xf241) # battery-3/4
|
||||
set(LV_SYMBOL_BATTERY_2 0xf242) # battery-1/2
|
||||
set(LV_SYMBOL_BATTERY_1 0xf243) # battery-1/4
|
||||
set(LV_SYMBOL_BATTERY_EMPTY 0xf244) # battery-empty
|
||||
|
||||
# --- Navigation ---
|
||||
set(LV_SYMBOL_LEFT 0xf060) # arrow-left
|
||||
set(LV_SYMBOL_RIGHT 0xf061) # arrow-right
|
||||
set(LV_SYMBOL_UP 0xf062) # arrow-up
|
||||
set(LV_SYMBOL_DOWN 0xf063) # arrow-down
|
||||
set(LV_SYMBOL_NEXT 0xf061) # alias RIGHT
|
||||
set(LV_SYMBOL_PREV 0xf060) # alias LEFT
|
||||
|
||||
# --- Media / Actions ---
|
||||
set(LV_SYMBOL_PLAY 0xf04b) # play
|
||||
set(LV_SYMBOL_PAUSE 0xf04c) # pause
|
||||
set(LV_SYMBOL_STOP 0xf04d) # stop
|
||||
set(LV_SYMBOL_EJECT 0xf052) # eject
|
||||
set(LV_SYMBOL_VOLUME_UP 0xf028)
|
||||
set(LV_SYMBOL_VOLUME_DOWN 0xf027)
|
||||
set(LV_SYMBOL_MUTE 0xf026)
|
||||
|
||||
# --- Information ---
|
||||
set(LV_SYMBOL_EYE_OPEN 0xf06e)
|
||||
set(LV_SYMBOL_EYE_CLOSE 0xf070)
|
||||
set(LV_SYMBOL_WARNING 0xf071)
|
||||
set(LV_SYMBOL_INFO 0xf05a)
|
||||
set(LV_SYMBOL_QUESTION 0xf128)
|
||||
|
||||
# --- Time / Status ---
|
||||
set(LV_SYMBOL_CLOCK 0xf017)
|
||||
set(LV_SYMBOL_CALENDAR 0xf073)
|
||||
|
||||
# --- List of symbols used for font generation ---
|
||||
set(LVGL_SYMBOLS_CLASSIQUES
|
||||
${LV_SYMBOL_OK}
|
||||
${LV_SYMBOL_CLOSE}
|
||||
${LV_SYMBOL_POWER}
|
||||
${LV_SYMBOL_SETTINGS}
|
||||
${LV_SYMBOL_HOME}
|
||||
${LV_SYMBOL_DOWNLOAD}
|
||||
${LV_SYMBOL_REFRESH}
|
||||
${LV_SYMBOL_LOCK}
|
||||
${LV_SYMBOL_WIFI}
|
||||
${LV_SYMBOL_BELL}
|
||||
${LV_SYMBOL_BATTERY_FULL}
|
||||
${LV_SYMBOL_BATTERY_3}
|
||||
${LV_SYMBOL_BATTERY_2}
|
||||
${LV_SYMBOL_BATTERY_1}
|
||||
${LV_SYMBOL_BATTERY_EMPTY}
|
||||
${LV_SYMBOL_LEFT}
|
||||
${LV_SYMBOL_RIGHT}
|
||||
${LV_SYMBOL_UP}
|
||||
${LV_SYMBOL_DOWN}
|
||||
${LV_SYMBOL_PLAY}
|
||||
${LV_SYMBOL_PAUSE}
|
||||
${LV_SYMBOL_STOP}
|
||||
${LV_SYMBOL_VOLUME_UP}
|
||||
${LV_SYMBOL_VOLUME_DOWN}
|
||||
${LV_SYMBOL_MUTE}
|
||||
${LV_SYMBOL_EYE_OPEN}
|
||||
${LV_SYMBOL_EYE_CLOSE}
|
||||
${LV_SYMBOL_WARNING}
|
||||
${LV_SYMBOL_INFO}
|
||||
${LV_SYMBOL_QUESTION}
|
||||
${LV_SYMBOL_CLOCK}
|
||||
${LV_SYMBOL_CALENDAR}
|
||||
|
||||
${MY_SYMBOL_CLOUD}
|
||||
${MY_SYMBOL_CLOUD_SUN}
|
||||
${MY_SYMBOL_UP}
|
||||
${MY_SYMBOL_DOWN}
|
||||
${MY_SYMBOL_THERMOMETER}
|
||||
${MY_SYMBOL_MESSAGE}
|
||||
${MY_THERMOMETER_IN_HOUSE}
|
||||
)
|
||||
@ -1,28 +0,0 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: '>=4.1.0'
|
||||
# # Put list of dependencies here
|
||||
# # For components maintained by Espressif:
|
||||
# component: "~1.0.0"
|
||||
# # For 3rd party components:
|
||||
# username/component: ">=1.0.0,<2.0.0"
|
||||
# username2/component2:
|
||||
# version: "~1.0.0"
|
||||
# # For transient dependencies `public` flag can be set.
|
||||
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||
# # All dependencies of `main` are public by default.
|
||||
# public: true
|
||||
espressif/esp_lvgl_port:
|
||||
rules:
|
||||
- if: target in ["esp32p4","esp32, "esp32s3"]
|
||||
version: ^2.7.0
|
||||
lvgl/lvgl:
|
||||
rules:
|
||||
- if: target in ["linux"]
|
||||
version: 9.4.0
|
||||
espressif/esp_lcd_qemu_rgb:
|
||||
rules:
|
||||
- if: target in ["esp32, "esp32s3"]
|
||||
version: ^1
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,115 +0,0 @@
|
||||
// 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"
|
||||
#include "washingMachineState.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 CONFIG_IDF_TARGET_LINUX
|
||||
while (xQueueReceive(xIHMEventQueue, &evt, pdMS_TO_TICKS(0)) == pdTRUE)
|
||||
#else
|
||||
while (xQueueReceive(xIHMEventQueue, &evt, pdMS_TO_TICKS(10)) == pdTRUE)
|
||||
#endif
|
||||
{
|
||||
if (!evt) return;
|
||||
|
||||
UBaseType_t pending = uxQueueMessagesWaiting(xIHMEventQueue);
|
||||
ESP_LOGE(TAG,"Evt recu %d. La queue comporte %d éléments à traiter", evt->eEventType, pending);
|
||||
|
||||
lv_async_call(traiteEvt, evt);
|
||||
}
|
||||
}
|
||||
|
||||
void traiteEvt(void *arg)
|
||||
{
|
||||
xIHMEvent_t *evt = (xIHMEvent_t *)arg;
|
||||
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;
|
||||
WashingMachineState wms = traiteMessage(etatMachine);
|
||||
char etat[80];
|
||||
getEtatMachineStr(wms, etat,80);
|
||||
ESP_LOGE(TAG,"Etat machine : %s", etat);
|
||||
draw_minuteur(etat);
|
||||
// lv_label_set_text(lblEtatMachine, etatFormate);
|
||||
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);
|
||||
ESP_LOGV(TAG, "Evt traité");
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
void func(void);
|
||||
@ -1,2 +0,0 @@
|
||||
bool bsp_display_lock(int timeout_ms){return true;};
|
||||
void bsp_display_unlock(){};
|
||||
@ -1,14 +0,0 @@
|
||||
// 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);
|
||||
|
||||
void traiteEvt(void * evt);
|
||||
@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
#include "lvgl.h"
|
||||
#include "RemindMe.h"
|
||||
|
||||
/* input subjects */
|
||||
extern lv_subject_t timeSubj;
|
||||
|
||||
extern lv_color_t base;
|
||||
extern lv_color_t accent;
|
||||
extern lv_color_t bgColor;
|
||||
|
||||
extern RemindMeEvent *events;
|
||||
@ -1,13 +0,0 @@
|
||||
// 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 false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@ -1,253 +0,0 @@
|
||||
/**
|
||||
* @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 "lvgl_private.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
LV_FONT_DECLARE(montserrat_medium_12)
|
||||
LV_FONT_DECLARE(montserrat_medium_18)
|
||||
LV_FONT_DECLARE(montserrat_medium_24)
|
||||
LV_FONT_DECLARE(roboto_medium_72)
|
||||
|
||||
|
||||
void * theme_domotic;
|
||||
|
||||
#define theme_def (*(domotic_theme_t **)(&theme_domotic))
|
||||
|
||||
#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;
|
||||
lv_style_t btn;
|
||||
lv_style_t card;
|
||||
#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 _domotic_theme_t {
|
||||
lv_theme_t base;
|
||||
my_theme_styles_t styles;
|
||||
lv_color_t color_scr;
|
||||
lv_color_t color_text;
|
||||
lv_color_t color_card;
|
||||
lv_color_t color_grey;
|
||||
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(domotic_theme_t * theme)
|
||||
{
|
||||
theme->color_scr = lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4);
|
||||
theme->color_text = lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4);
|
||||
theme->color_card = lv_color_white();
|
||||
theme->color_grey = lv_palette_lighten(LV_PALETTE_BLUE_GREY, 2);
|
||||
|
||||
style_init_reset(&theme->styles.scr);
|
||||
lv_style_set_bg_opa(&theme->styles.scr, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&theme->styles.scr, theme->color_scr);
|
||||
lv_style_set_text_color(&theme->styles.scr, theme->color_text);
|
||||
lv_style_set_text_font(&theme->styles.scr, theme->base.font_normal);
|
||||
//lv_style_set_pad_row(&theme->styles.scr, PAD_SMALL);
|
||||
//lv_style_set_pad_column(&theme->styles.scr, PAD_SMALL);
|
||||
//lv_style_set_rotary_sensitivity(&theme->styles.scr, theme->disp_dpi / 4 * 256);
|
||||
style_init_reset(&theme->styles.btn);
|
||||
//lv_style_set_radius(&theme->styles.btn,LV_DPX_CALC(theme->disp_dpi, theme->disp_size == DISP_LARGE ? 16 : theme->disp_size == DISP_MEDIUM ? 12: 8));
|
||||
lv_style_set_bg_opa(&theme->styles.btn, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&theme->styles.btn, theme->color_grey);
|
||||
/*if (!(theme->base.flags & MODE_DARK))
|
||||
{
|
||||
lv_style_set_shadow_color(&theme->styles.btn, lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_shadow_width(&theme->styles.btn, LV_DPX(3));
|
||||
lv_style_set_shadow_opa(&theme->styles.btn, LV_OPA_50);
|
||||
lv_style_set_shadow_offset_y(&theme->styles.btn, LV_DPX_CALC(theme->disp_dpi, LV_DPX(4)));
|
||||
}*/
|
||||
lv_style_set_text_color(&theme->styles.btn, theme->color_text);
|
||||
//lv_style_set_pad_hor(&theme->styles.btn, PAD_DEF);
|
||||
//lv_style_set_pad_ver(&theme->styles.btn, PAD_SMALL);
|
||||
//lv_style_set_pad_column(&theme->styles.btn, LV_DPX_CALC(theme->disp_dpi, 5));
|
||||
//lv_style_set_pad_row(&theme->styles.btn, LV_DPX_CALC(theme->disp_dpi, 5));
|
||||
|
||||
style_init_reset(&theme->styles.card);
|
||||
//lv_style_set_radius(&theme->styles.card, RADIUS_DEFAULT);
|
||||
lv_style_set_bg_opa(&theme->styles.card, 10);
|
||||
lv_style_set_bg_color(&theme->styles.card, theme->color_card);
|
||||
lv_style_set_border_color(&theme->styles.card, theme->color_grey);
|
||||
//lv_style_set_border_width(&theme->styles.card, BORDER_WIDTH);
|
||||
lv_style_set_border_post(&theme->styles.card, true);
|
||||
lv_style_set_text_color(&theme->styles.card, theme->color_text);
|
||||
lv_style_set_text_font(&theme->styles.card, theme->base.font_normal);
|
||||
lv_style_set_pad_all(&theme->styles.card, 16);
|
||||
lv_style_set_pad_row(&theme->styles.card, 10);
|
||||
lv_style_set_pad_column(&theme->styles.card, 10);
|
||||
lv_style_set_line_color(&theme->styles.card, lv_palette_main(LV_PALETTE_GREY));
|
||||
//lv_style_set_line_width(&theme->styles.card, LV_DPX_CALC(theme->disp_dpi, 1));
|
||||
}
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
bool lv_theme_domotic_is_inited(void)
|
||||
{
|
||||
domotic_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)
|
||||
{
|
||||
domotic_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(domotic_theme_t));
|
||||
}
|
||||
|
||||
domotic_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_simple = lv_theme_simple_init(disp);
|
||||
lv_theme_set_parent((lv_theme_t *)theme, th_simple);
|
||||
|
||||
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);
|
||||
|
||||
domotic_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;
|
||||
}
|
||||
|
||||
// On ne passe pas par une variable KCONFIG pour ne pas avoir a recompiler
|
||||
const char *borderEnv = getenv("DOM_SHOW_BORDER");
|
||||
int border = atoi(borderEnv ? borderEnv : "0");
|
||||
if(border)
|
||||
lv_obj_set_style_border_width(obj,1,0);
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_obj_class))
|
||||
{
|
||||
lv_obj_add_style(obj, &theme->styles.card, 0);
|
||||
lv_obj_add_style(obj, &theme->styles.scrollbar, LV_PART_SCROLLBAR);
|
||||
//lv_obj_add_style(obj, &theme->styles.scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
|
||||
}
|
||||
//lv_obj_set_style_text_color(obj, lv_color_white(), 0);
|
||||
//lv_obj_set_style_text_font(obj, ((my_theme_t*)theme_domotic)->base.font_normal,0);
|
||||
|
||||
if (lv_obj_check_type(obj, &lv_button_class)){
|
||||
lv_obj_add_style(obj, &theme->styles.btn,0);
|
||||
lv_obj_set_style_text_color(obj, lv_color_black(), 0);
|
||||
lv_obj_set_style_text_font(obj, theme->base.font_large, 0);
|
||||
//lv_obj_set_style_bg_color(obj, lv_color_hex(0x6B6969), 0);
|
||||
lv_obj_set_style_pad_all(obj,10,0);
|
||||
lv_obj_set_style_margin_all(obj, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* 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
|
||||
@ -1,7 +0,0 @@
|
||||
#include "model.h"
|
||||
lv_subject_t timeSubj;
|
||||
RemindMeEvent *events;
|
||||
|
||||
//lv_color_t base = LV_COLOR_MAKE(126, 94, 133);
|
||||
//lv_color_t accent = LV_COLOR_MAKE(204, 16, 16);
|
||||
//lv_color_t bgColor = LV_COLOR_MAKE(235, 199, 158);
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"idf.pythonInstallPath": "/usr/bin/python3"
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set(COMPONENTS main)
|
||||
list(APPEND EXTRA_COMPONENT_DIRS
|
||||
# "$ENV{IDF_PATH}/tools/mocks/freertos/"
|
||||
"$ENV{IDF_PATH}/tools/mocks/esp_timer"
|
||||
../../meteofrance
|
||||
../../stateManagement
|
||||
../../eventsManager
|
||||
../../RemindMe
|
||||
)
|
||||
|
||||
idf_build_set_property(COMPILE_DEFINITIONS "NO_DEBUG_STORAGE" APPEND)
|
||||
project(host_test)
|
||||
|
||||
#add_custom_command(
|
||||
# OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/coverage_report/index.html"
|
||||
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
# COMMAND gcovr --root $ENV{IDF_PATH}/components/nvs_flash --html-details
|
||||
# --exclude ${CMAKE_CURRENT_SOURCE_DIR}/managed_components/*
|
||||
# -o ${CMAKE_CURRENT_BINARY_DIR}/coverage_report/index.html ${CMAKE_CURRENT_BINARY_DIR}
|
||||
# COMMENT "Generate coverage report"
|
||||
# )
|
||||
|
||||
#add_custom_target(coverage
|
||||
# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
# DEPENDS "coverage_report/index.html"
|
||||
# )
|
||||
@ -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,18 +0,0 @@
|
||||
dependencies:
|
||||
idf:
|
||||
source:
|
||||
type: idf
|
||||
version: 5.5.2
|
||||
lvgl/lvgl:
|
||||
component_hash: 17e68bfd21f0edf4c3ee838e2273da840bf3930e5dbc3bfa6c1190c3aed41f9f
|
||||
dependencies: []
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 9.4.0
|
||||
direct_dependencies:
|
||||
- idf
|
||||
- lvgl/lvgl
|
||||
manifest_hash: c3178a7d5dcb1c033d1e27022341dbe9157f2399224612db51cd652145d429de
|
||||
target: linux
|
||||
version: 2.0.0
|
||||
@ -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,230 +0,0 @@
|
||||
|
||||
#define LV_USE_SDL 1
|
||||
#define LV_FONT_DEFAULT &roboto_medium_36
|
||||
|
||||
#include <stdio.h>
|
||||
#include "esp_wifi.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_main(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_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();
|
||||
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;
|
||||
@ -1,14 +0,0 @@
|
||||
# This file was generated using idf.py save-defconfig. It can be edited manually.
|
||||
# Espressif IoT Development Framework (ESP-IDF) 5.5.1 Project Minimal Configuration
|
||||
#
|
||||
CONFIG_IDF_TARGET="linux"
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=12288
|
||||
CONFIG_LV_USE_LOG=y
|
||||
CONFIG_LV_LOG_PRINTF=y
|
||||
CONFIG_LV_FONT_MONTSERRAT_40=y
|
||||
CONFIG_LV_USE_SDL=y
|
||||
CONFIG_LV_BUILD_EXAMPLES=n
|
||||
CONFIG_LV_BUILD_DEMOS=n
|
||||
CONFIG_LV_USE_DRAW_SW_COMPLEX_GRADIENTS=y
|
||||
CONFIG_LV_COLOR_DEPTH_32=y
|
||||
CONFIG_LV_COLOR_DEPTH=32
|
||||
@ -1,3 +0,0 @@
|
||||
idf_component_register(SRCS "obtain_time.c" "eventsManager.c" obtain_time.c
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES mqtt esp_netif)
|
||||
@ -1,145 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "eventsManager.h"
|
||||
#include "esp_log.h"
|
||||
#include "mqtt_client.h"
|
||||
#include "obtain_time.h"
|
||||
#include <time.h>
|
||||
|
||||
EventGroupHandle_t domotic_event_group;
|
||||
QueueHandle_t ihm_queue;
|
||||
//extern esp_mqtt_client_handle_t client;
|
||||
|
||||
static const char *TAG = "evtMgr";
|
||||
|
||||
void startEvtManager(){
|
||||
domotic_event_group = xEventGroupCreate();
|
||||
ihm_queue = getIHMQueueHandle();
|
||||
|
||||
/* Tache updateTime */
|
||||
BaseType_t ret2 = xTaskCreate(&updateTime, "updateTimeTask", 3 * 1024, NULL, 5, NULL);
|
||||
if (ret2 != pdPASS)
|
||||
{
|
||||
ESP_LOGE(TAG, "Impossiblke de creer la tache updateTimeTask %i", ret2);
|
||||
}
|
||||
/* Tache updateTime - FIN*/
|
||||
}
|
||||
|
||||
void send_event(domo_events evt, void* pDatas) {
|
||||
ESP_LOGV(TAG,"On est dans l'event handler %i", evt);
|
||||
|
||||
xIHMEvent_t *ihmEvt = malloc(sizeof(xIHMEvent_t));
|
||||
if (!ihmEvt) {
|
||||
ESP_LOGE(TAG, "malloc failed for event struct");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt) {
|
||||
case EVT_WIFI_CONNECTED: {
|
||||
xEventGroupSetBits(domotic_event_group, WIFI_CONNECTED_BIT);
|
||||
ESP_LOGI(TAG, "connected to AP SSID");
|
||||
|
||||
bool *wifiStatus = malloc(sizeof(bool));
|
||||
if (!wifiStatus) {
|
||||
ESP_LOGE(TAG, "malloc failed for wifiStatus");
|
||||
free(ihmEvt);
|
||||
return;
|
||||
}
|
||||
*wifiStatus = true;
|
||||
|
||||
ihmEvt->eEventType = IHM_EVT_WIFI_STATUS;
|
||||
ihmEvt->pvData = wifiStatus;
|
||||
ihmEvt->bNeedToFreeData = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case EVT_TIME_SETTED:
|
||||
struct tm *msg = (struct tm *)pDatas;
|
||||
struct tm *msg_copy = malloc(sizeof(struct tm));
|
||||
if (!msg_copy)
|
||||
{
|
||||
ESP_LOGE(TAG, "malloc failed for message string");
|
||||
free(ihmEvt);
|
||||
return;
|
||||
}
|
||||
// Vérifier que msg n'est pas NULL avant de copier
|
||||
if (msg == NULL)
|
||||
{
|
||||
fprintf(stderr, "msg est NULL !\n");
|
||||
free(msg_copy);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*msg_copy = *msg;
|
||||
ihmEvt->eEventType = IHM_EVT_TIME_SETTED;
|
||||
ihmEvt->pvData = msg_copy;
|
||||
ihmEvt->bNeedToFreeData = true;
|
||||
break;
|
||||
|
||||
case EVT_BTN_VOLET:
|
||||
//esp_mqtt_client_publish(client, "volets", pDatas, 0, 0, 0);
|
||||
free(ihmEvt); // rien à envoyer à l'IHM
|
||||
return;
|
||||
|
||||
case EVT_PUISSANCE_RECUE:
|
||||
ESP_LOGE(TAG, "Puissance recue %i", *(int*)pDatas);
|
||||
int *data = malloc(sizeof(int));
|
||||
if (!data) {
|
||||
ESP_LOGE(TAG, "malloc failed for puissance_5mn");
|
||||
free(ihmEvt);
|
||||
return;
|
||||
}
|
||||
*data = *(int *)pDatas;
|
||||
ihmEvt->eEventType = IHM_EVT_PUISSANCE_EMISE;
|
||||
ihmEvt->pvData = data;
|
||||
ihmEvt->bNeedToFreeData = true;
|
||||
break;
|
||||
|
||||
case EVT_ETAT_MACHINE:
|
||||
const char *msg2 = (const char *)pDatas;
|
||||
char *msg_copy2 = malloc(strlen(msg2) + 1);
|
||||
if (!msg_copy2) {
|
||||
ESP_LOGE(TAG, "malloc failed for message string");
|
||||
free(ihmEvt);
|
||||
return;
|
||||
}
|
||||
strcpy(msg_copy2, msg2);
|
||||
ihmEvt->eEventType = IHM_EVT_ETAT_MACHINE;
|
||||
ihmEvt->pvData = msg_copy2;
|
||||
ihmEvt->bNeedToFreeData = true;
|
||||
break;
|
||||
|
||||
case EVT_HAUTEUR_CUVE: {
|
||||
float *data = malloc(sizeof(float));
|
||||
if (!data) {
|
||||
ESP_LOGE(TAG, "malloc failed for hauteur_cuve");
|
||||
free(ihmEvt);
|
||||
return;
|
||||
}
|
||||
*data = *(float *)pDatas;
|
||||
ESP_LOGE(TAG, "EVENT_HANDLER -> On a recu %f", *data);
|
||||
ihmEvt->eEventType = IHM_EVT_HAUTEUR_CUVE;
|
||||
ihmEvt->pvData = data;
|
||||
ihmEvt->bNeedToFreeData = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ESP_LOGE(TAG, "Unhandled event type");
|
||||
free(ihmEvt);
|
||||
return;
|
||||
}
|
||||
ESP_LOGE(TAG, "Envoi d'un evt %i a l'IHM", ihmEvt->eEventType);
|
||||
if( ihm_queue != NULL && ihmEvt){
|
||||
if (xQueueSendToFront(ihm_queue, &ihmEvt, pdMS_TO_TICKS(10)) != pdPASS)
|
||||
{
|
||||
ESP_LOGE(TAG, "La queue est pleine");
|
||||
if (ihmEvt->bNeedToFreeData && ihmEvt->pvData)
|
||||
{
|
||||
free(ihmEvt->pvData);
|
||||
}
|
||||
free(ihmEvt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
#define BIT0 0x00000001
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
|
||||
typedef enum eIHMEvent_t{
|
||||
IHM_EVT_WIFI_STATUS,
|
||||
IHM_EVT_TIME_SETTED,
|
||||
IHM_EVT_OTA_STARTED,
|
||||
IHM_EVT_OTA_PROGRESS,
|
||||
IHM_EVT_HUMID_TEMP,
|
||||
IHM_EVT_PUISSANCE_EMISE,
|
||||
IHM_EVT_ETAT_MACHINE,
|
||||
IHM_EVT_HAUTEUR_CUVE,
|
||||
} eIHMEvent_t;
|
||||
|
||||
typedef struct IHM_EVENT
|
||||
{
|
||||
eIHMEvent_t eEventType; /* Tells the receiving task what the event is. */
|
||||
void *pvData; /* Holds or points to any data associated with the event. */
|
||||
bool bNeedToFreeData; // ← Important !
|
||||
} xIHMEvent_t;
|
||||
|
||||
typedef enum domo_events{
|
||||
EVT_WIFI_CONNECTED,
|
||||
EVT_TIME_SETTED,
|
||||
EVT_BTN_VOLET,
|
||||
EVT_PUISSANCE_RECUE,
|
||||
EVT_ETAT_MACHINE,
|
||||
EVT_HAUTEUR_CUVE
|
||||
} domo_events;
|
||||
void startEvtManager();
|
||||
QueueHandle_t getIHMQueueHandle();
|
||||
void send_event(domo_events evt, void *pDatas);
|
||||
@ -1,86 +0,0 @@
|
||||
#include "esp_log.h"
|
||||
#include "obtain_time.h"
|
||||
#include <time.h>
|
||||
#ifdef CONFIG_IDF_TARGET_LINUX
|
||||
#else
|
||||
#include "esp_netif_sntp.h"
|
||||
#include "esp_sntp.h"
|
||||
#endif
|
||||
|
||||
static const char *TAG = "sntp";
|
||||
|
||||
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"};
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_LINUX
|
||||
void updateTime(void *pvParameter)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
char strftime_buf[64];
|
||||
|
||||
// Set timezone to Eastern Standard Time and print local time
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
time(&now);
|
||||
localtime_r(&now, &timeinfo);
|
||||
// strftime(strftime_buf, sizeof(strftime_buf), "%c", &timeinfo);
|
||||
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);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void time_sync_notification_cb(struct timeval *tv)
|
||||
{
|
||||
ESP_LOGI(TAG, "Notification of a time synchronization event");
|
||||
char strftime_buf[64];
|
||||
|
||||
// Set timezone to Eastern Standard Time and print local time
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
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);
|
||||
ESP_LOGE(TAG, "%s", strftime_buf);
|
||||
localtime_r(&now, &timeinfo);
|
||||
send_event(EVT_TIME_SETTED, &timeinfo);
|
||||
}
|
||||
|
||||
void updateTime(void *pvParameter)
|
||||
{
|
||||
|
||||
// Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
|
||||
// number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above)
|
||||
EventBits_t bits = xEventGroupWaitBits(domotic_event_group,
|
||||
WIFI_CONNECTED_BIT,
|
||||
pdFALSE,
|
||||
pdFALSE,
|
||||
portMAX_DELAY);
|
||||
if (bits & WIFI_CONNECTED_BIT)
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing and starting SNTP");
|
||||
esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG("pool.ntp.org");
|
||||
config.sync_cb = time_sync_notification_cb; // Note: This is only needed if we want
|
||||
esp_netif_sntp_init(&config);
|
||||
}
|
||||
|
||||
char strftime_buf[64];
|
||||
time_t now = 0;
|
||||
while (1)
|
||||
{
|
||||
time(&now);
|
||||
setenv("TZ", "CET-1CEST,M3.5.0,M10.5.0/3", 1);
|
||||
tzset();
|
||||
struct tm timeinfo = {0};
|
||||
localtime_r(&now, &timeinfo);
|
||||
sprintf(strftime_buf, "%s %d %s %02d:%02d (%lli mn depuis reboot)", days[timeinfo.tm_wday], timeinfo.tm_mday, months[timeinfo.tm_mon], timeinfo.tm_hour, timeinfo.tm_min, (esp_timer_get_time() / 1000 / 1000 / 60));
|
||||
ESP_LOGE(TAG, "%s", strftime_buf);
|
||||
send_event(EVT_TIME_SETTED, &timeinfo);
|
||||
vTaskDelay(60000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1,5 +1,3 @@
|
||||
set(requires json esp_http_client esp-tls esp_timer)
|
||||
|
||||
idf_component_register(SRCS "image_downloader.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES ${requires})
|
||||
REQUIRES json esp_http_client esp-tls esp_timer )
|
||||
|
||||
@ -199,12 +199,12 @@ void imgdwn(void *domotic_event_group) {
|
||||
if (source_buf == NULL) {
|
||||
ESP_LOGE(TAG, "Initial alloc source_buf failed!");
|
||||
}
|
||||
printf("Free heap after buffers allocation: %zu\n", xPortGetFreeHeapSize());
|
||||
printf("Free heap after buffers allocation: %"PRIu16"\n", xPortGetFreeHeapSize());
|
||||
|
||||
download();
|
||||
|
||||
heap_caps_free(source_buf);
|
||||
printf("Free heap after buffers allocation: %zu\n", xPortGetFreeHeapSize());
|
||||
printf("Free heap after buffers allocation: %"PRIu16"\n", xPortGetFreeHeapSize());
|
||||
vTaskDelay(3600000 / portTICK_PERIOD_MS);
|
||||
|
||||
}else{
|
||||
|
||||
@ -1,11 +1,3 @@
|
||||
#IF(ESP_PLATFORM)
|
||||
idf_component_register(SRCS "meteofrance.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES json esp_http_client esp-tls stateManagement eventsManager)
|
||||
#else()
|
||||
# add_library(meteofrance SHARED
|
||||
# meteofrance.c)
|
||||
# target_include_directories(meteofrance PUBLIC ./include)
|
||||
# target_link_libraries(meteofrance PRIVATE stateManagement FreeRTOS freertos_kernel)
|
||||
|
||||
#endif()
|
||||
REQUIRES json esp_http_client esp-tls stateManagement)
|
||||
|
||||
@ -3,66 +3,62 @@
|
||||
#include "stdbool.h"
|
||||
#include "stateManagement.h"
|
||||
|
||||
/*struct node {
|
||||
struct node *next;
|
||||
int e;
|
||||
};
|
||||
|
||||
struct Hashtable {
|
||||
unsigned Tablesize;
|
||||
struct node *Cells;
|
||||
};
|
||||
*/
|
||||
|
||||
struct dailyforecast_prev
|
||||
{
|
||||
float min;
|
||||
float max;
|
||||
char desc[25];
|
||||
char icon[9];
|
||||
/*struct node {
|
||||
struct node *next;
|
||||
int e;
|
||||
};
|
||||
|
||||
struct forecast_prev
|
||||
{
|
||||
float value;
|
||||
char desc[25];
|
||||
char icon[9];
|
||||
struct Hashtable {
|
||||
unsigned Tablesize;
|
||||
struct node *Cells;
|
||||
};
|
||||
*/
|
||||
|
||||
typedef struct meteodailyforecast_data
|
||||
{
|
||||
time_t datetime;
|
||||
bool isValid;
|
||||
struct dailyforecast_prev previsions;
|
||||
} meteodailyforecast_data;
|
||||
struct dailyforecast_prev{
|
||||
float min;
|
||||
float max;
|
||||
char desc[25];
|
||||
char icon[9];
|
||||
};
|
||||
|
||||
typedef struct meteoforecast_data
|
||||
{
|
||||
time_t datetime;
|
||||
bool isValid;
|
||||
struct forecast_prev previsions;
|
||||
} meteoforecast_data;
|
||||
struct forecast_prev{
|
||||
float value;
|
||||
char desc[25];
|
||||
char icon[9];
|
||||
};
|
||||
|
||||
typedef void (*weather_data_callback)(struct meteodailyforecast_data *datas, struct meteoforecast_data *datasf);
|
||||
typedef void (*weather_data_start_callback)();
|
||||
typedef struct meteodailyforecast_data{
|
||||
time_t datetime;
|
||||
bool isValid;
|
||||
struct dailyforecast_prev previsions;
|
||||
} meteodailyforecast_data;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int humidity;
|
||||
float temperature;
|
||||
float pressure;
|
||||
unsigned long retreival_period;
|
||||
weather_data_callback data_retreived_cb;
|
||||
weather_data_start_callback data_retreived_cb_start;
|
||||
} weather_data;
|
||||
typedef struct meteoforecast_data{
|
||||
time_t datetime;
|
||||
bool isValid;
|
||||
struct forecast_prev previsions;
|
||||
} meteoforecast_data;
|
||||
|
||||
void printdftemp(struct dailyforecast_prev * tmp);
|
||||
void printftemp(struct forecast_prev * tmp);
|
||||
void printfdf(struct meteodailyforecast_data * tmp);
|
||||
void dtToString(time_t, char *buffer);
|
||||
void dtHToString(time_t, char *buffer);
|
||||
void printff(struct meteoforecast_data * tmp);
|
||||
typedef void (*weather_data_callback)(struct meteodailyforecast_data *datas, struct meteoforecast_data *datasf);
|
||||
typedef void (*weather_data_start_callback)();
|
||||
|
||||
typedef struct {
|
||||
unsigned int humidity;
|
||||
float temperature;
|
||||
float pressure;
|
||||
unsigned long retreival_period;
|
||||
weather_data_callback data_retreived_cb;
|
||||
weather_data_start_callback data_retreived_cb_start;
|
||||
} weather_data;
|
||||
|
||||
void printdftemp(struct dailyforecast_prev *tmp);
|
||||
void printftemp(struct forecast_prev *tmp);
|
||||
void printfdf(struct meteodailyforecast_data *tmp);
|
||||
void dtToString(time_t, char *buffer);
|
||||
void dtHToString(time_t, char *buffer);
|
||||
void printff(struct meteoforecast_data *tmp);
|
||||
|
||||
void on_weather_data_retrieval(weather_data_callback data_retreived_cb);
|
||||
void on_weather_data_retrieval_start(weather_data_callback data_retreived_cb);
|
||||
void initialise_weather_data_retrieval(unsigned long retreival_period, void* evtGroup);
|
||||
|
||||
void on_weather_data_retrieval(weather_data_callback data_retreived_cb);
|
||||
void on_weather_data_retrieval_start(weather_data_callback data_retreived_cb);
|
||||
void initialise_weather_data_retrieval(unsigned long retreival_period, void *evtGroup);
|
||||
|
||||
@ -11,6 +11,8 @@
|
||||
|
||||
#include "meteofrance.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
@ -27,7 +29,7 @@ static const char *TAG = "MeteoFrance";
|
||||
Typically only LOCATION_ID may need to be changed
|
||||
*/
|
||||
#define WEB_SERVER "webservice.meteofrance.com" //"192.168.0.10" //"www.example.com"// //"webservice.meteofrance.com"
|
||||
#define WEB_PORT 443 // 5403 //80
|
||||
#define WEB_PORT 80 // 5403 //80
|
||||
#define WEB_URL "/forecast"
|
||||
#define TOKEN "__Wj7dVSTjV9YGu1guveLyDq0g7S7TfTjaHBTPTpO0kj8__"
|
||||
// Location ID to get the weather data for
|
||||
@ -320,7 +322,7 @@ static bool process_response_body(const char *body)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void meteo_task(void* domotic_event_group)
|
||||
static void http_request_task(void* domotic_event_group)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
@ -351,15 +353,12 @@ static void meteo_task(void* domotic_event_group)
|
||||
.query = WEB_QUERY,
|
||||
.event_handler = _http_event_handler,
|
||||
.user_data = local_response_buffer, // Pass address of local buffer to get response
|
||||
.disable_auto_redirect = false,
|
||||
.transport_type = HTTP_TRANSPORT_OVER_SSL,
|
||||
.cert_pem = NULL,
|
||||
.skip_cert_common_name_check = true
|
||||
.disable_auto_redirect = true,
|
||||
};
|
||||
esp_http_client_handle_t client = esp_http_client_init(&config);
|
||||
char url[50];
|
||||
esp_http_client_get_url(client, url, 50);
|
||||
ESP_LOGE(TAG, "%s", url);
|
||||
ESP_LOGV(TAG, "%s", url);
|
||||
|
||||
// GET
|
||||
esp_err_t err = esp_http_client_perform(client);
|
||||
@ -385,7 +384,7 @@ static void meteo_task(void* domotic_event_group)
|
||||
}else{
|
||||
//Ca a échoué on recommence dans 30 secondes
|
||||
ESP_LOGI(TAG, "Données non valides on attend avant de retenter");
|
||||
vTaskDelay(10000 / portTICK_PERIOD_MS);
|
||||
vTaskDelay(30000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}else{
|
||||
|
||||
@ -412,7 +411,7 @@ void initialise_weather_data_retrieval(unsigned long retreival_period, void* dom
|
||||
// http_client_on_process_chunk(&http_client, process_chunk);
|
||||
// http_client_on_disconnected(&http_client, disconnected);
|
||||
TaskHandle_t xHandle = NULL;
|
||||
BaseType_t ret1 = xTaskCreate(&meteo_task, "http_meteof", 20 * 1024, domotic_event_group, configMAX_PRIORITIES-2, &xHandle);
|
||||
BaseType_t ret1 = xTaskCreatePinnedToCore(&http_request_task, "http_meteof", 5 * 1024, domotic_event_group, 5, &xHandle, 1);
|
||||
if(ret1!=pdPASS ){
|
||||
ESP_LOGE(TAG, "Impossible de creer la tache %"PRIi16, ret1);
|
||||
}
|
||||
|
||||
@ -1,15 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set(COMPONENTS main)
|
||||
# This test app doesn't require FreeRTOS, using mock instead
|
||||
list(APPEND EXTRA_COMPONENT_DIRS
|
||||
# "$ENV{IDF_PATH}/tools/mocks/freertos/"
|
||||
"$ENV{IDF_PATH}/tools/mocks/esp_timer"
|
||||
../../meteofrance
|
||||
../../stateManagement
|
||||
../../eventsManager
|
||||
../../RemindMe
|
||||
)
|
||||
|
||||
project(my_custom_app C)
|
||||
@ -1,10 +0,0 @@
|
||||
dependencies:
|
||||
idf:
|
||||
source:
|
||||
type: idf
|
||||
version: 5.5.2
|
||||
direct_dependencies:
|
||||
- idf
|
||||
manifest_hash: 2fc18f414627b3fc737adcef5ecbfa3a4f7cff55fd5f96a20734c8d5302b79ed
|
||||
target: linux
|
||||
version: 2.0.0
|
||||
@ -1,13 +0,0 @@
|
||||
set(LV_BUILD_USE_KCONFIG ON)
|
||||
idf_component_register(SRCS main.c ../../meteofrance.c
|
||||
INCLUDE_DIRS
|
||||
"../../include"
|
||||
WHOLE_ARCHIVE
|
||||
REQUIRES stateManagement freertos json esp_http_client esp-tls
|
||||
EMBED_TXTFILES ../../../../main/ca_cert.pem
|
||||
)
|
||||
|
||||
|
||||
# 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,45 +0,0 @@
|
||||
#include <stddef.h>
|
||||
#include "meteofrance.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_event.h"
|
||||
|
||||
#define BIT0 0x00000001
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
|
||||
|
||||
int main1(int argc, char const *argv[])
|
||||
{
|
||||
/* code */
|
||||
return 0;
|
||||
}
|
||||
|
||||
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("","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])
|
||||
{
|
||||
}
|
||||
|
||||
EventGroupHandle_t domotic_event_group;
|
||||
int app_main(int argc, char *argv[]) {
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
domotic_event_group = xEventGroupCreate();
|
||||
on_weather_data_retrieval_start(weather_data_retreived_start);
|
||||
on_weather_data_retrieval(weather_data_retreived);
|
||||
initialise_weather_data_retrieval(30000, domotic_event_group);
|
||||
xEventGroupSetBits(domotic_event_group, WIFI_CONNECTED_BIT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,9 +1,2 @@
|
||||
IF(ESP_PLATFORM)
|
||||
idf_component_register(SRCS "stateManagement.c"
|
||||
INCLUDE_DIRS "include")
|
||||
else()
|
||||
add_library(stateManagement STATIC
|
||||
stateManagement.c
|
||||
)
|
||||
target_include_directories(stateManagement PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
endif()
|
||||
@ -1,11 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include "stateManagement.h"
|
||||
|
||||
struct state mainState={
|
||||
.wifi_init=false,
|
||||
.display_init=false
|
||||
};
|
||||
|
||||
void func(void)
|
||||
{
|
||||
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
idf_component_register(SRCS "washingMachineState.c" PRIV_REQUIRES json
|
||||
INCLUDE_DIRS "include")
|
||||
@ -1,5 +0,0 @@
|
||||
But:
|
||||
Exposer l'état de la machine à laver
|
||||
Dans sa plus simple expression c'est un listener MQTT
|
||||
L'état de la machine est ensuite émise via une interface
|
||||
Le topic est en retain pour pouvoir garder le dernier état de la machine {etat, timestamp}
|
||||
@ -1,24 +0,0 @@
|
||||
|
||||
typedef enum {
|
||||
LAVEUSE_ARRET,
|
||||
LAVEUSE_REMPLISSAGE,
|
||||
LAVEUSE_LAVAGE,
|
||||
LAVEUSE_RINCAGE,
|
||||
LAVEUSE_ESSORAGE,
|
||||
LAVEUSE_TERMINEE,
|
||||
LAVEUSE_ERREUR
|
||||
} WMState;
|
||||
|
||||
typedef struct {
|
||||
WMState etat; // Indique l'état de la machine
|
||||
double depuis; // timestamp de l'evenement
|
||||
bool ack; // Evenement acquitté ?
|
||||
} WashingMachineState;
|
||||
|
||||
WashingMachineState traiteMessage(char *message);
|
||||
|
||||
void timestampToDate(double timestamp, char* dateStr, size_t dateStrSize);
|
||||
|
||||
WashingMachineState getEtatMachine();
|
||||
void getEtatMachineStr(WashingMachineState wms, char* etat, size_t etatSize);
|
||||
void acknoledge();
|
||||
@ -1,75 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <cJSON.h>
|
||||
#include <esp_log.h>
|
||||
#include "washingMachineState.h"
|
||||
#include <time.h>
|
||||
|
||||
#define TAG "WMS"
|
||||
|
||||
WashingMachineState wms;
|
||||
|
||||
WashingMachineState traiteMessage(char* message){
|
||||
|
||||
cJSON *root = cJSON_Parse(message);
|
||||
char* json = cJSON_PrintUnformatted(root);
|
||||
ESP_LOGE(TAG, "%s", json);
|
||||
|
||||
bool state = cJSON_IsTrue(cJSON_GetObjectItem(root, "state"));
|
||||
double timestamp = cJSON_GetNumberValue(cJSON_GetObjectItem(root, "timestamp"));
|
||||
bool ack = cJSON_HasObjectItem(root,"ack") && cJSON_GetNumberValue(cJSON_GetObjectItem(root,"ack"));
|
||||
|
||||
//char dateStr[80] ;
|
||||
//timestampToDate(timestamp,dateStr,80);
|
||||
|
||||
wms.etat = state?LAVEUSE_LAVAGE:LAVEUSE_ARRET;
|
||||
wms.depuis = timestamp;
|
||||
wms.ack = ack;
|
||||
|
||||
cJSON_Delete(root);
|
||||
|
||||
return wms;
|
||||
}
|
||||
|
||||
void timestampToDate(double timestamp, char* dateStr, size_t dateStrSize)
|
||||
{
|
||||
time_t ts = timestamp;
|
||||
struct tm *pTime = localtime(&ts);
|
||||
|
||||
strftime(dateStr, dateStrSize, "%d/%m/%Y %H:%M:%S", pTime);
|
||||
//printf("Date and french time : %s\n", dateStr);
|
||||
}
|
||||
|
||||
WashingMachineState getEtatMachine(){
|
||||
return wms;
|
||||
}
|
||||
|
||||
void getEtatMachineStr(WashingMachineState wms, char* etat, size_t etatSize)
|
||||
{
|
||||
char* etatStr;
|
||||
switch (wms.etat)
|
||||
{
|
||||
case LAVEUSE_ARRET:
|
||||
/* code */
|
||||
etatStr="Machine arretée";
|
||||
break;
|
||||
|
||||
case LAVEUSE_LAVAGE:
|
||||
/* code */
|
||||
etatStr="Machine en route";
|
||||
break;
|
||||
|
||||
default:
|
||||
etatStr="Etat inconnu";
|
||||
break;
|
||||
}
|
||||
char dateStr[30];
|
||||
timestampToDate(wms.depuis,dateStr,30);
|
||||
|
||||
snprintf(etat,etatSize,"%s depuis %s", etatStr, dateStr);
|
||||
ESP_LOGE(TAG,"%s",etat);
|
||||
|
||||
}
|
||||
|
||||
void acknoledge(){
|
||||
wms.ack=true;
|
||||
}
|
||||
@ -1,18 +1,46 @@
|
||||
dependencies:
|
||||
espressif/bh1750:
|
||||
component_hash: c8cae6dca70fd5fdf5943ae37efbbea6cc41bcb784506e61ea301b3e94dce74b
|
||||
chmorgan/esp-audio-player:
|
||||
component_hash: c8ac1998e9af863bc41b57e592f88d1a5791a0f891485122336ddabbf7a65033
|
||||
dependencies:
|
||||
- name: idf
|
||||
- name: chmorgan/esp-libhelix-mp3
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=4.0'
|
||||
version: '>=1.0.0,<2.0.0'
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=5.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.0.7
|
||||
chmorgan/esp-file-iterator:
|
||||
component_hash: 327091394b9ef5c2cd395a960ab70ae64479e0a8831cbd9925e38895fad93719
|
||||
dependencies:
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=4.1.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.0.0
|
||||
chmorgan/esp-libhelix-mp3:
|
||||
component_hash: cbb76089dc2c5749f7b470e2e70aedc44c9da519e04eb9a67d4c7ec275229e53
|
||||
dependencies:
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=4.1.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 1.0.3
|
||||
espressif/cmake_utilities:
|
||||
component_hash: 351350613ceafba240b761b4ea991e0f231ac7a9f59a9ee901f751bddc0bb18f
|
||||
dependencies:
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=4.1'
|
||||
source:
|
||||
@ -20,116 +48,69 @@ dependencies:
|
||||
type: service
|
||||
version: 0.5.3
|
||||
espressif/eppp_link:
|
||||
component_hash: 9472e6825f4bb71eca2b39cf1bc92659c1ac60bfd7416560ad033a7dd8641b17
|
||||
component_hash: c2fd9c57ac14a68a62c9d9cdeec39a2b265abc16779196ce2c9f5000c9a4dd8b
|
||||
dependencies:
|
||||
- name: espressif/esp_serial_slave_link
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: ^1.1.0
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=5.2'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 1.1.4
|
||||
version: 0.2.0
|
||||
espressif/esp32_p4_function_ev_board:
|
||||
component_hash: 2d90a5160cd2aa81f1bc90edf90d802bdc15626b9ec6d699aa36a35bad119ed9
|
||||
component_hash: 1e0436b3d220275d6b7930330b1a9b828fedf0dbc81006531e592b059842641e
|
||||
dependencies:
|
||||
- name: espressif/esp_codec_dev
|
||||
registry_url: https://components.espressif.com
|
||||
require: public
|
||||
version: ~1.5
|
||||
version: 1.2.*
|
||||
- name: espressif/esp_lcd_ek79007
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=2.0.1,<3.0.0'
|
||||
version: 1.*
|
||||
- name: espressif/esp_lcd_ili9881c
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=1.0.3,<2.0.0'
|
||||
version: 1.*
|
||||
- name: espressif/esp_lcd_touch_gt911
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: ^1
|
||||
- name: espressif/esp_video
|
||||
registry_url: https://components.espressif.com
|
||||
require: public
|
||||
version: ~1.4
|
||||
- name: espressif/esp_lcd_lt8912b
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=0.1.3,<1.0.0'
|
||||
- name: espressif/esp_lvgl_port
|
||||
registry_url: https://components.espressif.com
|
||||
require: public
|
||||
version: ^2
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.4'
|
||||
version: '>=5.3'
|
||||
- name: lvgl/lvgl
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=8,<10'
|
||||
- name: espressif/usb
|
||||
registry_url: https://components.espressif.com
|
||||
require: public
|
||||
rules:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
targets:
|
||||
- esp32p4
|
||||
version: 5.2.1
|
||||
espressif/esp_cam_sensor:
|
||||
component_hash: db5b1c725799dced61e7b100dc027e1e59558c9973d7e1ed8ce42a5ec89da31c
|
||||
dependencies:
|
||||
- name: espressif/cmake_utilities
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: 0.*
|
||||
- name: espressif/esp_sccb_intf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=0.0.5'
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.3'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
targets:
|
||||
- esp32p4
|
||||
- esp32s3
|
||||
- esp32c3
|
||||
- esp32c5
|
||||
- esp32c6
|
||||
- esp32c61
|
||||
version: 1.7.0
|
||||
version: 4.1.1
|
||||
espressif/esp_codec_dev:
|
||||
component_hash: 0d9e9bc288156eb55f79338d312e1ebf8c9dfbd5e7d13ef0f20ccb031b4e15cf
|
||||
component_hash: 014948481bda426cd46714f297fe1891711246c62bea288863a8cc8cf13ef1f0
|
||||
dependencies:
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=4.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 1.5.4
|
||||
espressif/esp_h264:
|
||||
component_hash: fa5daaebc8a304f0b79bc57e51aab43e0a03eabc2ba3865bff4063c56b5d4564
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=4.4'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 1.0.4
|
||||
version: 1.2.0
|
||||
espressif/esp_hosted:
|
||||
component_hash: 5e1f8af8b51b47714eafb30c59bac952d6abc03125c01cb6a970f368d1e1cb83
|
||||
component_hash: fba52659b7d0256b0f6bd497ebce2492bf93506d797935a292f0fd864e364e47
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
@ -137,25 +118,9 @@ dependencies:
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 2.11.7
|
||||
espressif/esp_ipa:
|
||||
component_hash: 31003e536f0d26158e10d7fcf2448b6377ce1148518287d0f34ed3b6c942c6d8
|
||||
dependencies:
|
||||
- name: espressif/cmake_utilities
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: 0.*
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.4'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
targets:
|
||||
- esp32p4
|
||||
version: 1.3.1
|
||||
version: 2.0.1
|
||||
espressif/esp_lcd_ek79007:
|
||||
component_hash: 7a0896e167d88b9fc368ac74b2e84774ec5b48cd9baa390896c4be255d900e2e
|
||||
component_hash: 07c1afab7e9fd4dd2fd06ff9245e65327c5bbd5485efec199496e19a9304d47b
|
||||
dependencies:
|
||||
- name: espressif/cmake_utilities
|
||||
registry_url: https://components.espressif.com
|
||||
@ -169,9 +134,9 @@ dependencies:
|
||||
type: service
|
||||
targets:
|
||||
- esp32p4
|
||||
version: 2.0.2
|
||||
version: 1.0.2
|
||||
espressif/esp_lcd_ili9881c:
|
||||
component_hash: 0288df12755c95d406ccea245a427595f314df0b14a61846286d926ea6f3698e
|
||||
component_hash: f4f374226b62baf13f735864e8fae58e17c537df34d598e059f6caad4761ef65
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
@ -181,47 +146,38 @@ dependencies:
|
||||
type: service
|
||||
targets:
|
||||
- esp32p4
|
||||
version: 1.1.0
|
||||
espressif/esp_lcd_lt8912b:
|
||||
component_hash: f954a3393c8e16159f0c7448c9f4312b58933a53563fe5173db5f63a2b0f7aa7
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.3'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 0.2.0
|
||||
version: 1.0.1
|
||||
espressif/esp_lcd_touch:
|
||||
component_hash: 3f85a7d95af876f1a6ecca8eb90a81614890d0f03a038390804e5a77e2caf862
|
||||
component_hash: 779b4ba2464a3ae85681e4b860caa5fdc35801458c23f3039ee761bae7f442a4
|
||||
dependencies:
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=4.4.2'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 1.2.1
|
||||
version: 1.1.2
|
||||
espressif/esp_lcd_touch_gt911:
|
||||
component_hash: be02e243d18b9a661bc13b0d22c0a5cfa3f708cf04d6eb059772276c8c8a4d76
|
||||
component_hash: acc1c184358aa29ef72506f618c9c76a8cc2bf12af38a2bff3d44d84f3a08857
|
||||
dependencies:
|
||||
- name: espressif/esp_lcd_touch
|
||||
registry_url: https://components.espressif.com
|
||||
require: public
|
||||
version: ^1.2.0
|
||||
version: ^1.1.0
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=4.4.2'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.2.0~1
|
||||
version: 1.1.3
|
||||
espressif/esp_lvgl_port:
|
||||
component_hash: 88bbda87376ae20fabfbb5d794ed78d23b3b4a186ecfafecf2edbf06223fd6c9
|
||||
component_hash: e720c95cf0667554a204591bb5fade4655fb2990465557041200fa44b5bc7556
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.1'
|
||||
version: '>=4.4'
|
||||
- name: lvgl/lvgl
|
||||
registry_url: https://components.espressif.com
|
||||
require: public
|
||||
@ -229,72 +185,20 @@ dependencies:
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 2.7.1
|
||||
espressif/esp_sccb_intf:
|
||||
component_hash: c071b189e49f40940722aea01a5489f873385cc39cd5b14012341135b85d1a9d
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.3'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 0.0.8
|
||||
version: 2.6.0
|
||||
espressif/esp_serial_slave_link:
|
||||
component_hash: ac1776806de0a6e371c84e87898bb983e19ce62aa7f1e2e5c4a3b0234a575d2c
|
||||
component_hash: 8c534b7d4986ca0e4c41db71f559492b795ab862f1d15359d7993034696b7bcc
|
||||
dependencies:
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=5.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 1.1.2
|
||||
espressif/esp_video:
|
||||
component_hash: 2239aed49fa4eb1efdf3b0c2b95b05c03fc8b363c101bc2cd70f5e3bcd3c7cc4
|
||||
dependencies:
|
||||
- name: espressif/cmake_utilities
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: 0.*
|
||||
- name: espressif/esp_cam_sensor
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: 1.7.*
|
||||
- name: espressif/esp_h264
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32p4]
|
||||
version: 1.0.4
|
||||
- name: espressif/esp_ipa
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32p4]
|
||||
version: 1.3.*
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.4'
|
||||
- name: espressif/usb_host_uvc
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32p4, esp32s3]
|
||||
version: 2.4.*
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
targets:
|
||||
- esp32p4
|
||||
- esp32s3
|
||||
- esp32c3
|
||||
- esp32c5
|
||||
- esp32c6
|
||||
- esp32c61
|
||||
version: 1.4.1
|
||||
version: 1.1.0
|
||||
espressif/esp_wifi_remote:
|
||||
component_hash: 20393ed850b2cb40cadcf369b4c852ef5af49e2d89e58774d968c57b0c436fd3
|
||||
component_hash: 6448c379c1dceef7f0dedd30635006118e8b768be884f3804d4a94930556e08c
|
||||
dependencies:
|
||||
- name: espressif/eppp_link
|
||||
registry_url: https://components.espressif.com
|
||||
@ -312,36 +216,13 @@ dependencies:
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 0.14.4
|
||||
espressif/usb_host_uvc:
|
||||
component_hash: 197eae0d1dd5ddec773704653e0ff70e81126b8ccdb62e034ed239f755adb48c
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.0'
|
||||
- name: espressif/usb
|
||||
registry_url: https://components.espressif.com
|
||||
require: public
|
||||
rules:
|
||||
- if: idf_version >=6.0
|
||||
- if: target not in ["linux"]
|
||||
version: ^1.0.0
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
targets:
|
||||
- esp32s2
|
||||
- esp32s3
|
||||
- esp32p4
|
||||
- esp32h4
|
||||
- linux
|
||||
version: 2.4.1
|
||||
version: 0.9.2
|
||||
idf:
|
||||
source:
|
||||
type: idf
|
||||
version: 5.5.2
|
||||
version: 5.5.0
|
||||
joltwallet/littlefs:
|
||||
component_hash: dcea25bcef2de023f089f5f01e8d8c46ad1b8ffef75861ad5ffb4098555839df
|
||||
component_hash: e1dbe782be5aa58e879fe9f22bee60e5ff68acbfe3793d92a2e730c27374c787
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
@ -349,33 +230,36 @@ dependencies:
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.20.4
|
||||
version: 1.19.2
|
||||
lvgl/lvgl:
|
||||
component_hash: 17e68bfd21f0edf4c3ee838e2273da840bf3930e5dbc3bfa6c1190c3aed41f9f
|
||||
component_hash: 2409fdc84e9766d2a18afd84b051aef3f838348136cdb1c10ac2e8bcdb012bf6
|
||||
dependencies: []
|
||||
source:
|
||||
registry_url: https://components.espressif.com
|
||||
type: service
|
||||
version: 9.4.0
|
||||
suda-morris/am2302_rmt:
|
||||
component_hash: 890df8ebfec652eb9f8e1d612959f00a951dbe9241335e5e335fc7fb1468ea32
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.1'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.1.0
|
||||
version: 9.2.0
|
||||
suda-morris/am2302_rmt:
|
||||
component_hash: b46dd8c20dee72654e8ea4a43b16e8a93e984a6c10426392a4b8486fed50ca93
|
||||
dependencies:
|
||||
- name: idf
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '>=5.0'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.0.0
|
||||
direct_dependencies:
|
||||
- espressif/bh1750
|
||||
- chmorgan/esp-audio-player
|
||||
- chmorgan/esp-file-iterator
|
||||
- espressif/esp32_p4_function_ev_board
|
||||
- espressif/esp_lcd_touch_gt911
|
||||
- espressif/esp_lvgl_port
|
||||
- espressif/esp_wifi_remote
|
||||
- idf
|
||||
- joltwallet/littlefs
|
||||
- lvgl/lvgl
|
||||
- suda-morris/am2302_rmt
|
||||
manifest_hash: ff7936466302f0a070f567433bba5708f3bdab0fb5fa4b9941b77ae4ac95532c
|
||||
manifest_hash: fc9086d177c610d5a3ed802c7e759df686413041315e1f9bed4bca07bf42740f
|
||||
target: esp32p4
|
||||
version: 2.0.0
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
idf_component_register(
|
||||
SRCS "bh1750.c"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES "driver"
|
||||
)
|
||||
@ -1,8 +0,0 @@
|
||||
# Component: BH1750
|
||||
|
||||
* This component will show you how to use I2C module read external i2c sensor data, here we use BH1750 light sensor(GY-30 module).
|
||||
* BH1750 measurement mode:
|
||||
* one-time mode: bh1750 just measure only one time when receieved the one time measurement command, so you need to send this command when you want to get intensity value every time
|
||||
* continuous mode: bh1750 will measure continuously when receieved the continuously measurement command, so you just need to send this command once, and than call `bh1750_get_data()` to get intensity value repeatedly.
|
||||
## Notice:
|
||||
* Bh1750 has different measurement time in different measurement mode, and also, measurement time can be changed by call `bh1750_change_measure_time()`
|
||||
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "driver/i2c_master.h"
|
||||
#include "bh1750.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
|
||||
#define BH_1750_MEASUREMENT_ACCURACY 1.2 /*!< the typical measurement accuracy of BH1750 sensor */
|
||||
|
||||
#define BH1750_POWER_DOWN 0x00 /*!< Command to set Power Down*/
|
||||
#define BH1750_POWER_ON 0x01 /*!< Command to set Power On*/
|
||||
|
||||
typedef struct {
|
||||
i2c_port_t bus;
|
||||
uint16_t dev_addr;
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
} bh1750_dev_t;
|
||||
|
||||
static esp_err_t bh1750_write_byte(const bh1750_dev_t *const sens, const uint8_t byte)
|
||||
{
|
||||
esp_err_t ret;
|
||||
ESP_ERROR_CHECK(i2c_master_transmit(sens->dev_handle, &byte, 1, -1));
|
||||
|
||||
/*i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
ret = i2c_master_start(cmd);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_write_byte(cmd, sens->dev_addr | I2C_MASTER_WRITE, true);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_write_byte(cmd, byte, true);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_stop(cmd);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_cmd_begin(sens->bus, cmd, 1000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
return ret;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
bh1750_handle_t bh1750_create(i2c_port_t port, const uint16_t dev_addr, i2c_master_bus_handle_t bus_handle)
|
||||
{
|
||||
bh1750_dev_t *sensor = (bh1750_dev_t *) calloc(1, sizeof(bh1750_dev_t));
|
||||
sensor->bus = port;
|
||||
sensor->dev_addr = dev_addr << 1;
|
||||
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = dev_addr,
|
||||
.scl_speed_hz = 100000,
|
||||
};
|
||||
i2c_master_dev_handle_t dev_handle;
|
||||
ESP_ERROR_CHECK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &(sensor->dev_handle)));
|
||||
return (bh1750_handle_t) sensor;
|
||||
|
||||
}
|
||||
|
||||
esp_err_t bh1750_delete(bh1750_handle_t sensor)
|
||||
{
|
||||
bh1750_dev_t *sens = (bh1750_dev_t *) sensor;
|
||||
free(sens);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bh1750_power_down(bh1750_handle_t sensor)
|
||||
{
|
||||
bh1750_dev_t *sens = (bh1750_dev_t *) sensor;
|
||||
return bh1750_write_byte(sens, BH1750_POWER_DOWN);
|
||||
}
|
||||
|
||||
esp_err_t bh1750_power_on(bh1750_handle_t sensor)
|
||||
{
|
||||
bh1750_dev_t *sens = (bh1750_dev_t *) sensor;
|
||||
return bh1750_write_byte(sens, BH1750_POWER_ON);
|
||||
}
|
||||
|
||||
esp_err_t bh1750_set_measure_time(bh1750_handle_t sensor, const uint8_t measure_time)
|
||||
{
|
||||
bh1750_dev_t *sens = (bh1750_dev_t *) sensor;
|
||||
uint32_t i = 0;
|
||||
uint8_t buf[2] = {0x40, 0x60}; // constant part of the the MTreg
|
||||
buf[0] |= measure_time >> 5;
|
||||
buf[1] |= measure_time & 0x1F;
|
||||
for (i = 0; i < 2; i++) {
|
||||
esp_err_t ret = bh1750_write_byte(sens, buf[i]);
|
||||
if (ESP_OK != ret) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t bh1750_set_measure_mode(bh1750_handle_t sensor, const bh1750_measure_mode_t cmd_measure)
|
||||
{
|
||||
bh1750_dev_t *sens = (bh1750_dev_t *) sensor;
|
||||
return bh1750_write_byte(sens, (uint8_t)cmd_measure);
|
||||
}
|
||||
|
||||
esp_err_t bh1750_get_data(bh1750_handle_t sensor, float *const data)
|
||||
{
|
||||
esp_err_t ret;
|
||||
uint8_t bh1750_data_h, bh1750_data_l;
|
||||
bh1750_dev_t *sens = (bh1750_dev_t *) sensor;
|
||||
uint8_t datas[2] = {0};
|
||||
esp_err_t err = i2c_master_receive(sens->dev_handle, datas, 2, -1);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE("bh1750", "Erreur lecture BH1750 : %s", esp_err_to_name(err));
|
||||
return 0;
|
||||
}
|
||||
*data = ((datas[0] << 8) | datas[1])/ BH_1750_MEASUREMENT_ACCURACY; // En lux (si mode H-resolution)
|
||||
/*
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
ret = i2c_master_start(cmd);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_write_byte(cmd, sens->dev_addr | I2C_MASTER_READ, true);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_read_byte(cmd, &bh1750_data_h, I2C_MASTER_ACK);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_read_byte(cmd, &bh1750_data_l, I2C_MASTER_NACK);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_stop(cmd);
|
||||
assert(ESP_OK == ret);
|
||||
ret = i2c_master_cmd_begin(sens->bus, cmd, 1000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
if (ESP_OK != ret) {
|
||||
return ret;
|
||||
}
|
||||
*data = (( bh1750_data_h << 8 | bh1750_data_l ) / BH_1750_MEASUREMENT_ACCURACY);
|
||||
*/
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
dependencies:
|
||||
idf: '>=4.0'
|
||||
description: I2C driver for BH1750 light sensor
|
||||
url: https://github.com/espressif/esp-bsp/tree/master/components/bh1750
|
||||
version: 1.0.3
|
||||
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "driver/i2c_master.h"
|
||||
|
||||
typedef enum {
|
||||
BH1750_CONTINUE_1LX_RES = 0x10, /*!< Command to set measure mode as Continuously H-Resolution mode*/
|
||||
BH1750_CONTINUE_HALFLX_RES = 0x11, /*!< Command to set measure mode as Continuously H-Resolution mode2*/
|
||||
BH1750_CONTINUE_4LX_RES = 0x13, /*!< Command to set measure mode as Continuously L-Resolution mode*/
|
||||
BH1750_ONETIME_1LX_RES = 0x20, /*!< Command to set measure mode as One Time H-Resolution mode*/
|
||||
BH1750_ONETIME_HALFLX_RES = 0x21, /*!< Command to set measure mode as One Time H-Resolution mode2*/
|
||||
BH1750_ONETIME_4LX_RES = 0x23, /*!< Command to set measure mode as One Time L-Resolution mode*/
|
||||
} bh1750_measure_mode_t;
|
||||
|
||||
#define BH1750_I2C_ADDRESS_DEFAULT (0x23)
|
||||
typedef void *bh1750_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Set bh1750 as power down mode (low current)
|
||||
*
|
||||
* @param sensor object handle of bh1750
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t bh1750_power_down(bh1750_handle_t sensor);
|
||||
|
||||
/**
|
||||
* @brief Set bh1750 as power on mode
|
||||
*
|
||||
* @param sensor object handle of bh1750
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t bh1750_power_on(bh1750_handle_t sensor);
|
||||
|
||||
/**
|
||||
* @brief Get light intensity from bh1750
|
||||
*
|
||||
* @param sensor object handle of bh1750
|
||||
* @param[in] cmd_measure the instruction to set measurement mode
|
||||
*
|
||||
* @note
|
||||
* You should call this funtion to set measurement mode before call bh1750_get_data() to acquire data.
|
||||
* If you set onetime mode, you just can get one measurement result.
|
||||
* If you set continuous mode, you can call bh1750_get_data() to acquire data repeatedly.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t bh1750_set_measure_mode(bh1750_handle_t sensor, const bh1750_measure_mode_t cmd_measure);
|
||||
|
||||
/**
|
||||
* @brief Get light intensity from BH1750
|
||||
*
|
||||
* Returns light intensity in [lx] corrected by typical BH1750 Measurement Accuracy (= 1.2).
|
||||
*
|
||||
* @see BH1750 datasheet Rev. D page 2
|
||||
*
|
||||
* @note
|
||||
* You should acquire data from the sensor after the measurement time is over,
|
||||
* so take care of measurement time in different modes.
|
||||
*
|
||||
* @param sensor object handle of bh1750
|
||||
* @param[out] data light intensity value got from bh1750 in [lx]
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t bh1750_get_data(bh1750_handle_t sensor, float *const data);
|
||||
|
||||
/**
|
||||
* @brief Set measurement time
|
||||
*
|
||||
* This function is used to adjust BH1750 sensitivity, i.e. compensating influence from optical window.
|
||||
*
|
||||
* @see BH1750 datasheet Rev. D page 11
|
||||
*
|
||||
* @param sensor object handle of bh1750
|
||||
* @param[in] measure_time measurement time
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t bh1750_set_measure_time(bh1750_handle_t sensor, const uint8_t measure_time);
|
||||
|
||||
/**
|
||||
* @brief Create and init sensor object and return a sensor handle
|
||||
*
|
||||
* @param port I2C port number
|
||||
* @param[in] dev_addr I2C device address of sensor
|
||||
*
|
||||
* @return
|
||||
* - NULL Fail
|
||||
* - Others Success
|
||||
*/
|
||||
bh1750_handle_t bh1750_create(i2c_port_t port, const uint16_t dev_addr, i2c_master_bus_handle_t bus_handle);
|
||||
|
||||
/**
|
||||
* @brief Delete and release a sensor object
|
||||
*
|
||||
* @param sensor object handle of bh1750
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Fail
|
||||
*/
|
||||
esp_err_t bh1750_delete(bh1750_handle_t sensor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,3 +0,0 @@
|
||||
idf_component_register(SRCS "bh1750_test.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES "bh1750" "unity")
|
||||
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "unity.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "bh1750.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#define I2C_MASTER_SCL_IO 26 /*!< gpio number for I2C master clock */
|
||||
#define I2C_MASTER_SDA_IO 25 /*!< gpio number for I2C master data */
|
||||
#define I2C_MASTER_NUM I2C_NUM_0 /*!< I2C port number for master dev */
|
||||
#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */
|
||||
|
||||
static const char *TAG = "bh1750 test";
|
||||
static bh1750_handle_t bh1750 = NULL;
|
||||
|
||||
/**
|
||||
* @brief i2c master initialization
|
||||
*/
|
||||
static void i2c_bus_init(void)
|
||||
{
|
||||
i2c_config_t conf;
|
||||
conf.mode = I2C_MODE_MASTER;
|
||||
conf.sda_io_num = (gpio_num_t)I2C_MASTER_SDA_IO;
|
||||
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
conf.scl_io_num = (gpio_num_t)I2C_MASTER_SCL_IO;
|
||||
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
|
||||
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
|
||||
conf.clk_flags = I2C_SCLK_SRC_FLAG_FOR_NOMAL;
|
||||
|
||||
esp_err_t ret = i2c_param_config(I2C_MASTER_NUM, &conf);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, ret, "I2C config returned error");
|
||||
|
||||
ret = i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, ret, "I2C install returned error");
|
||||
}
|
||||
|
||||
void bh1750_init(void)
|
||||
{
|
||||
i2c_bus_init();
|
||||
bh1750 = bh1750_create(I2C_MASTER_NUM, BH1750_I2C_ADDRESS_DEFAULT);
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(bh1750, "BH1750 create returned NULL");
|
||||
}
|
||||
|
||||
TEST_CASE("Sensor BH1750 test", "[bh1750][iot][sensor]")
|
||||
{
|
||||
esp_err_t ret;
|
||||
bh1750_measure_mode_t cmd_measure;
|
||||
float bh1750_data;
|
||||
|
||||
bh1750_init();
|
||||
|
||||
ret = bh1750_power_on(bh1750);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
|
||||
// one-shot mode
|
||||
cmd_measure = BH1750_ONETIME_4LX_RES;
|
||||
ret = bh1750_set_measure_mode(bh1750, cmd_measure);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
vTaskDelay(30 / portTICK_PERIOD_MS);
|
||||
|
||||
ret = bh1750_get_data(bh1750, &bh1750_data);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
ESP_LOGI(TAG, "bh1750 val(one time mode): %f\n", bh1750_data);
|
||||
|
||||
// continous mode
|
||||
cmd_measure = BH1750_CONTINUE_4LX_RES;
|
||||
ret = bh1750_set_measure_mode(bh1750, cmd_measure);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
vTaskDelay(30 / portTICK_PERIOD_MS);
|
||||
|
||||
ret = bh1750_get_data(bh1750, &bh1750_data);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
ESP_LOGI(TAG, "bh1750 val(continuously mode): %f\n", bh1750_data);
|
||||
|
||||
// clean-up
|
||||
ret = bh1750_delete(bh1750);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
ret = i2c_driver_delete(I2C_MASTER_NUM);
|
||||
TEST_ASSERT_EQUAL(ESP_OK, ret);
|
||||
}
|
||||
6
gdbinit
Normal file
6
gdbinit
Normal file
@ -0,0 +1,6 @@
|
||||
target remote :3333
|
||||
set remote hardware-watchpoint-limit 2
|
||||
mon reset halt
|
||||
maintenance flush register-cache
|
||||
thb app_main
|
||||
c
|
||||
@ -1,4 +0,0 @@
|
||||
source "/home/marc/esp/v5.5.1/esp-idf/components/esp_app_format/Kconfig.projbuild"
|
||||
source "/home/marc/esp/v5.5.1/esp-idf/components/esp_rom/Kconfig.projbuild"
|
||||
source "/home/marc/esp/v5.5.1/esp-idf/components/partition_table/Kconfig.projbuild"
|
||||
source "/home/marc/rgb_lcd/components/protocol_examples_common/Kconfig.projbuild"
|
||||
@ -1,40 +1,40 @@
|
||||
idf_build_get_property(python SIMULATION_QEMU)
|
||||
message(STATUS "The Python interpreter is: ${python}")
|
||||
set(EXTRA_COMPONENT_DIRS ../components)
|
||||
|
||||
set(comps heap nvs_flash esp_netif image_downloader fatfs protocol_examples_common mqtt meteofrance domotic_display RemindMe esp_timer)
|
||||
set(comps heap nvs_flash meteofrance esp_netif image_downloader fatfs protocol_examples_common mqtt )
|
||||
|
||||
if(${IDF_TARGET} STREQUAL "esp32p4")
|
||||
message(STATUS "SIMULATION_QEMU = OOF --> main standard")
|
||||
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
|
||||
EMBED_FILES "index.html")
|
||||
elseif(${IDF_TARGET} STREQUAL "linux")
|
||||
message(STATUS "Linux Mode --> main standard")
|
||||
list(APPEND comps vfs esp_http_server)
|
||||
idf_component_register(SRCS main.c communication.c
|
||||
INCLUDE_DIRS "./include"
|
||||
REQUIRES ${comps}
|
||||
EMBED_TXTFILES ${PROJECT_DIR}/main/ca_cert.pem
|
||||
EMBED_FILES "index.html")
|
||||
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PUBLIC --coverage -DLV_LVGL_H_INCLUDE_SIMPLE )
|
||||
|
||||
else()
|
||||
message(STATUS "SIMULATION_QEMU = On vide le main")
|
||||
idf_component_register(SRCS test_main.c PRIV_REQUIRES meteofrance)
|
||||
return()
|
||||
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)
|
||||
endif()
|
||||
|
||||
function (make_font fontSize)
|
||||
execute_process(COMMAND podman run -v /home/marc/rgb_lcd/main/fonts:/app -w /app lvfontconv lv_font_conv --bpp 4 --size ${fontSize} --no-compress --font Montserrat-Medium.ttf --symbols "0123456789.°éèûCABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz %,'():" --format lvgl -o montserrat_medium_${fontSize}.c --font fa-solid-900.ttf --range 61461,0xf0c2,0xf575)
|
||||
endfunction()
|
||||
|
||||
make_font(12)
|
||||
make_font(18)
|
||||
make_font(24)
|
||||
|
||||
|
||||
idf_component_register(SRC_DIRS . fonts
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES ${comps}
|
||||
EMBED_TXTFILES ${project_dir}/main/ca_cert.pem
|
||||
EMBED_FILES "index.html")
|
||||
|
||||
|
||||
#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) LV_FONT_DECLARE(montserrat_medium_24)"
|
||||
# )
|
||||
|
||||
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) LV_FONT_DECLARE(montserrat_medium_24)"
|
||||
)
|
||||
|
||||
if(${IDF_TARGET} STREQUAL "esp32p4")
|
||||
lvgl_port_create_c_image("images/wifi_ok.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_create_c_image("images/wifi_ko.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_create_c_image("images/mqtt_ok.png" "images/" "AUTO" "NONE")
|
||||
lvgl_port_create_c_image("images/mqtt_ko.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_add_images(${COMPONENT_LIB} "images/")
|
||||
littlefs_create_partition_image(littlefs images_meteo FLASH_IN_PROJECT)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
@ -12,17 +12,11 @@ menu "Domotic Configuration"
|
||||
help
|
||||
WiFi password (WPA or WPA2) for the example to use.
|
||||
|
||||
config EXAMPLE_QEMU_RGB_PANEL_DEDIC_FB
|
||||
bool "Use QEMU RGB panel dedicated framebuffer"
|
||||
default "n"
|
||||
config GPIO_INPUT_CAPTEUR_PIR
|
||||
int "GPIO PIN Capteur PIR"
|
||||
range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
|
||||
default 4
|
||||
help
|
||||
Use QEMU RGB panel dedicated framebuffer as the framebuffer for LVGL.
|
||||
|
||||
#config GPIO_INPUT_CAPTEUR_PIR
|
||||
# int "GPIO PIN Capteur PIR"
|
||||
# range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX
|
||||
# default 4
|
||||
# help
|
||||
# GPIO pin à utiliser pour le capteur de présence IR.
|
||||
GPIO pin à utiliser pour le capteur de présence IR.
|
||||
|
||||
endmenu
|
||||
endmenu
|
||||
|
||||
@ -2,152 +2,13 @@
|
||||
#include "esp_log.h"
|
||||
#include "mqtt_client.h"
|
||||
#include "stateManagement.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
#include "esp_wifi.h"
|
||||
#endif
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char *TAG = "domo_mqtt";
|
||||
|
||||
/* FreeRTOS event group to signal when we are connected*/
|
||||
static EventGroupHandle_t s_wifi_event_group;
|
||||
|
||||
/* The event group allows multiple bits for each event, but we only care about two events:
|
||||
* - we are connected to the AP with an IP
|
||||
* - we failed to connect after the maximum amount of retries */
|
||||
#define BIT0 0x00000001
|
||||
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
#define EXAMPLE_ESP_WIFI_SSID "wifimms3"
|
||||
#define EXAMPLE_ESP_WIFI_PASS "mmswifi0611"
|
||||
#define EXAMPLE_ESP_MAXIMUM_RETRY 5
|
||||
|
||||
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_BOTH
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
||||
|
||||
static int s_retry_num = 0;
|
||||
wifi_callback cb;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
#define BIT0 0x00000001
|
||||
static void wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||
{
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START)
|
||||
{
|
||||
esp_wifi_connect();
|
||||
}
|
||||
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
|
||||
{
|
||||
if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY)
|
||||
{
|
||||
esp_wifi_connect();
|
||||
s_retry_num++;
|
||||
ESP_LOGI(TAG, "retry to connect to the AP");
|
||||
}
|
||||
else
|
||||
{
|
||||
//xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
}
|
||||
cb(WIFI_DISCONNECTED);
|
||||
ESP_LOGI(TAG, "connect to the AP fail");
|
||||
}
|
||||
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
|
||||
{
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||
s_retry_num = 0;
|
||||
cb(WIFI_CONNECTED);
|
||||
//xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
}
|
||||
}
|
||||
void wifi_init_sta(wifi_callback callback)
|
||||
{
|
||||
cb=callback;
|
||||
//s_wifi_event_group = xEventGroupCreate();
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
//ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
esp_event_handler_instance_t instance_any_id;
|
||||
esp_event_handler_instance_t instance_got_ip;
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||
ESP_EVENT_ANY_ID,
|
||||
&wifi_event_handler,
|
||||
NULL,
|
||||
&instance_any_id));
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||
IP_EVENT_STA_GOT_IP,
|
||||
&wifi_event_handler,
|
||||
NULL,
|
||||
&instance_got_ip));
|
||||
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = EXAMPLE_ESP_WIFI_SSID,
|
||||
.password = EXAMPLE_ESP_WIFI_PASS,
|
||||
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8).
|
||||
* If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
|
||||
* to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
|
||||
* WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
|
||||
*/
|
||||
.threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
|
||||
.sae_pwe_h2e = ESP_WIFI_SAE_MODE,
|
||||
.sae_h2e_identifier = "",
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||
|
||||
/*
|
||||
// Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
|
||||
// number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above)
|
||||
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
|
||||
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||
pdFALSE,
|
||||
pdFALSE,
|
||||
portMAX_DELAY);
|
||||
|
||||
// xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
||||
// happened.
|
||||
if (bits & WIFI_CONNECTED_BIT)
|
||||
{
|
||||
cb(CONNECTED);
|
||||
}
|
||||
else if (bits & WIFI_FAIL_BIT)
|
||||
{
|
||||
cb(CONNECT_FAIL);
|
||||
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
|
||||
EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
*/
|
||||
}
|
||||
#else
|
||||
#include <time.h>
|
||||
int64_t esp_timer_get_time(void)
|
||||
{
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (int64_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
esp_mqtt_client_handle_t client;
|
||||
|
||||
static const char *TAG = "domo_mqtt";
|
||||
|
||||
|
||||
static void log_error_if_nonzero(const char *message, int error_code)
|
||||
@ -165,28 +26,24 @@ void splitIt(char *payload, unsigned int length, float *datas)
|
||||
char *saveptr1;
|
||||
|
||||
token = strtok_r(payload, sep, &saveptr1);
|
||||
datas[0] = atof(token);
|
||||
datas[0] = atoff(token);
|
||||
ESP_LOGE(TAG,"%f",datas[0]);
|
||||
|
||||
token = strtok_r(NULL, sep, &saveptr1);
|
||||
datas[1] = atof(token);
|
||||
datas[1] = atoff(token);
|
||||
ESP_LOGE(TAG,"%f",datas[1]);
|
||||
|
||||
token = strtok_r(NULL, sep, &saveptr1);
|
||||
datas[2] = atof(token);
|
||||
datas[2] = atoff(token);
|
||||
ESP_LOGE(TAG,"%f",datas[2]);
|
||||
|
||||
token = strtok_r(NULL, sep, &saveptr1);
|
||||
datas[3] = atof(token);
|
||||
datas[3] = atoff(token);
|
||||
ESP_LOGE(TAG,"%f",datas[3]);
|
||||
}
|
||||
|
||||
mqtt_callback mqttcb;
|
||||
|
||||
void mqtt_publish(const char *topic, const char *datas){
|
||||
esp_mqtt_client_publish(client, topic, datas, 0, 1, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief Event handler registered to receive MQTT events
|
||||
*
|
||||
@ -335,3 +192,127 @@ void mqtt_app_start(mqtt_callback callback, EventGroupHandle_t domotic_event_gro
|
||||
}
|
||||
|
||||
|
||||
/* FreeRTOS event group to signal when we are connected*/
|
||||
static EventGroupHandle_t s_wifi_event_group;
|
||||
|
||||
/* The event group allows multiple bits for each event, but we only care about two events:
|
||||
* - we are connected to the AP with an IP
|
||||
* - we failed to connect after the maximum amount of retries */
|
||||
#define WIFI_CONNECTED_BIT BIT0
|
||||
#define WIFI_FAIL_BIT BIT1
|
||||
|
||||
#define EXAMPLE_ESP_WIFI_SSID "wifimms3"
|
||||
#define EXAMPLE_ESP_WIFI_PASS "mmswifi0611"
|
||||
#define EXAMPLE_ESP_MAXIMUM_RETRY 5
|
||||
|
||||
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_BOTH
|
||||
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
|
||||
|
||||
static int s_retry_num = 0;
|
||||
wifi_callback cb;
|
||||
|
||||
|
||||
static void wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||
{
|
||||
if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START)
|
||||
{
|
||||
esp_wifi_connect();
|
||||
}
|
||||
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED)
|
||||
{
|
||||
if (s_retry_num < EXAMPLE_ESP_MAXIMUM_RETRY)
|
||||
{
|
||||
esp_wifi_connect();
|
||||
s_retry_num++;
|
||||
ESP_LOGI(TAG, "retry to connect to the AP");
|
||||
}
|
||||
else
|
||||
{
|
||||
//xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
|
||||
}
|
||||
cb(WIFI_DISCONNECTED);
|
||||
ESP_LOGI(TAG, "connect to the AP fail");
|
||||
}
|
||||
else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP)
|
||||
{
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
|
||||
s_retry_num = 0;
|
||||
cb(WIFI_CONNECTED);
|
||||
//xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
|
||||
}
|
||||
}
|
||||
void wifi_init_sta(wifi_callback callback)
|
||||
{
|
||||
cb=callback;
|
||||
//s_wifi_event_group = xEventGroupCreate();
|
||||
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_sta();
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
esp_event_handler_instance_t instance_any_id;
|
||||
esp_event_handler_instance_t instance_got_ip;
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
|
||||
ESP_EVENT_ANY_ID,
|
||||
&wifi_event_handler,
|
||||
NULL,
|
||||
&instance_any_id));
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
|
||||
IP_EVENT_STA_GOT_IP,
|
||||
&wifi_event_handler,
|
||||
NULL,
|
||||
&instance_got_ip));
|
||||
|
||||
wifi_config_t wifi_config = {
|
||||
.sta = {
|
||||
.ssid = EXAMPLE_ESP_WIFI_SSID,
|
||||
.password = EXAMPLE_ESP_WIFI_PASS,
|
||||
/* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8).
|
||||
* If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
|
||||
* to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
|
||||
* WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
|
||||
*/
|
||||
.threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
|
||||
.sae_pwe_h2e = ESP_WIFI_SAE_MODE,
|
||||
.sae_h2e_identifier = "",
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_sta finished.");
|
||||
|
||||
/*
|
||||
// Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
|
||||
// number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above)
|
||||
EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
|
||||
WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
|
||||
pdFALSE,
|
||||
pdFALSE,
|
||||
portMAX_DELAY);
|
||||
|
||||
// xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
|
||||
// happened.
|
||||
if (bits & WIFI_CONNECTED_BIT)
|
||||
{
|
||||
cb(CONNECTED);
|
||||
}
|
||||
else if (bits & WIFI_FAIL_BIT)
|
||||
{
|
||||
cb(CONNECT_FAIL);
|
||||
ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
|
||||
EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user