fonctionnel
This commit is contained in:
commit
a6221da812
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build/
|
||||
managed_components/
|
||||
21
.vscode/c_cpp_properties.json
vendored
Normal file
21
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE"
|
||||
],
|
||||
"compilerPath": "C:\\msys64\\mingw64\\bin\\gcc.exe",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "gnu++17",
|
||||
"intelliSenseMode": "windows-gcc-x64",
|
||||
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"idf.adapterTargetName": "esp32s3",
|
||||
"idf.openOcdConfigs": [
|
||||
"board/esp32s3-builtin.cfg"
|
||||
],
|
||||
"idf.flashType": "UART",
|
||||
"idf.portWin": "COM12"
|
||||
}
|
||||
9
CMakeLists.txt
Normal file
9
CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
# 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)
|
||||
|
||||
# "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)
|
||||
19
README.md
Normal file
19
README.md
Normal file
@ -0,0 +1,19 @@
|
||||
# ESP LVGL RGB Screen Example
|
||||
|
||||
Very simple example for demonstration of initialization and usage of the `esp_lvgl_port` component with RGB LCD. This example contains four main parts:
|
||||
|
||||
## 1. LCD HW initialization - `app_lcd_init()`
|
||||
|
||||
Standard HW initialization of the LCD using [`esp_lcd`](https://github.com/espressif/esp-idf/tree/master/components/esp_lcd) component. Settings of this example are fully compatible with [ESP32-S3-LCD-EV-Board-2](https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s3_lcd_ev_board) board.
|
||||
|
||||
## 2. Touch HW initialization - `app_touch_init()`
|
||||
|
||||
Standard HW initialization of the LCD touch using [`esp_lcd_touch`](https://github.com/espressif/esp-bsp/tree/master/components/lcd_touch/esp_lcd_touch) component. Settings of this example are fully compatible with [ESP32-S3-LCD-EV-Board-2](https://github.com/espressif/esp-bsp/tree/master/bsp/esp32_s3_lcd_ev_board) board.
|
||||
|
||||
## 3. LVGL port initialization - `app_lvgl_init()`
|
||||
|
||||
Initialization of the LVGL port.
|
||||
|
||||
## 4. LVGL objects example usage - `app_main_display()`
|
||||
|
||||
Very simple demonstration code of using LVGL objects after LVGL port initialization.
|
||||
29
dependencies.lock
Normal file
29
dependencies.lock
Normal file
@ -0,0 +1,29 @@
|
||||
dependencies:
|
||||
espressif/esp_lcd_touch:
|
||||
component_hash: 779b4ba2464a3ae85681e4b860caa5fdc35801458c23f3039ee761bae7f442a4
|
||||
source:
|
||||
type: service
|
||||
version: 1.1.2
|
||||
espressif/esp_lcd_touch_gt911:
|
||||
component_hash: 664c544533b91497f29b41e045bb4374a0d4d002f9d8c67c7c1bf43fb4179e3f
|
||||
source:
|
||||
type: service
|
||||
version: 1.1.1
|
||||
espressif/esp_lvgl_port:
|
||||
component_hash: 531c0525b5a5d6c05c45a147baa0626209aea6b6c0e01a7af7e6bf151878d056
|
||||
source:
|
||||
type: service
|
||||
version: 2.2.2
|
||||
idf:
|
||||
component_hash: null
|
||||
source:
|
||||
type: idf
|
||||
version: 5.1.4
|
||||
lvgl/lvgl:
|
||||
component_hash: 2a8f619b5c2b1c7ad116c33d43dae8989c76739068f406a7e8ba9221e1085f17
|
||||
source:
|
||||
type: service
|
||||
version: 9.1.0
|
||||
manifest_hash: 00b1178407be665595f229a4c10495a43316f71ef19242ff89f82944e383f982
|
||||
target: esp32s3
|
||||
version: 1.0.0
|
||||
10
main/CMakeLists.txt
Normal file
10
main/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
idf_component_register(SRCS "main.c"
|
||||
INCLUDE_DIRS "." ${LV_DEMO_DIR})
|
||||
|
||||
lvgl_port_create_c_image("images/esp_logo.png" "images/" "ARGB8888" "NONE")
|
||||
lvgl_port_add_images(${COMPONENT_LIB} "images/")
|
||||
|
||||
set_source_files_properties(
|
||||
PROPERTIES COMPILE_OPTIONS
|
||||
"-DLV_LVGL_H_INCLUDE_SIMPLE;-Wno-format;"
|
||||
)
|
||||
7
main/idf_component.yml
Normal file
7
main/idf_component.yml
Normal file
@ -0,0 +1,7 @@
|
||||
dependencies:
|
||||
esp_lcd_touch_gt911:
|
||||
version: ^1
|
||||
esp_lvgl_port:
|
||||
version: '*'
|
||||
idf:
|
||||
version: '>=5.0'
|
||||
1
main/images/.gitignore
vendored
Normal file
1
main/images/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.c
|
||||
BIN
main/images/esp_logo.png
Normal file
BIN
main/images/esp_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.5 KiB |
461
main/main.c
Normal file
461
main/main.c
Normal file
@ -0,0 +1,461 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_check.h"
|
||||
#include "driver/i2c.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_lcd_panel_rgb.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
#include "lv_demos.h"
|
||||
|
||||
#include "esp_lcd_touch_gt911.h"
|
||||
|
||||
/* LCD size */
|
||||
#define EXAMPLE_LCD_H_RES (800)
|
||||
#define EXAMPLE_LCD_V_RES (480)
|
||||
|
||||
/* LCD settings */
|
||||
#define EXAMPLE_LCD_LVGL_FULL_REFRESH (0)
|
||||
#define EXAMPLE_LCD_LVGL_DIRECT_MODE (1)
|
||||
#define EXAMPLE_LCD_LVGL_AVOID_TEAR (1)
|
||||
#define EXAMPLE_LCD_RGB_BOUNCE_BUFFER_MODE (1)
|
||||
#define EXAMPLE_LCD_DRAW_BUFF_DOUBLE (0)
|
||||
#define EXAMPLE_LCD_DRAW_BUFF_HEIGHT (100)
|
||||
#define EXAMPLE_LCD_RGB_BUFFER_NUMS (2)
|
||||
#define EXAMPLE_LCD_RGB_BOUNCE_BUFFER_HEIGHT (10)
|
||||
|
||||
/* LCD pins */
|
||||
#define EXAMPLE_LCD_GPIO_VSYNC (GPIO_NUM_41)
|
||||
#define EXAMPLE_LCD_GPIO_HSYNC (GPIO_NUM_39)
|
||||
#define EXAMPLE_LCD_GPIO_DE (GPIO_NUM_40)
|
||||
#define EXAMPLE_LCD_GPIO_PCLK (GPIO_NUM_42)
|
||||
#define EXAMPLE_LCD_GPIO_DISP (GPIO_NUM_NC)
|
||||
#define EXAMPLE_LCD_GPIO_DATA0 (GPIO_NUM_8)
|
||||
#define EXAMPLE_LCD_GPIO_DATA1 (GPIO_NUM_3)
|
||||
#define EXAMPLE_LCD_GPIO_DATA2 (GPIO_NUM_46)
|
||||
#define EXAMPLE_LCD_GPIO_DATA3 (GPIO_NUM_9)
|
||||
#define EXAMPLE_LCD_GPIO_DATA4 (GPIO_NUM_1)
|
||||
#define EXAMPLE_LCD_GPIO_DATA5 (GPIO_NUM_5)
|
||||
#define EXAMPLE_LCD_GPIO_DATA6 (GPIO_NUM_6)
|
||||
#define EXAMPLE_LCD_GPIO_DATA7 (GPIO_NUM_7)
|
||||
#define EXAMPLE_LCD_GPIO_DATA8 (GPIO_NUM_15)
|
||||
#define EXAMPLE_LCD_GPIO_DATA9 (GPIO_NUM_16)
|
||||
#define EXAMPLE_LCD_GPIO_DATA10 (GPIO_NUM_4)
|
||||
#define EXAMPLE_LCD_GPIO_DATA11 (GPIO_NUM_45)
|
||||
#define EXAMPLE_LCD_GPIO_DATA12 (GPIO_NUM_48)
|
||||
#define EXAMPLE_LCD_GPIO_DATA13 (GPIO_NUM_47)
|
||||
#define EXAMPLE_LCD_GPIO_DATA14 (GPIO_NUM_21)
|
||||
#define EXAMPLE_LCD_GPIO_DATA15 (GPIO_NUM_14)
|
||||
|
||||
/* Touch settings */
|
||||
#define EXAMPLE_TOUCH_I2C_NUM (0)
|
||||
#define EXAMPLE_TOUCH_I2C_CLK_HZ (400000)
|
||||
|
||||
/* LCD touch pins */
|
||||
#define EXAMPLE_TOUCH_I2C_SCL (GPIO_NUM_18)
|
||||
#define EXAMPLE_TOUCH_I2C_SDA (GPIO_NUM_17)
|
||||
|
||||
#define EXAMPLE_LCD_PANEL_35HZ_RGB_TIMING() \
|
||||
{ \
|
||||
.pclk_hz = 18 * 1000 * 1000, \
|
||||
.h_res = EXAMPLE_LCD_H_RES, \
|
||||
.v_res = EXAMPLE_LCD_V_RES, \
|
||||
.hsync_pulse_width = 40, \
|
||||
.hsync_back_porch = 40, \
|
||||
.hsync_front_porch = 48, \
|
||||
.vsync_pulse_width = 23, \
|
||||
.vsync_back_porch = 32, \
|
||||
.vsync_front_porch = 13, \
|
||||
.flags.pclk_active_neg = true, \
|
||||
}
|
||||
|
||||
static const char *TAG = "EXAMPLE";
|
||||
|
||||
// LVGL image declare
|
||||
LV_IMG_DECLARE(esp_logo)
|
||||
|
||||
/* LCD IO and panel */
|
||||
static esp_lcd_panel_handle_t lcd_panel = NULL;
|
||||
static esp_lcd_touch_handle_t touch_handle = NULL;
|
||||
|
||||
/* LVGL display and touch */
|
||||
static lv_display_t *lvgl_disp = NULL;
|
||||
static lv_indev_t *lvgl_touch_indev = NULL;
|
||||
|
||||
static esp_err_t app_lcd_init(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
/* LCD initialization */
|
||||
ESP_LOGI(TAG, "Initialize RGB panel");
|
||||
esp_lcd_rgb_panel_config_t panel_conf = {
|
||||
.clk_src = LCD_CLK_SRC_PLL160M,
|
||||
.psram_trans_align = 64,
|
||||
.data_width = 16,
|
||||
.bits_per_pixel = 16,
|
||||
.de_gpio_num = EXAMPLE_LCD_GPIO_DE,
|
||||
.pclk_gpio_num = EXAMPLE_LCD_GPIO_PCLK,
|
||||
.vsync_gpio_num = EXAMPLE_LCD_GPIO_VSYNC,
|
||||
.hsync_gpio_num = EXAMPLE_LCD_GPIO_HSYNC,
|
||||
.disp_gpio_num = EXAMPLE_LCD_GPIO_DISP,
|
||||
.data_gpio_nums = {
|
||||
EXAMPLE_LCD_GPIO_DATA0,
|
||||
EXAMPLE_LCD_GPIO_DATA1,
|
||||
EXAMPLE_LCD_GPIO_DATA2,
|
||||
EXAMPLE_LCD_GPIO_DATA3,
|
||||
EXAMPLE_LCD_GPIO_DATA4,
|
||||
EXAMPLE_LCD_GPIO_DATA5,
|
||||
EXAMPLE_LCD_GPIO_DATA6,
|
||||
EXAMPLE_LCD_GPIO_DATA7,
|
||||
EXAMPLE_LCD_GPIO_DATA8,
|
||||
EXAMPLE_LCD_GPIO_DATA9,
|
||||
EXAMPLE_LCD_GPIO_DATA10,
|
||||
EXAMPLE_LCD_GPIO_DATA11,
|
||||
EXAMPLE_LCD_GPIO_DATA12,
|
||||
EXAMPLE_LCD_GPIO_DATA13,
|
||||
EXAMPLE_LCD_GPIO_DATA14,
|
||||
EXAMPLE_LCD_GPIO_DATA15,
|
||||
},
|
||||
.timings = EXAMPLE_LCD_PANEL_35HZ_RGB_TIMING(),
|
||||
.flags.fb_in_psram = 1,
|
||||
.num_fbs = EXAMPLE_LCD_RGB_BUFFER_NUMS,
|
||||
#if EXAMPLE_LCD_RGB_BOUNCE_BUFFER_MODE
|
||||
.bounce_buffer_size_px = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_RGB_BOUNCE_BUFFER_HEIGHT,
|
||||
#endif
|
||||
};
|
||||
ESP_GOTO_ON_ERROR(esp_lcd_new_rgb_panel(&panel_conf, &lcd_panel), err, TAG, "RGB init failed");
|
||||
ESP_GOTO_ON_ERROR(esp_lcd_panel_init(lcd_panel), err, TAG, "LCD init failed");
|
||||
|
||||
return ret;
|
||||
|
||||
err:
|
||||
if (lcd_panel) {
|
||||
esp_lcd_panel_del(lcd_panel);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t app_touch_init(void)
|
||||
{
|
||||
/* Initilize I2C */
|
||||
const i2c_config_t i2c_conf = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = EXAMPLE_TOUCH_I2C_SDA,
|
||||
.sda_pullup_en = GPIO_PULLUP_DISABLE,
|
||||
.scl_io_num = EXAMPLE_TOUCH_I2C_SCL,
|
||||
.scl_pullup_en = GPIO_PULLUP_DISABLE,
|
||||
.master.clk_speed = EXAMPLE_TOUCH_I2C_CLK_HZ
|
||||
};
|
||||
ESP_RETURN_ON_ERROR(i2c_param_config(EXAMPLE_TOUCH_I2C_NUM, &i2c_conf), TAG, "I2C configuration failed");
|
||||
ESP_RETURN_ON_ERROR(i2c_driver_install(EXAMPLE_TOUCH_I2C_NUM, i2c_conf.mode, 0, 0, 0), TAG, "I2C initialization failed");
|
||||
|
||||
/* Initialize touch HW */
|
||||
const esp_lcd_touch_config_t tp_cfg = {
|
||||
.x_max = EXAMPLE_LCD_H_RES,
|
||||
.y_max = EXAMPLE_LCD_V_RES,
|
||||
.rst_gpio_num = GPIO_NUM_NC,
|
||||
.int_gpio_num = GPIO_NUM_NC,
|
||||
.levels = {
|
||||
.reset = 0,
|
||||
.interrupt = 0,
|
||||
},
|
||||
.flags = {
|
||||
.swap_xy = 0,
|
||||
.mirror_x = 0,
|
||||
.mirror_y = 0,
|
||||
},
|
||||
};
|
||||
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
|
||||
const esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
|
||||
ESP_RETURN_ON_ERROR(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)EXAMPLE_TOUCH_I2C_NUM, &tp_io_config, &tp_io_handle), TAG, "");
|
||||
return esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &touch_handle);
|
||||
}
|
||||
|
||||
static esp_err_t app_lvgl_init(void)
|
||||
{
|
||||
/* Initialize LVGL */
|
||||
const lvgl_port_cfg_t lvgl_cfg = {
|
||||
.task_priority = 4, /* LVGL task priority */
|
||||
.task_stack = 6144, /* LVGL task stack size */
|
||||
.task_affinity = -1, /* LVGL task pinned to core (-1 is no affinity) */
|
||||
.task_max_sleep_ms = 500, /* Maximum sleep in LVGL task */
|
||||
.timer_period_ms = 5 /* LVGL timer tick period in ms */
|
||||
};
|
||||
ESP_RETURN_ON_ERROR(lvgl_port_init(&lvgl_cfg), TAG, "LVGL port initialization failed");
|
||||
|
||||
uint32_t buff_size = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_DRAW_BUFF_HEIGHT;
|
||||
#if EXAMPLE_LCD_LVGL_FULL_REFRESH || EXAMPLE_LCD_LVGL_DIRECT_MODE
|
||||
buff_size = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES;
|
||||
#endif
|
||||
|
||||
/* Add LCD screen */
|
||||
ESP_LOGD(TAG, "Add LCD screen");
|
||||
const lvgl_port_display_cfg_t disp_cfg = {
|
||||
.panel_handle = lcd_panel,
|
||||
.buffer_size = buff_size,
|
||||
.double_buffer = EXAMPLE_LCD_DRAW_BUFF_DOUBLE,
|
||||
.hres = EXAMPLE_LCD_H_RES,
|
||||
.vres = EXAMPLE_LCD_V_RES,
|
||||
.monochrome = false,
|
||||
#if LVGL_VERSION_MAJOR >= 9
|
||||
.color_format = LV_COLOR_FORMAT_RGB565,
|
||||
#endif
|
||||
.rotation = {
|
||||
.swap_xy = false,
|
||||
.mirror_x = false,
|
||||
.mirror_y = false,
|
||||
},
|
||||
.flags = {
|
||||
.buff_dma = false,
|
||||
.buff_spiram = false,
|
||||
#if EXAMPLE_LCD_LVGL_FULL_REFRESH
|
||||
.full_refresh = true,
|
||||
#elif EXAMPLE_LCD_LVGL_DIRECT_MODE
|
||||
.direct_mode = true,
|
||||
#endif
|
||||
#if LVGL_VERSION_MAJOR >= 9
|
||||
.swap_bytes = false,
|
||||
#endif
|
||||
}
|
||||
};
|
||||
const lvgl_port_display_rgb_cfg_t rgb_cfg = {
|
||||
.flags = {
|
||||
#if EXAMPLE_LCD_RGB_BOUNCE_BUFFER_MODE
|
||||
.bb_mode = true,
|
||||
#else
|
||||
.bb_mode = false,
|
||||
#endif
|
||||
#if EXAMPLE_LCD_LVGL_AVOID_TEAR
|
||||
.avoid_tearing = true,
|
||||
#else
|
||||
.avoid_tearing = false,
|
||||
#endif
|
||||
}
|
||||
};
|
||||
lvgl_disp = lvgl_port_add_disp_rgb(&disp_cfg, &rgb_cfg);
|
||||
|
||||
/* Add touch input (for selected screen) */
|
||||
const lvgl_port_touch_cfg_t touch_cfg = {
|
||||
.disp = lvgl_disp,
|
||||
.handle = touch_handle,
|
||||
};
|
||||
lvgl_touch_indev = lvgl_port_add_touch(&touch_cfg);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void _app_button_cb(lv_event_t *e)
|
||||
{
|
||||
lv_disp_rotation_t rotation = lv_disp_get_rotation(lvgl_disp);
|
||||
rotation++;
|
||||
if (rotation > LV_DISPLAY_ROTATION_270) {
|
||||
rotation = LV_DISPLAY_ROTATION_0;
|
||||
}
|
||||
|
||||
/* LCD HW rotation */
|
||||
lv_disp_set_rotation(lvgl_disp, rotation);
|
||||
}
|
||||
|
||||
static void app_main_display(void)
|
||||
{
|
||||
lv_obj_t *scr = lv_scr_act();
|
||||
|
||||
/* Your LVGL objects code here .... */
|
||||
|
||||
/* Create image */
|
||||
lv_obj_t *img_logo = lv_img_create(scr);
|
||||
lv_img_set_src(img_logo, &esp_logo);
|
||||
lv_obj_align(img_logo, LV_ALIGN_TOP_MID, 0, 20);
|
||||
|
||||
/* Label */
|
||||
lv_obj_t *label = lv_label_create(scr);
|
||||
lv_obj_set_width(label, EXAMPLE_LCD_H_RES);
|
||||
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
|
||||
#if LVGL_VERSION_MAJOR == 8
|
||||
lv_label_set_recolor(label, true);
|
||||
lv_label_set_text(label, "#FF0000 "LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"#\n#FF9400 "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING" #");
|
||||
#else
|
||||
lv_label_set_text(label, LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"\n "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING);
|
||||
#endif
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 20);
|
||||
|
||||
/* Button */
|
||||
lv_obj_t *btn = lv_btn_create(scr);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text_static(label, "Rotate screen");
|
||||
lv_obj_align(btn, LV_ALIGN_BOTTOM_MID, 0, -30);
|
||||
lv_obj_add_event_cb(btn, _app_button_cb, LV_EVENT_CLICKED, NULL);
|
||||
}
|
||||
|
||||
char tempExtStr[6];
|
||||
char tempIntStr[6];
|
||||
char hauteurCuveStr[6];
|
||||
lv_subject_t tempIntSubj;
|
||||
lv_subject_t tempExtSubj;
|
||||
lv_subject_t hauteurCuveSubj;
|
||||
|
||||
char *upEvent = "monter";
|
||||
char *downEvent = "descendre";
|
||||
|
||||
static void event_handler(lv_event_t *e)
|
||||
{
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
lv_obj_t *obj = (lv_obj_t *)lv_event_get_target(e);
|
||||
char *evtData = (char *)lv_event_get_user_data(e);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case LV_EVENT_PRESSED:
|
||||
// LV_LOG_USER("%s was pressed\n", evtData);
|
||||
break;
|
||||
case LV_EVENT_CLICKED:
|
||||
LV_LOG_USER("%s was clicked\n", evtData);
|
||||
//client.publish("volets", evtData);
|
||||
break;
|
||||
case LV_EVENT_LONG_PRESSED:
|
||||
LV_LOG_USER("%s was long pressed\n", evtData);
|
||||
break;
|
||||
case LV_EVENT_LONG_PRESSED_REPEAT:
|
||||
LV_LOG_USER("%s was long press repeat\n", evtData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void draw_ihm()
|
||||
{
|
||||
lv_subject_init_string(&tempExtSubj, tempExtStr, NULL, 6, "--");
|
||||
lv_subject_init_string(&tempIntSubj, tempIntStr, NULL, 6, "--");
|
||||
lv_subject_init_string(&hauteurCuveSubj, hauteurCuveStr, NULL, 6, "--");
|
||||
|
||||
// keys.clear();
|
||||
lv_obj_clean(lv_scr_act());
|
||||
|
||||
static lv_style_t style_btn;
|
||||
lv_style_init(&style_btn);
|
||||
// lv_style_set_bg_color(&style_btn, lv_color_hex(0x115588));
|
||||
// lv_style_set_bg_opa(&style_btn, LV_OPA_50);
|
||||
// lv_style_set_border_width(&style_btn, 2);
|
||||
// lv_style_set_border_color(&style_btn, lv_color_black());
|
||||
lv_style_set_width(&style_btn, 120);
|
||||
lv_style_set_height(&style_btn, 120);
|
||||
|
||||
// Un style pour les conteneurs (température, cuve ...)
|
||||
static lv_style_t style_container;
|
||||
lv_style_init(&style_container);
|
||||
lv_style_set_pad_all(&style_container, 5);
|
||||
// lv_style_set_height(&style_container,LV_SIZE_CONTENT);
|
||||
lv_style_set_height(&style_container, 80);
|
||||
lv_style_set_width(&style_container, 130);
|
||||
lv_style_set_bg_color(&style_container, lv_palette_lighten(LV_PALETTE_BLUE_GREY, 4));
|
||||
lv_style_set_align(&style_container, LV_ALIGN_BOTTOM_LEFT);
|
||||
lv_style_set_flex_cross_place(&style_container, LV_FLEX_ALIGN_END);
|
||||
|
||||
static lv_style_t style_lbvValue;
|
||||
lv_style_init(&style_lbvValue);
|
||||
lv_style_set_text_font(&style_lbvValue, &lv_font_montserrat_26);
|
||||
|
||||
lv_obj_set_flex_flow(lv_screen_active(), LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_style_pad_column(lv_screen_active(), 1, 0);
|
||||
|
||||
/*Create a container with COLUMN flex direction*/
|
||||
lv_obj_t *cont_col = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_style_pad_all(cont_col, 5, 0);
|
||||
lv_obj_set_size(cont_col, 250, 480);
|
||||
lv_obj_align(cont_col, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
lv_obj_set_flex_flow(cont_col, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
/*Create a container with COLUMN flex direction*/
|
||||
lv_obj_t *cont_col2 = lv_obj_create(lv_screen_active());
|
||||
lv_obj_set_style_pad_all(cont_col2, 5, 0);
|
||||
lv_obj_set_flex_align(cont_col2, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
|
||||
lv_obj_set_height(cont_col2, 480);
|
||||
lv_obj_set_width(cont_col2, LV_SIZE_CONTENT);
|
||||
lv_obj_align_to(cont_col2, cont_col, LV_ALIGN_OUT_TOP_RIGHT, 0, 0);
|
||||
lv_obj_set_flex_flow(cont_col2, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
lv_obj_t *label1 = lv_label_create(cont_col);
|
||||
lv_label_set_text(label1, "Temperatures");
|
||||
lv_obj_set_pos(label1, 0, 0);
|
||||
|
||||
/*Create a container with COLUMN flex direction*/
|
||||
lv_obj_t *cont_tempExt = lv_obj_create(cont_col);
|
||||
lv_obj_add_style(cont_tempExt, &style_container, 0);
|
||||
// lv_obj_set_height(cont_tempExt,50);
|
||||
lv_obj_set_flex_flow(cont_tempExt, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_t *lblExt = lv_label_create(cont_tempExt);
|
||||
lv_label_set_text(lblExt, "ext.");
|
||||
lv_obj_t *lblTempExt = lv_label_create(cont_tempExt);
|
||||
lv_obj_add_style(lblTempExt, &style_lbvValue, 0);
|
||||
lv_label_set_text(lblTempExt, "");
|
||||
lv_label_bind_text(lblTempExt, &tempExtSubj, "%s °C");
|
||||
|
||||
/*Create a container with COLUMN flex direction*/
|
||||
lv_obj_t *cont_tempInt = lv_obj_create(cont_col);
|
||||
lv_obj_add_style(cont_tempInt, &style_container, 0);
|
||||
// lv_obj_set_height(cont_tempInt,50);
|
||||
lv_obj_set_flex_flow(cont_tempInt, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_t *lblInt = lv_label_create(cont_tempInt);
|
||||
lv_label_set_text(lblInt, "int.");
|
||||
lv_obj_t *lblTempInt = lv_label_create(cont_tempInt);
|
||||
lv_obj_add_style(lblTempInt, &style_lbvValue, 0);
|
||||
lv_label_set_text(lblTempInt, "");
|
||||
lv_label_bind_text(lblTempInt, &tempIntSubj, "%s °C");
|
||||
|
||||
/*Create a container with COLUMN flex direction*/
|
||||
lv_obj_t *cont_Cuve = lv_obj_create(cont_col);
|
||||
lv_obj_add_style(cont_Cuve, &style_container, 0);
|
||||
lv_obj_set_flex_flow(cont_Cuve, LV_FLEX_FLOW_ROW_WRAP);
|
||||
// lv_obj_set_height(cont_Cuve,80);
|
||||
|
||||
lv_obj_t *lblHauteurEau = lv_label_create(cont_Cuve);
|
||||
lv_label_set_text(lblHauteurEau, "Cuve: ");
|
||||
lv_obj_t *lblHauteurCuve = lv_label_create(cont_Cuve);
|
||||
lv_obj_add_style(lblHauteurCuve, &style_lbvValue, 0);
|
||||
lv_label_bind_text(lblHauteurCuve, &hauteurCuveSubj, "%s cm");
|
||||
|
||||
lv_obj_t *btnUp = lv_button_create(cont_col2);
|
||||
lv_obj_add_style(btnUp, &style_btn, 0);
|
||||
lv_obj_add_event_cb(btnUp, event_handler, LV_EVENT_ALL, upEvent);
|
||||
lv_obj_align(btnUp, LV_ALIGN_CENTER, 0, -40);
|
||||
lv_obj_remove_flag(btnUp, LV_OBJ_FLAG_PRESS_LOCK);
|
||||
lv_obj_t *label = lv_label_create(btnUp);
|
||||
lv_label_set_text(label, LV_SYMBOL_UP);
|
||||
lv_obj_center(label);
|
||||
|
||||
lv_obj_t *btnDwn = lv_button_create(cont_col2);
|
||||
lv_obj_add_style(btnDwn, &style_btn, 0);
|
||||
lv_obj_add_event_cb(btnDwn, event_handler, LV_EVENT_ALL, downEvent);
|
||||
lv_obj_align(btnDwn, LV_ALIGN_CENTER, 0, -40);
|
||||
lv_obj_remove_flag(btnDwn, LV_OBJ_FLAG_PRESS_LOCK);
|
||||
label = lv_label_create(btnDwn);
|
||||
lv_label_set_text(label, LV_SYMBOL_DOWN);
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
/* LCD HW initialization */
|
||||
ESP_ERROR_CHECK(app_lcd_init());
|
||||
|
||||
/* Touch initialization */
|
||||
ESP_ERROR_CHECK(app_touch_init());
|
||||
|
||||
/* LVGL initialization */
|
||||
ESP_ERROR_CHECK(app_lvgl_init());
|
||||
|
||||
/* Show LVGL objects */
|
||||
lvgl_port_lock(0);
|
||||
//app_main_display();
|
||||
draw_ihm();
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
5
partitions.csv
Normal file
5
partitions.csv
Normal file
@ -0,0 +1,5 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 2M,
|
||||
|
41
sdkconfig.defaults
Normal file
41
sdkconfig.defaults
Normal file
@ -0,0 +1,41 @@
|
||||
CONFIG_IDF_TARGET="esp32s3"
|
||||
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_PERF=y
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
|
||||
CONFIG_SPIRAM_RODATA=y
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
|
||||
CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_LV_MEM_CUSTOM=y
|
||||
CONFIG_LV_MEMCPY_MEMSET_STD=y
|
||||
CONFIG_LV_ATTRIBUTE_FAST_MEM_USE_IRAM=y
|
||||
CONFIG_LV_FONT_MONTSERRAT_12=y
|
||||
CONFIG_LV_FONT_MONTSERRAT_16=y
|
||||
CONFIG_LV_FONT_MONTSERRAT_26=y
|
||||
CONFIG_LV_USE_DEMO_WIDGETS=n
|
||||
CONFIG_LV_USE_DEMO_BENCHMARK=n
|
||||
CONFIG_LV_USE_DEMO_STRESS=n
|
||||
CONFIG_LV_USE_DEMO_MUSIC=n
|
||||
CONFIG_LV_DEMO_MUSIC_AUTO_PLAY=n
|
||||
|
||||
## LVGL8 ##
|
||||
CONFIG_LV_MEM_SIZE_KILOBYTES=48
|
||||
CONFIG_LV_USE_PERF_MONITOR=y
|
||||
|
||||
## LVGL9 ##
|
||||
CONFIG_LV_CONF_SKIP=y
|
||||
|
||||
#CLIB default
|
||||
CONFIG_LV_USE_CLIB_MALLOC=y
|
||||
CONFIG_LV_USE_CLIB_SPRINTF=y
|
||||
CONFIG_LV_USE_CLIB_STRING=y
|
||||
|
||||
# Performance monitor
|
||||
CONFIG_LV_USE_OBSERVER=y
|
||||
CONFIG_LV_USE_SYSMON=y
|
||||
CONFIG_LV_USE_PERF_MONITOR=y
|
||||
1652
sdkconfig.old
Normal file
1652
sdkconfig.old
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user