diff --git a/CMakeLists.txt b/CMakeLists.txt index 71ef820..155c8f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(i80_controller) + +add_compile_options(-Wno-missing-field-initializers) + +project(oxy_fluxdc) diff --git a/SquareLineProj/ESP32S3_UI.sll b/SquareLineProj/ESP32S3_UI.sll index 271b12b..6f77b1f 100644 --- a/SquareLineProj/ESP32S3_UI.sll +++ b/SquareLineProj/ESP32S3_UI.sll @@ -25,7 +25,7 @@ "uiExportFolderPath": "D:\\yuwell_workspace\\FluxDC\\SquareLineProj\\Export", "projectExportFolderPath": "D:\\yuwell_workspace\\FluxDC\\SquareLineProj\\Export", "custom_variable_prefix": "uic", - "backup_cnt": 725, + "backup_cnt": 726, "autosave_cnt": 0, "group_color_cnt": 0, "lvgl_version": "8.3.6", diff --git a/SquareLineProj/ESP32S3_UI.spj b/SquareLineProj/ESP32S3_UI.spj index 2db0b31..d1365c0 100644 --- a/SquareLineProj/ESP32S3_UI.spj +++ b/SquareLineProj/ESP32S3_UI.spj @@ -17164,7 +17164,7 @@ { "nid": 1000311, "strtype": "CALL FUNCTION/Function_name", - "strval": "on_buttonFluxRead_clicked", + "strval": "on_buttonGetWifi_clicked", "InheritedType": 10 }, { @@ -24294,7 +24294,7 @@ "uiExportFolderPath": "D:\\yuwell_workspace\\FluxDC\\SquareLineProj\\Export", "projectExportFolderPath": "D:\\yuwell_workspace\\FluxDC\\SquareLineProj\\Export", "custom_variable_prefix": "uic", - "backup_cnt": 724, + "backup_cnt": 725, "autosave_cnt": 0, "group_color_cnt": 0, "lvgl_version": "8.3.6", diff --git a/SquareLineProj/backup/ESP32S3_UI_backup06.zip b/SquareLineProj/backup/ESP32S3_UI_backup06.zip index fd75fa4..e57fb7f 100644 Binary files a/SquareLineProj/backup/ESP32S3_UI_backup06.zip and b/SquareLineProj/backup/ESP32S3_UI_backup06.zip differ diff --git a/components/FluxButton/FluxButton.h b/components/FluxButton/FluxButton.h index 685a51f..11de619 100644 --- a/components/FluxButton/FluxButton.h +++ b/components/FluxButton/FluxButton.h @@ -37,6 +37,17 @@ enum button_cmd_t #define CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE 0 -void button_init_func(uint32_t button_num); +#ifdef __cplusplus +extern "C" { +#endif + + +void button_init_func(uint32_t button_num); void button_init(void); + + + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/components/FluxMod/FluxMod.h b/components/FluxMod/FluxMod.h index c71c976..b4555f4 100644 --- a/components/FluxMod/FluxMod.h +++ b/components/FluxMod/FluxMod.h @@ -64,9 +64,18 @@ enum { #define USE_MODBUS_OFFICIAL 0 +#ifdef __cplusplus +extern "C" { +#endif + /*Modbus总线初始化函数*/ esp_err_t modbus_master_init(void); void master_operation_func(void *arg); -static void* master_get_param_data(const mb_parameter_descriptor_t* param_descriptor); \ No newline at end of file +static void* master_get_param_data(const mb_parameter_descriptor_t* param_descriptor); + + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/components/FluxUI/CMakeLists.txt b/components/FluxUI/CMakeLists.txt index 02ced44..76bc965 100644 --- a/components/FluxUI/CMakeLists.txt +++ b/components/FluxUI/CMakeLists.txt @@ -32,5 +32,3 @@ idf_component_register(SRCS ${SOURCES} PRIV_REQUIRES driver lvgl FluxMod FluxWifi FluxUart FluxSD 78__esp-wifi-connect espressif__esp-idf-cxx INCLUDE_DIRS "." "C:/Espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/xtensa-esp-elf/include/" ) - -target_compile_options(${COMPONENT_LIB} PUBLIC -std=gnu++23) diff --git a/components/FluxUI/ui_events.c b/components/FluxUI/ui_events.c index b8b207c..e3660fb 100644 --- a/components/FluxUI/ui_events.c +++ b/components/FluxUI/ui_events.c @@ -173,5 +173,5 @@ void on_buttonReadSDCard_clicked(lv_event_t * e) void on_buttonGetWifi_clicked(lv_event_t * e) { - + } \ No newline at end of file diff --git a/components/FluxUart/FluxUart.h b/components/FluxUart/FluxUart.h index 628c512..4b31dd4 100644 --- a/components/FluxUart/FluxUart.h +++ b/components/FluxUart/FluxUart.h @@ -1,4 +1,11 @@ +#ifndef _FLUX_UART_H +#define _FLUX_UART_H + +#ifdef __cplusplus +extern "C" { +#endif + #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -62,4 +69,10 @@ void uart2_echoTask(void); unsigned short CRC16(unsigned char* pchMsg, unsigned short wDataLen); -esp_err_t ModbusRTU_Send(uart_port_t uart_num, struct ModbusRTU_Frame *frame); \ No newline at end of file +esp_err_t ModbusRTU_Send(uart_port_t uart_num, struct ModbusRTU_Frame *frame); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index c1dee42..299ddb8 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -3,8 +3,8 @@ if(CONFIG_EXAMPLE_LCD_IMAGE_FROM_EMBEDDED_BINARY) file(GLOB_RECURSE embedded_images images/*.c) endif() -idf_component_register(SRCS "i80_controller_example_main.c" "lvgl_demo_ui.c" ${embedded_images} -REQUIRES FluxUI FluxPower spiffs FluxSD FluxMod FluxButton FluxWifi FluxSpifs FluxUart +idf_component_register(SRCS "main.cc" "lvgl_demo_ui.c" ${embedded_images} +REQUIRES FluxUI FluxPower spiffs FluxSD FluxMod FluxButton FluxWifi FluxSpifs FluxUart 78__esp-wifi-connect nvs_flash INCLUDE_DIRS ".") if(CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM) diff --git a/main/i80_controller_example_main.c b/main/i80_controller_example_main.c deleted file mode 100644 index f96369c..0000000 --- a/main/i80_controller_example_main.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: CC0-1.0 - */ - -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/semphr.h" -#include "esp_timer.h" -#include "esp_err.h" -#include "esp_log.h" -#include "esp_lcd_panel_io.h" -#include "esp_lcd_panel_vendor.h" -#include "esp_lcd_panel_ops.h" -#include "esp_spiffs.h" -#include "driver/gpio.h" -#include "driver/ledc.h" -#include "lvgl.h" - -/*鍖呭惈SD鍗¤鍐欐帶鍒跺ご鏂囦欢*/ -#include "FluxSD.h" - -/*瀵煎叆Modbus鎺у埗澶存枃浠*/ -#include "FluxMod.h" - -//鏂板瑙︽懜灞忛┍鍔ㄥご鏂囦欢 -#include "driver/i2c.h" -#include "esp_lcd_touch_ft5x06.h" - -/*瀵煎叆澶栭儴LVGL椤圭洰*/ -#include "ui.h" - -/*鍖呭惈鎸夐敭鎺у埗澶存枃浠*/ -#include "FluxButton.h" - -/*娣诲姞鐢甸噺鐩戞祴澶存枃浠*/ -#include "FluxPower.h" - -/*娣诲姞WiFi绠$悊澶存枃浠*/ -#include "FluxWifi.h" - -/*鍖呭惈鍐呴儴瀛樺偍鐨勫ご鏂囦欢*/ -#include "FluxSpifs.h" - -/*鍖呭惈涓插彛鎺у埗澶存枃浠*/ -#include "FluxUart.h" - -static const char *TAG = "example"; - -#include "modbus_params.h" - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////// Please update the following configuration according to your LCD spec ////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#define EXAMPLE_LCD_PIXEL_CLOCK_HZ CONFIG_EXAMPLE_LCD_PIXEL_CLOCK_HZ - -#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 0 -#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL -/*瀹氫箟鏁版嵁鎺ュ彛*/ -#define EXAMPLE_PIN_NUM_DATA0 18 -#define EXAMPLE_PIN_NUM_DATA1 17 -#define EXAMPLE_PIN_NUM_DATA2 16 -#define EXAMPLE_PIN_NUM_DATA3 15 -#define EXAMPLE_PIN_NUM_DATA4 7 -#define EXAMPLE_PIN_NUM_DATA5 6 -#define EXAMPLE_PIN_NUM_DATA6 5 -#define EXAMPLE_PIN_NUM_DATA7 4 - -/*瀹氫箟灞忓箷鏄剧ず鍏朵粬鎺ュ彛*/ -#define EXAMPLE_PIN_NUM_PCLK 19 - -#if 0 -#define EXAMPLE_PIN_NUM_CS 45 -#define EXAMPLE_PIN_NUM_DC 20 -#define EXAMPLE_PIN_NUM_RST 8 -#define EXAMPLE_PIN_NUM_BK_LIGHT 10 -#elif 1 - -#define EXAMPLE_PIN_NUM_CS 0 -#define EXAMPLE_PIN_NUM_DC 20 -#define EXAMPLE_PIN_NUM_RST 8 -#define EXAMPLE_PIN_NUM_BK_LIGHT 3 -#endif - -// The pixel number in horizontal and vertical -#define EXAMPLE_LCD_H_RES 320 -#define EXAMPLE_LCD_V_RES 480 -// Bit number used to represent command and parameter -#define EXAMPLE_LCD_CMD_BITS 8 -#define EXAMPLE_LCD_PARAM_BITS 8 - -//瀹氫箟鎵浣跨敤瑙︽懜灞忛┍鍔ㄦ帴鍙 -#define EXAMPLE_I2C_NUM 0 // I2C number -#define EXAMPLE_I2C_SCL 39 -#define EXAMPLE_I2C_SDA 38 - -#define EXAMPLE_LVGL_TICK_PERIOD_MS 2 -#define EXAMPLE_LVGL_TASK_MAX_DELAY_MS 500 -#define EXAMPLE_LVGL_TASK_MIN_DELAY_MS 1 -#define EXAMPLE_LVGL_TASK_STACK_SIZE (16 * 1024) -#define EXAMPLE_LVGL_TASK_PRIORITY 2 - -#define EXAMPLE_DMA_BURST_SIZE 64 // 16, 32, 64. Higher burst size can improve the performance when the DMA buffer comes from PSRAM - -static SemaphoreHandle_t lvgl_mux = NULL; - -extern void example_lvgl_demo_ui(lv_disp_t *disp); - -/*鍒╃敤 PWM杩涜鑳屽厜浜害璋冭妭*/ -#define LEDC_TIMER LEDC_TIMER_0 -#define LEDC_MODE LEDC_LOW_SPEED_MODE -#define LEDC_OUTPUT_IO (EXAMPLE_PIN_NUM_BK_LIGHT) // Define the output GPIO -#define LEDC_CHANNEL LEDC_CHANNEL_0 -#define LEDC_DUTY_RES LEDC_TIMER_13_BIT // Set duty resolution to 13 bits -#define LEDC_DUTY (4096) // Set duty to 50%. (2 ** 13) * 50% = 4096 -#define LEDC_FREQUENCY (4000) // Frequency in Hertz. Set frequency at 4 kHz - -static void example_ledc_init(void) -{ - // Prepare and then apply the LEDC PWM timer configuration - ledc_timer_config_t ledc_timer = { - .speed_mode = LEDC_MODE, - .duty_resolution = LEDC_DUTY_RES, - .timer_num = LEDC_TIMER, - .freq_hz = LEDC_FREQUENCY, // Set output frequency at 4 kHz - .clk_cfg = LEDC_AUTO_CLK - }; - ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer)); - - // Prepare and then apply the LEDC PWM channel configuration - ledc_channel_config_t ledc_channel = { - .speed_mode = LEDC_MODE, - .channel = LEDC_CHANNEL, - .timer_sel = LEDC_TIMER, - .intr_type = LEDC_INTR_DISABLE, - .gpio_num = LEDC_OUTPUT_IO, - .duty = 0, // Set duty to 0% - .hpoint = 0 - }; - ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel)); -} - - -static bool example_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx) -{ - lv_disp_drv_t *disp_driver = (lv_disp_drv_t *)user_ctx; - lv_disp_flush_ready(disp_driver); - return false; -} - -static void example_lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) -{ - esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data; - int offsetx1 = area->x1; - int offsetx2 = area->x2; - int offsety1 = area->y1; - int offsety2 = area->y2; - // copy a buffer's content to a specific area of the display - esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map); -} - -/*鏂板鐢靛瑙︽懜灞忕紦瀛*/ -static void example_lvgl_touch_cb(lv_indev_drv_t *drv, lv_indev_data_t *data) -{ - uint16_t touchpad_x[1] = {0}; - uint16_t touchpad_y[1] = {0}; - uint8_t touchpad_cnt = 0; - - /* Read touch controller data */ - esp_lcd_touch_read_data(drv->user_data); - - /* Get coordinates */ - bool touchpad_pressed = esp_lcd_touch_get_coordinates(drv->user_data, touchpad_x, touchpad_y, NULL, &touchpad_cnt, 1); - - if (touchpad_pressed && touchpad_cnt > 0) - { - data->point.x = touchpad_x[0]; - data->point.y = touchpad_y[0]; - data->state = LV_INDEV_STATE_PRESSED; - } - else - { - data->state = LV_INDEV_STATE_RELEASED; - } -} - -static void example_increase_lvgl_tick(void *arg) -{ - /* Tell LVGL how many milliseconds has elapsed */ - lv_tick_inc(EXAMPLE_LVGL_TICK_PERIOD_MS); -} - -bool example_lvgl_lock(int timeout_ms) -{ - // Convert timeout in milliseconds to FreeRTOS ticks - // If `timeout_ms` is set to -1, the program will block until the condition is met - const TickType_t timeout_ticks = (timeout_ms == -1) ? portMAX_DELAY : pdMS_TO_TICKS(timeout_ms); - return xSemaphoreTakeRecursive(lvgl_mux, timeout_ticks) == pdTRUE; -} - -void example_lvgl_unlock(void) -{ - xSemaphoreGiveRecursive(lvgl_mux); -} - -static void example_lvgl_port_task(void *arg) -{ - ESP_LOGI(TAG, "Starting LVGL task"); - uint32_t task_delay_ms = EXAMPLE_LVGL_TASK_MAX_DELAY_MS; - while (1) { - // Lock the mutex due to the LVGL APIs are not thread-safe - if (example_lvgl_lock(-1)) { - task_delay_ms = lv_timer_handler(); - // Release the mutex - example_lvgl_unlock(); - } - if (task_delay_ms > EXAMPLE_LVGL_TASK_MAX_DELAY_MS) { - task_delay_ms = EXAMPLE_LVGL_TASK_MAX_DELAY_MS; - } else if (task_delay_ms < EXAMPLE_LVGL_TASK_MIN_DELAY_MS) { - task_delay_ms = EXAMPLE_LVGL_TASK_MIN_DELAY_MS; - } - vTaskDelay(pdMS_TO_TICKS(task_delay_ms)); - } -} - -#if CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM -void example_init_filesystem(void) -{ - ESP_LOGI(TAG, "Initializing filesystem"); - esp_vfs_spiffs_conf_t conf = { - .base_path = "/spiffs", - .partition_label = "storage", - .max_files = 5, - .format_if_mount_failed = true - }; - - // Use settings defined above to initialize and mount SPIFFS filesystem. - // Note: esp_vfs_spiffs_register is an all-in-one convenience function. - esp_err_t ret = esp_vfs_spiffs_register(&conf); - - if (ret != ESP_OK) { - if (ret == ESP_FAIL) { - ESP_LOGE(TAG, "Failed to mount or format filesystem"); - } else if (ret == ESP_ERR_NOT_FOUND) { - ESP_LOGE(TAG, "Failed to find SPIFFS partition"); - } else { - ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret)); - } - return; - } - - size_t total = 0, used = 0; - ret = esp_spiffs_info(conf.partition_label, &total, &used); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s). Formatting...", esp_err_to_name(ret)); - esp_spiffs_format(conf.partition_label); - return; - } else { - ESP_LOGI(TAG, "Partition size: total: %zu, used: %zu", total, used); - } -} -#endif // CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM - -void example_init_i80_bus(esp_lcd_panel_io_handle_t *io_handle, void *user_ctx) -{ - ESP_LOGI(TAG, "Initialize Intel 8080 bus"); - esp_lcd_i80_bus_handle_t i80_bus = NULL; - esp_lcd_i80_bus_config_t bus_config = { - .clk_src = LCD_CLK_SRC_DEFAULT, - .dc_gpio_num = EXAMPLE_PIN_NUM_DC, - .wr_gpio_num = EXAMPLE_PIN_NUM_PCLK, - .data_gpio_nums = { - EXAMPLE_PIN_NUM_DATA0, - EXAMPLE_PIN_NUM_DATA1, - EXAMPLE_PIN_NUM_DATA2, - EXAMPLE_PIN_NUM_DATA3, - EXAMPLE_PIN_NUM_DATA4, - EXAMPLE_PIN_NUM_DATA5, - EXAMPLE_PIN_NUM_DATA6, - EXAMPLE_PIN_NUM_DATA7, - }, - .bus_width = CONFIG_EXAMPLE_LCD_I80_BUS_WIDTH, - .max_transfer_bytes = EXAMPLE_LCD_H_RES * 100 * sizeof(uint16_t), - .dma_burst_size = EXAMPLE_DMA_BURST_SIZE, - }; - ESP_ERROR_CHECK(esp_lcd_new_i80_bus(&bus_config, &i80_bus)); - - esp_lcd_panel_io_i80_config_t io_config = { - .cs_gpio_num = EXAMPLE_PIN_NUM_CS, - .pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ, - .trans_queue_depth = 10, - .dc_levels = { - .dc_idle_level = 0, - .dc_cmd_level = 0, - .dc_dummy_level = 0, - .dc_data_level = 1, - }, - .flags = { - .swap_color_bytes = !LV_COLOR_16_SWAP, // Swap can be done in LvGL (default) or DMA - }, - .on_color_trans_done = example_notify_lvgl_flush_ready, - .user_ctx = user_ctx, - .lcd_cmd_bits = EXAMPLE_LCD_CMD_BITS, - .lcd_param_bits = EXAMPLE_LCD_PARAM_BITS, - }; - ESP_ERROR_CHECK(esp_lcd_new_panel_io_i80(i80_bus, &io_config, io_handle)); -} - -void example_init_lcd_panel(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_handle_t *panel) -{ - esp_lcd_panel_handle_t panel_handle = NULL; - - ESP_LOGI(TAG, "Install LCD driver of st7789"); - esp_lcd_panel_dev_config_t panel_config = { - .reset_gpio_num = EXAMPLE_PIN_NUM_RST, - .rgb_ele_order = COLOR_RGB_ELEMENT_ORDER_BGR, - .bits_per_pixel = 16, - }; - ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle)); - - esp_lcd_panel_reset(panel_handle); - esp_lcd_panel_init(panel_handle); - // Set inversion, x/y coordinate order, x/y mirror according to your LCD module spec - // the gap is LCD panel specific, even panels with the same driver IC, can have different gap value - esp_lcd_panel_invert_color(panel_handle, false); - esp_lcd_panel_set_gap(panel_handle, 0, 0); - - esp_lcd_panel_mirror(panel_handle, true, false); - *panel = panel_handle; -} - -/*瀹氫箟瑙︽懜灞忔帶鍒剁殑鍏ㄥ眬鍙橀噺*/ -esp_lcd_touch_handle_t tp = NULL; -/*鍒濆鍖栬Е鎽稿睆椹卞姩*/ -void example_init_touch_panel(void) -{ - esp_lcd_panel_io_handle_t tp_io_handle = NULL; - - ESP_LOGI(TAG, "Initialize I2C"); - const i2c_config_t i2c_conf = { - .mode = I2C_MODE_MASTER, - .sda_io_num = EXAMPLE_I2C_SDA, - .scl_io_num = EXAMPLE_I2C_SCL, - .sda_pullup_en = GPIO_PULLUP_ENABLE, - .scl_pullup_en = GPIO_PULLUP_ENABLE, - .master.clk_speed = 400000, - }; - /* Initialize I2C */ - ESP_ERROR_CHECK(i2c_param_config(EXAMPLE_I2C_NUM, &i2c_conf)); - ESP_ERROR_CHECK(i2c_driver_install(EXAMPLE_I2C_NUM, i2c_conf.mode, 0, 0, 0)); - - esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG(); - - ESP_LOGI(TAG, "Initialize touch IO (I2C)"); - - /* Touch IO handle */ - ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)EXAMPLE_I2C_NUM, &tp_io_config, &tp_io_handle)); - - esp_lcd_touch_config_t tp_cfg = { - .x_max = EXAMPLE_LCD_V_RES, - .y_max = EXAMPLE_LCD_H_RES, - .rst_gpio_num = -1, - .int_gpio_num = -1, - .flags = { - .swap_xy = 0, - .mirror_x = 0, - .mirror_y = 0, - }, - }; - - ESP_LOGI(TAG, "Initialize touch controller FT5X06"); - ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_ft5x06(tp_io_handle, &tp_cfg, &tp)); -} - - -void app_main(void) -{ - /*鍒濆鍖朏luxButton - 涓婄數涔嬪悗鐨勭涓浠朵簨*/ - button_init(); - /*鎷夎捣寮鏈虹姸鎬*/ - POWER_ON; - - static lv_disp_draw_buf_t disp_buf; // contains internal graphic buffer(s) called draw buffer(s) - static lv_disp_drv_t disp_drv; // contains callback functions - -#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0 - ESP_LOGI(TAG, "Turn off LCD backlight"); - gpio_config_t bk_gpio_config = { - .mode = GPIO_MODE_OUTPUT, - .pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT - }; - ESP_ERROR_CHECK(gpio_config(&bk_gpio_config)); - gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL); -#endif // EXAMPLE_PIN_NUM_BK_LIGHT >= 0 - -#if CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM - example_init_filesystem(); -#endif // CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM - - esp_lcd_panel_io_handle_t io_handle = NULL; - example_init_i80_bus(&io_handle, &disp_drv); - - esp_lcd_panel_handle_t panel_handle = NULL; - example_init_lcd_panel(io_handle, &panel_handle); - - // Stub: user can flush pre-defined pattern to the screen before we turn on the screen or backlight - - ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true)); - -#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0 - ESP_LOGI(TAG, "Turn on LCD backlight"); - gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL); -#endif // EXAMPLE_PIN_NUM_BK_LIGHT >= 0 - - /*灏嗚Е鎽稿睆椹卞姩鍒濆鍖栨斁缃埌杩欓噷*/ - example_init_touch_panel(); - - ESP_LOGI(TAG, "Initialize LVGL library"); - lv_init(); - // alloc draw buffers used by LVGL - // it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized - uint32_t draw_buf_alloc_caps = 0; - -#if CONFIG_EXAMPLE_LCD_I80_COLOR_IN_PSRAM - draw_buf_alloc_caps |= MALLOC_CAP_SPIRAM; -#endif - lv_color_t *buf1 = esp_lcd_i80_alloc_draw_buffer(io_handle, EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), draw_buf_alloc_caps); - lv_color_t *buf2 = esp_lcd_i80_alloc_draw_buffer(io_handle, EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), draw_buf_alloc_caps); - assert(buf1); - assert(buf2); - ESP_LOGI(TAG, "buf1@%p, buf2@%p", buf1, buf2); - // initialize LVGL draw buffers - lv_disp_draw_buf_init(&disp_buf, buf1, buf2, EXAMPLE_LCD_H_RES * 100); - - ESP_LOGI(TAG, "Register display driver to LVGL"); - lv_disp_drv_init(&disp_drv); - disp_drv.hor_res = EXAMPLE_LCD_H_RES; - disp_drv.ver_res = EXAMPLE_LCD_V_RES; - disp_drv.flush_cb = example_lvgl_flush_cb; - disp_drv.draw_buf = &disp_buf; - disp_drv.user_data = panel_handle; - lv_disp_t *disp = lv_disp_drv_register(&disp_drv); - - ESP_LOGI(TAG, "Install LVGL tick timer"); - // Tick interface for LVGL (using esp_timer to generate 2ms periodic event) - const esp_timer_create_args_t lvgl_tick_timer_args = { - .callback = &example_increase_lvgl_tick, - .name = "lvgl_tick" - }; - esp_timer_handle_t lvgl_tick_timer = NULL; - ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer)); - ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000)); - - /*瀹夎瑙︽懜灞忛┍鍔ㄥ嚱鏁*/ - static lv_indev_drv_t indev_drv; // Input device driver (Touch) - lv_indev_drv_init(&indev_drv); - indev_drv.type = LV_INDEV_TYPE_POINTER; - indev_drv.disp = disp; - indev_drv.read_cb = example_lvgl_touch_cb; - indev_drv.user_data = tp; - - lv_indev_drv_register(&indev_drv); - - lvgl_mux = xSemaphoreCreateRecursiveMutex(); - assert(lvgl_mux); - ESP_LOGI(TAG, "Create LVGL task"); - xTaskCreate(example_lvgl_port_task, "LVGL", EXAMPLE_LVGL_TASK_STACK_SIZE, NULL, EXAMPLE_LVGL_TASK_PRIORITY, NULL); - - ESP_LOGI(TAG, "Display LVGL animation"); - - /*娴嬭瘯git*/ - /*閰嶇疆LEDC杩涜鑳屽厜浜害璋冭妭 */ - example_ledc_init(); - - /*鍒濆鍖朣D鍗*/ - flux_sd_init(); - - /*鐢垫簮绠$悊寮濮*/ - powerInit(); - - /*鍒濆鍖杦ifi鎵弿鐜*/ - wifi_scanInit(); - - // Lock the mutex due to the LVGL APIs are not thread-safe - if (example_lvgl_lock(-1)) { - - //example_lvgl_demo_ui(disp); - ui_init(); - - /*闅愯棌椤堕儴鍔犺浇鍦堝湀*/ - lv_obj_add_flag(ui_pageHome_spinnerStateBusy, LV_OBJ_FLAG_HIDDEN); - lv_event_send(ui_pageSDCard_buttonReadSDCard, LV_EVENT_CLICKED, NULL); - -#if USE_MODBUS_OFFICIAL - /*鍒濆鍖朚odbus*/ - ESP_ERROR_CHECK(modbus_master_init()); -#else - /*鐩存帴浣跨敤涓插彛杩涜鎺у埗*/ - - /*鍒涘缓UART1鍝嶅簲浠诲姟*/ - xTaskCreate(uart1_echoTask, "uart1_echo_task", ECHO_TASK_STACK_SIZE, NULL, 10, NULL); - - /*鍒涘缓UART2鍝嶅簲浠诲姟*/ - xTaskCreate(uart2_echoTask, "uart2_echo_task", ECHO_TASK_STACK_SIZE, NULL, 10, NULL); -#endif - - // Release the mutex - example_lvgl_unlock(); - } -} diff --git a/main/main.cc b/main/main.cc new file mode 100644 index 0000000..1cb2c15 --- /dev/null +++ b/main/main.cc @@ -0,0 +1,19 @@ +/* + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#include "main.h" + +/*包含按键控制头文件*/ +#include "FluxButton.h" + +extern "C" void app_main(void) +{ + + + +} + + diff --git a/main/main.h b/main/main.h new file mode 100644 index 0000000..050a487 --- /dev/null +++ b/main/main.h @@ -0,0 +1,41 @@ + +#ifndef __MAIN_H__ +#define __MAIN_H__ + + + +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/semphr.h" +#include "esp_timer.h" +#include "esp_err.h" +#include "esp_log.h" +#include "esp_lcd_panel_io.h" +#include "esp_lcd_panel_vendor.h" +#include "esp_lcd_panel_ops.h" +#include "esp_spiffs.h" +#include "driver/gpio.h" +#include "driver/ledc.h" +#include "lvgl.h" + + +#include +#include "wifi_station.h" +#include "ssid_manager.h" +#include "dns_server.h" +#include "wifi_configuration_ap.h" + +#include "nvs_flash.h" + + +/*包含串口控制头文件*/ +#include "FluxUart.h" + + + + +#endif + + +