diff --git a/main/display.c b/main/display.c --- a/main/display.c +++ b/main/display.c @@ -25,6 +25,8 @@ static const char *TAG = "LVGL_SETUP"; static void lvgl_timer_task(void *arg); + + static lv_obj_t *ui_Screen1; static lv_obj_t *ui_redsquare; @@ -43,6 +45,9 @@ LV_IMG_DECLARE(red_square) static SemaphoreHandle_t lvgl_mux; // LVGL mutex static SemaphoreHandle_t touch_mux; // Touch mutex + +#if USE_TOUCH_DISPLAY + static void bsp_touchpad_read(lv_indev_drv_t *drv, lv_indev_data_t *data) { uint16_t touchpad_x[1] = {0}; @@ -82,6 +87,8 @@ static void touch_callback(esp_lcd_touch } } +#endif + static void set_value(void *indic, int32_t v) { lv_meter_set_indicator_end_value(meter, indic, v); @@ -275,8 +282,10 @@ void display_init() lvgl_mux = xSemaphoreCreateMutex(); BSP_NULL_CHECK(lvgl_mux, NULL); +#if USE_TOUCH_DISPLAY touch_mux = xSemaphoreCreateBinary(); BSP_NULL_CHECK(touch_mux, NULL); +#endif // it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized lv_color_t *buf1 = heap_caps_malloc(LVGL_LCD_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA); @@ -315,6 +324,8 @@ void display_init() #endif xTaskCreatePinnedToCore(lvgl_timer_task, "lvgl Timer", 10000, NULL, 4, NULL, 1); + + } static void lvgl_timer_task(void *arg) @@ -509,12 +520,15 @@ void display_update_text(char* str) } + +// make a display task that listens for messages from a queue that change visual elements + void display_process(void) { bsp_display_lock(0); - lv_obj_t *label = lv_label_create(lv_scr_act()); + label = lv_label_create(lv_scr_act()); lv_label_set_text(label, "Yup"); // lv_obj_align_to(label, lv_scr_act(), LV_ALIGN_OUT_BOTTOM_MID, 0, 10); @@ -528,9 +542,7 @@ void display_process(void) bsp_display_unlock(); -} - +} - diff --git a/main/display.h b/main/display.h --- a/main/display.h +++ b/main/display.h @@ -69,7 +69,11 @@ void get_img_color(); void bsp_display_unlock(void); bool bsp_display_lock(uint32_t timeout_ms); - +typedef struct _display_update_s +{ + uint32_t element; + char text[64]; +} display_update_t; @@ -78,4 +82,5 @@ void display_update_text(char* string); void display_process(void); + #endif \ No newline at end of file diff --git a/main/main.c b/main/main.c --- a/main/main.c +++ b/main/main.c @@ -13,7 +13,7 @@ #include "sdkconfig.h" #include "wifi.h" -#include "usb_cdc.h" +// #include "usb_cdc.h" #include "can.h" #include "display.h" @@ -26,7 +26,7 @@ static const char *TAG = "main"; void app_main(void) { // Initialize usb-cdc interface - usb_cdc_init(); + // usb_cdc_init(); // Initialize NVS esp_err_t ret = nvs_flash_init(); @@ -36,11 +36,13 @@ void app_main(void) } ESP_ERROR_CHECK(ret); + //vTaskDelay(pdTICKS_TO_MS(3000)); + + // Initialize display display_init(); display_process(); - vTaskDelay(1000 / portTICK_PERIOD_MS); // Connect to wifi wifi_init(); @@ -51,6 +53,7 @@ void app_main(void) while(1) { + vTaskDelay(pdMS_TO_TICKS(1000)); } } diff --git a/main/wifi.c b/main/wifi.c --- a/main/wifi.c +++ b/main/wifi.c @@ -34,7 +34,7 @@ static void __event_handler(void* arg, e esp_wifi_connect(); s_retry_num++; ESP_LOGI(TAG, "retry to connect to the AP"); - display_update_text("AP Connect Retry"); + //display_update_text("AP Connect Retry"); } else @@ -42,16 +42,18 @@ static void __event_handler(void* arg, e xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); } ESP_LOGI(TAG,"connect to the AP fail"); - display_update_text("AP Connect Fail"); + //display_update_text("AP Connect 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)); + ESP_LOGI(TAG, "WIFI OK, IP: " IPSTR, IP2STR(&event->ip_info.ip)); char out[128] = {0}; - snprintf(out, 128, "Got IP " IPSTR, IP2STR(&event->ip_info.ip)); + snprintf(out, 128, "WIFI OK, IP: " IPSTR, IP2STR(&event->ip_info.ip)); display_update_text(out); + + s_retry_num = 0; xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); }