From b6f0e57fc935a95f146533e585e1c8ceb66b148b Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Fri, 20 Sep 2024 11:32:56 +0800 Subject: [PATCH] Update UnitTest example --- examples/UnitTest/UnitTest.ino | 24 ++++++++++++++++++++++-- examples/UnitTest/ui.cpp | 10 ++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/examples/UnitTest/UnitTest.ino b/examples/UnitTest/UnitTest.ino index 7f49238..ca32d87 100644 --- a/examples/UnitTest/UnitTest.ino +++ b/examples/UnitTest/UnitTest.ino @@ -1008,10 +1008,17 @@ void setup() setupWiFi(); if (!setupGPS()) { - // set ubox m10q gps baudrate 38400 SerialGPS.begin(38400, SERIAL_8N1, BOARD_GPS_RX_PIN, BOARD_GPS_TX_PIN); + uint32_t baudrate[] = {38400, 115200, 9600}; // Restore factory settings - GPS_Recovery(); + for (int i = 0; i < 3; ++i) { + Serial.printf("Use baudrate : %u\n", baudrate[i]); + if (GPS_Recovery()) { + break; + } + Serial.printf("Update baudrate : %u\n", baudrate[i]); + SerialGPS.updateBaudRate(baudrate[i]); + } } @@ -1150,10 +1157,23 @@ static void touchpad_read( lv_indev_drv_t *indev_driver, lv_indev_data_t *data ) // Read key value from esp32c3 static uint32_t keypad_get_key(void) { + static uint32_t retry = 0; char key_ch = 0; + if (retry > 10) { + lv_indev_delete(kb_indev); + kb_indev = NULL; + return 0; + } + Wire.beginTransmission(0x55); + if (Wire.endTransmission() != 0) { + Serial.println("Keyboard Failed!"); + retry++; + return 0; + } Wire.requestFrom(0x55, 1); while (Wire.available() > 0) { key_ch = Wire.read(); + retry = 0; } return key_ch; } diff --git a/examples/UnitTest/ui.cpp b/examples/UnitTest/ui.cpp index 756853d..6dfe203 100644 --- a/examples/UnitTest/ui.cpp +++ b/examples/UnitTest/ui.cpp @@ -332,6 +332,16 @@ void setupUI(void) lv_textarea_set_max_length(radio_ta, 1024); sub_section.push_back(radio_ta); + + lv_timer_create([](lv_timer_t *t) { + extern lv_indev_t *kb_indev ; + if (NULL == kb_indev) { + lv_obj_t *radio_ta = (lv_obj_t *)t->user_data; + lv_textarea_set_text(radio_ta, "Keyboard is offline"); + lv_obj_invalidate(radio_ta); + } + }, 3000, radio_ta); + //! SD // lv_obj_t *sub_sd_page = lv_menu_page_create(menu, NULL); // lv_obj_set_style_pad_hor(sub_sd_page, lv_obj_get_style_pad_left(lv_menu_get_main_header(menu), 0), 0);