Factory example recording GPS completion takes time

This commit is contained in:
lewisxhe
2025-06-20 10:10:54 +08:00
parent a84522e8c4
commit a107982e04
2 changed files with 27 additions and 8 deletions
+18 -5
View File
@@ -98,7 +98,7 @@ TouchDrvGT911 touch;
lv_indev_t *kb_indev = NULL;
lv_indev_t *mouse_indev = NULL;
lv_indev_t *touch_indev = NULL;
uint32_t gps_start_ms = 0;
LV_IMG_DECLARE(image_emoji);
@@ -155,7 +155,7 @@ static bool GPS_Recovery();
extern void updateGPS(double lat, double lng,
uint16_t year, uint8_t month, uint8_t day,
uint8_t hour, uint8_t minute, uint8_t second,
double speed, uint32_t rx_char );
double speed, uint32_t rx_char, uint32_t use_sec);
extern void updateNoiseLabel(uint32_t cnt);
extern void setLoRaMessage(const char *text);
extern void setupUI(void);
@@ -471,10 +471,12 @@ void taskPlaySong(void *p)
}
}
uint32_t gps_update_interval = 0;
bool update_use_second = false;
uint32_t gps_use_second = 0;
void loopGPS()
{
static uint32_t gps_update_interval = 0;
unsigned long start = millis();
do {
while (SerialGPS.available()) {
@@ -485,6 +487,14 @@ void loopGPS()
} while (millis() - start < 20);
if (gps_update_interval < millis()) {
bool location = gps.location.isValid();
bool datetime = (gps.date.year() > 2000);
if (location && datetime && !update_use_second) {
update_use_second = true;
gps_use_second = (millis() - gps_start_ms) / 1000;
}
updateGPS(gps.location.lat(),
gps.location.lng(),
gps.date.year(),
@@ -494,7 +504,8 @@ void loopGPS()
gps.time.minute(),
gps.time.second(),
gps.speed.value(),
gps.charsProcessed());
gps.charsProcessed(),
gps_use_second);
gps_update_interval = millis() + 3000;
}
}
@@ -1039,6 +1050,8 @@ void setup()
}
}
// Record GPS start time
gps_start_ms = millis();
lv_obj_del(logo);
+9 -3
View File
@@ -23,6 +23,7 @@ typedef struct {
lv_obj_t *label_time;
lv_obj_t *label_speed;
lv_obj_t *label_processchar;
lv_obj_t *label_use_seconds;
} Deck_GPS_t;
Deck_GPS_t sub_gps_val;
@@ -36,7 +37,7 @@ typedef struct {
Deck_Radio_t sub_radio_val;
static lv_obj_t *sound_vad_label;
std::vector<lv_obj_t *>sub_section;
std::vector < lv_obj_t * > sub_section;
enum {
LV_MENU_ITEM_BUILDER_VARIANT_1,
@@ -130,11 +131,15 @@ void setLoRaMessage(const char *text)
void updateGPS(double lat, double lng,
uint16_t year, uint8_t month, uint8_t day,
uint8_t hour, uint8_t minute, uint8_t second,
double speed, uint32_t rx_char )
double speed, uint32_t rx_char, uint32_t use_sec)
{
if (use_sec == 0) {
lv_label_set_text_fmt(sub_gps_val.label_use_seconds, "N.A");
} else {
lv_label_set_text_fmt(sub_gps_val.label_use_seconds, "%u", use_sec);
}
lv_label_set_text_fmt(sub_gps_val.label_lng, "%.6f", lng);
lv_label_set_text_fmt(sub_gps_val.label_lat, "%.6f", lat);
lv_label_set_text_fmt(sub_gps_val.label_date, "%u/%u/%u", year, month, day);
lv_label_set_text_fmt(sub_gps_val.label_time, "%u:%u:%u", hour, minute, second);
lv_label_set_text_fmt(sub_gps_val.label_speed, "%.6f", speed);
@@ -339,6 +344,7 @@ void setupUI(void)
sub_section.push_back(section);
create_label(section, LV_SYMBOL_GPS, "Model", gps_model.c_str());
sub_gps_val.label_use_seconds = create_label(section, LV_SYMBOL_GPS, "Use Seconds", "N.A");
sub_gps_val.label_lat = create_label(section, LV_SYMBOL_GPS, "lat", "N.A");
sub_gps_val.label_lng = create_label(section, LV_SYMBOL_GPS, "lng", "N.A");
sub_gps_val.label_speed = create_label(section, LV_SYMBOL_SETTINGS, "Speed", "N.A");