#include #include #include #include #include #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/queue.h" #include "freertos/semphr.h" #include "freertos/event_groups.h" #include "driver/gpio.h" // #include "driver/i2c.h" // #include "driver/i2c_master.h" #include "driver/spi_master.h" #include "esp_timer.h" #include "esp_lcd_panel_io.h" #include "esp_lcd_panel_vendor.h" #include "esp_lcd_panel_ops.h" #include "esp_err.h" #include "esp_log.h" #include "lvgl.h" #include "lv_demos.h" #include "esp_lcd_qspi_amoled.h" #include "esp_spiffs.h" #include "sys/stat.h" #include "driver/i2s.h" #include "esp_afe_sr_models.h" #include "esp_websocket_client.h" #include "esp_mn_speech_commands.h" #include "esp_mn_iface.h" #include "esp_wn_iface.h" #include "esp_wn_models.h" #include "model_path.h" #include "esp_mn_models.h" #include "nvs_flash.h" #include "esp_system.h" #include "esp_wifi.h" #include "esp_event.h" #include "esp_mac.h" // #include "BluFi.h" // #include "WebSocket.h" #include "FLASH/flash.h" #include "OTA/ota_upgrade.h" #include "MQTT/mqtt.h" #include "cjson.h" #include "miniz.h" #include "MOTOR/motor.h" #include "ZIP_EXTRACTOR/zip_extractor.h" #include "SC7U22/SC7U22.h" #include "event.h" #include "esp_random.h" #include "ES7243E/ES7243E.h" // static const char *TAG = "example"; // 使用独特的TAG名称,避免冲突 extern const char *TAG_MAIN; extern esp_lcd_panel_handle_t panel_handle; #define LV_MEM_CUSTOM 1 #define LV_MEM_CUSTOM_INCLUDE "esp_heap_caps.h" #define LV_MEM_CUSTOM_ALLOC(size) heap_caps_malloc(size, MALLOC_CAP_SPIRAM) #define LV_MEM_CUSTOM_FREE(ptr) heap_caps_free(ptr) #define LV_MEM_CUSTOM_REALLOC(ptr, size) heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM) #define LOTTIE_ANIM_WIDTH 516 #define LOTTIE_ANIM_HEIGHT 410 // #define LOTTIE_ANIM_WIDTH 200 // #define LOTTIE_ANIM_HEIGHT 200 #define EXAMPLE_LVGL_TASK_PRIORITY 7 #define FEED_TASK_PRIORITY 4 #define DETECT_TASK_PRIORITY 5 #define CHANGE_TASK_PRIORITY 7 //7 #define MAIN_TASK_PRIORITY 8 //5 #define BMI_TASK_PRIORITY 8 #define NST112_TASK_PRIORITY 8 #define MS523_TASK_PRIORITY 8 #define PET_TASK_PRIORITY 8 #define HOUR_WRITE_TASK_PRIORITY 8 // #define LVGL_TASK_STACK_SIZE (40 * 1024) // #define FEED_TASK_STACK_SIZE (8 * 1024) // #define DETECT_TASK_STACK_SIZE (8 * 1024) // #define CHANGE_TASK_STACK_SIZE (30 * 1024) // #define MAIN_TASK_STACK_SIZE (8 * 1024) // #define BMI_TASK_STACK_SIZE (8192) #define LVGL_TASK_STACK_SIZE (40 * 1024) #define FEED_TASK_STACK_SIZE (16 * 1024) #define DETECT_TASK_STACK_SIZE (32 * 1024) #define CHANGE_TASK_STACK_SIZE (50 * 1024) //30 * 1024 #define MAIN_TASK_STACK_SIZE (16 * 1024) #define BMI_TASK_STACK_SIZE (8192) #define NST112_TASK_STACK_SIZE (8192) #define MS523_TASK_STACK_SIZE (8192) #define PET_TASK_STACK_SIZE (4096) #define HOUR_WRITE_STACK_SIZE (4096) #define LCD_HOST SPI2_HOST // #define TOUCH_HOST I2C_NUM_1 #define TOUCH_HOST I2C_NUM_0 #if LV_COLOR_DEPTH == 16 #define LCD_BIT_PER_PIXEL (16) #define LV_COLOR_FORMAT LV_COLOR_FORMAT_RGB565 #define LCD_RGB_ELEMENT_ORDER LCD_RGB_ELEMENT_ORDER_RGB #elif LV_COLOR_DEPTH == 24 #define LCD_BIT_PER_PIXEL (24) #define LV_COLOR_FORMAT LV_COLOR_FORMAT_RGB888 #define LCD_RGB_ELEMENT_ORDER LCD_RGB_ELEMENT_ORDER_BGR #endif #define EXAMPLE_USE_TOUCH 1 //开启或者关闭触摸 extern esp_lcd_panel_handle_t panel_handle; extern esp_lcd_panel_io_handle_t io_handle; #define CST816_ID 1 #define CST820_ID 2 #define CHSC6417_ID 3 #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 (4 * 1024 * 2) #define AM196Q410502LK_196_410x502 1 #define AM178Q368448LK_178_368x448 2 #define AM151Q466466LK_151_466x466_C 3 #define AM160Q480480LK_160_480x480_C 4 #define AM201Q240296LK_201_240x296 5 #define AM200Q460460LK_200_460x460 6 #define AM160Q320360ZS_160_320x360 7 #define AM119Q390390FLS2_119_390x390 8 #define AM165Q348442FLS_165_348x442 9 #define CURRENT_SCREEN_SIZE AM196Q410502LK_196_410x502 #if CURRENT_SCREEN_SIZE == AM196Q410502LK_196_410x502 // #define EXAMPLE_PIN_NUM_LCD_CS (GPIO_NUM_40) // #define EXAMPLE_PIN_NUM_LCD_PCLK (GPIO_NUM_21) // #define EXAMPLE_PIN_NUM_LCD_DATA0 (GPIO_NUM_47) // #define EXAMPLE_PIN_NUM_LCD_DATA1 (GPIO_NUM_45) // #define EXAMPLE_PIN_NUM_LCD_DATA2 (GPIO_NUM_38) // #define EXAMPLE_PIN_NUM_LCD_DATA3 (GPIO_NUM_39) // #define EXAMPLE_PIN_NUM_LCD_RST (GPIO_NUM_41) // #define EXAMPLE_PIN_NUM_LCD_CS (GPIO_NUM_8) // #define EXAMPLE_PIN_NUM_LCD_PCLK (GPIO_NUM_3) // #define EXAMPLE_PIN_NUM_LCD_DATA0 (GPIO_NUM_9) // #define EXAMPLE_PIN_NUM_LCD_DATA1 (GPIO_NUM_46) // #define EXAMPLE_PIN_NUM_LCD_DATA2 (GPIO_NUM_16) // #define EXAMPLE_PIN_NUM_LCD_DATA3 (GPIO_NUM_15) // #define EXAMPLE_PIN_NUM_LCD_RST (GPIO_NUM_17) // #define EXAMPLE_PIN_NUM_LCD_TE (GPIO_NUM_18) //#define EXAMPLE_PIN_NUM_LCD_CS (GPIO_NUM_7) //#define EXAMPLE_PIN_NUM_LCD_PCLK (GPIO_NUM_1) //#define EXAMPLE_PIN_NUM_LCD_DATA0 (GPIO_NUM_8) //#define EXAMPLE_PIN_NUM_LCD_DATA1 (GPIO_NUM_10) //#define EXAMPLE_PIN_NUM_LCD_DATA2 (GPIO_NUM_11) //#define EXAMPLE_PIN_NUM_LCD_DATA3 (GPIO_NUM_6) //#define EXAMPLE_PIN_NUM_LCD_RST (GPIO_NUM_20) //#define EXAMPLE_PIN_NUM_LCD_TE (GPIO_NUM_21) #define EXAMPLE_PIN_NUM_LCD_CS (GPIO_NUM_7) #define EXAMPLE_PIN_NUM_LCD_PCLK (GPIO_NUM_9) #define EXAMPLE_PIN_NUM_LCD_DATA0 (GPIO_NUM_8) //8 #define EXAMPLE_PIN_NUM_LCD_DATA1 (GPIO_NUM_10) //11 #define EXAMPLE_PIN_NUM_LCD_DATA2 (GPIO_NUM_11) #define EXAMPLE_PIN_NUM_LCD_DATA3 (GPIO_NUM_6) #define EXAMPLE_PIN_NUM_LCD_RST (GPIO_NUM_4) #define EXAMPLE_PIN_NUM_LCD_TE (GPIO_NUM_5) #define EXAMPLE_PIN_NUM_TOUCH_SCL (GPIO_NUM_51) #define EXAMPLE_PIN_NUM_TOUCH_SDA (GPIO_NUM_50) #define EXAMPLE_PIN_NUM_TOUCH_RST (GPIO_NUM_0) #define EXAMPLE_PIN_NUM_TOUCH_INT (GPIO_NUM_1) #define EXAMPLE_LCD_H_RES 410 #define EXAMPLE_LCD_V_RES 502 // #define EXAMPLE_LCD_H_RES 310 // #define EXAMPLE_LCD_V_RES 402 #define EXAMPLE_LCD_X_GAP 0 #define EXAMPLE_LCD_Y_GAP 22 #define EXAMPLE_TOUCH_MIRROR_X false #define EXAMPLE_TOUCH_MIRROR_Y false #define TOUCH_IC_CONFIG CST820_ID #define AMOLED_QSPI_MODE 0 #define AMOLED_QSPI_MAX_PCLK 20 * 1000 * 1000 #define EXAMPLE_LVGL_BUF_HEIGHT (EXAMPLE_LCD_V_RES / 15) #endif #if TOUCH_IC_CONFIG == CST816_ID #include "esp_lcd_touch_cst816.h" #define TOUCH_IO_I2C_CONFIG ESP_LCD_TOUCH_IO_I2C_CST816_CONFIG #define esp_lcd_touch_new_i2c esp_lcd_touch_new_i2c_cst816 #elif TOUCH_IC_CONFIG == CST820_ID #include "esp_lcd_touch_cst820.h" #define TOUCH_IO_I2C_CONFIG ESP_LCD_TOUCH_IO_I2C_CST820_CONFIG #define esp_lcd_touch_new_i2c esp_lcd_touch_new_i2c_cst820 #elif TOUCH_IC_CONFIG == CHSC6417_ID #include "esp_lcd_touch_chsc6417.h" #define TOUCH_IO_I2C_CONFIG ESP_LCD_TOUCH_IO_I2C_CHSC6417_CONFIG #define esp_lcd_touch_new_i2c esp_lcd_touch_new_i2c_chsc6417 #endif extern esp_lcd_touch_handle_t tp;