diff --git a/main/display.c b/main/display.c --- a/main/display.c +++ b/main/display.c @@ -467,6 +467,9 @@ void display_slider() lv_obj_align_to(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); } + + + static void slider_event_cb(lv_event_t *e) { lv_obj_t *slider = lv_event_get_target(e); @@ -497,14 +500,25 @@ void bsp_display_unlock(void) } - - +lv_obj_t *label; +void display_update_text(char* str) +{ + bsp_display_lock(0); + lv_label_set_text(label, str); + bsp_display_unlock(); +} void display_process(void) { bsp_display_lock(0); + + lv_obj_t *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); + + // display_slider(); //Call one at a time to see examples display_meter(); @@ -514,7 +528,6 @@ void display_process(void) bsp_display_unlock(); - while(1){} } diff --git a/main/display.h b/main/display.h --- a/main/display.h +++ b/main/display.h @@ -74,6 +74,7 @@ bool bsp_display_lock(uint32_t timeout_m void display_init(void); +void display_update_text(char* string); void display_process(void); diff --git a/main/main.c b/main/main.c --- a/main/main.c +++ b/main/main.c @@ -36,19 +36,21 @@ void app_main(void) } ESP_ERROR_CHECK(ret); + // Initialize display + display_init(); + display_process(); + + vTaskDelay(1000 / portTICK_PERIOD_MS); // Connect to wifi - //wifi_init(); + wifi_init(); // Initialize canbus //can_init(); - // Initialize display - display_init(); while(1) { - display_process(); } } diff --git a/main/wifi.c b/main/wifi.c --- a/main/wifi.c +++ b/main/wifi.c @@ -8,6 +8,7 @@ #include "esp_log.h" #include "lwip/err.h" #include "lwip/sys.h" +#include "display.h" // Private variables @@ -31,17 +32,24 @@ 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"); + } else { xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT); } ESP_LOGI(TAG,"connect to the AP 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)); + char out[128] = {0}; + snprintf(out, 128, "Got IP " IPSTR, IP2STR(&event->ip_info.ip)); + display_update_text(out); s_retry_num = 0; xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); }