Update subghz GPS dir finder & thread logic

also a few other finishing touches
This commit is contained in:
Sil333033
2023-10-08 21:20:42 +02:00
parent f7f3780aef
commit 88b98fb175
7 changed files with 99 additions and 64 deletions

View File

@@ -32,27 +32,29 @@ void subghz_scene_show_gps_draw_satellites(void* context) {
(double)subghz->gps->latitude,
(double)subghz->gps->longitude);
char* angle_str = "N";
if(angle > 22.5 && angle <= 67.5) {
char* angle_str = "?";
if(angle > -22.5 && angle <= 22.5) {
angle_str = "E";
} else if(angle > 22.5 && angle <= 67.5) {
angle_str = "NE";
} else if(angle > 67.5 && angle <= 112.5) {
angle_str = "E";
angle_str = "N";
} else if(angle > 112.5 && angle <= 157.5) {
angle_str = "SE";
} else if(angle > 157.5 && angle <= 202.5) {
angle_str = "S";
} else if(angle > 202.5 && angle <= 247.5) {
angle_str = "SW";
} else if(angle > 247.5 && angle <= 292.5) {
angle_str = "W";
} else if(angle > 292.5 && angle <= 337.5) {
angle_str = "NW";
} else if(angle < -22.5 && angle >= -67.5) {
angle_str = "SE";
} else if(angle < -67.5 && angle >= -112.5) {
angle_str = "S";
} else if(angle < -112.5 && angle >= -157.5) {
angle_str = "SW";
} else if(angle < -157.5 || angle >= 157.5) {
angle_str = "W";
}
FuriString* lat_str = furi_string_alloc();
FuriString* lon_str = furi_string_alloc();
if(isnan(subghz->gps->latitude)) {
if(isnan(subghz_history_get_latitude(subghz->history, subghz->idx_menu_chosen))) {
furi_string_printf(lat_str, "N/A");
} else {
furi_string_printf(
@@ -61,7 +63,7 @@ void subghz_scene_show_gps_draw_satellites(void* context) {
(double)subghz_history_get_latitude(subghz->history, subghz->idx_menu_chosen));
}
if(isnan(subghz->gps->longitude)) {
if(isnan(subghz_history_get_longitude(subghz->history, subghz->idx_menu_chosen))) {
furi_string_printf(lon_str, "N/A");
} else {
furi_string_printf(
@@ -72,7 +74,7 @@ void subghz_scene_show_gps_draw_satellites(void* context) {
furi_string_printf(
text,
"Captured at: %s,\r\n%s Time: %s\r\n\r\nRealtime: Sats: %d\r\nDistance: %.2f%s Dir: %s\r\nGPS time: %d:%d:%d UTC",
"Captured at: %s,\r\n%s Time: %s\r\n\r\nRealtime: Sats: %d\r\nDistance: %.2f%s Dir: %s\r\nGPS time: %02d:%02d:%02d UTC",
furi_string_get_cstr(lat_str),
furi_string_get_cstr(lon_str),
furi_string_get_cstr(time_text),
@@ -102,15 +104,13 @@ void subghz_scene_show_gps_refresh_screen(void* context) {
void subghz_scene_show_gps_on_enter(void* context) {
SubGhz* subghz = context;
if(subghz->last_settings->gps_enabled) {
furi_thread_start(subghz->gps->thread);
}
subghz_scene_show_gps_draw_satellites(subghz);
subghz->gps->timer =
furi_timer_alloc(subghz_scene_show_gps_refresh_screen, FuriTimerTypePeriodic, subghz);
furi_timer_start(subghz->gps->timer, 1000);
if(subghz->last_settings->gps_enabled) {
subghz->gps->timer =
furi_timer_alloc(subghz_scene_show_gps_refresh_screen, FuriTimerTypePeriodic, subghz);
furi_timer_start(subghz->gps->timer, 1000);
}
}
bool subghz_scene_show_gps_on_event(void* context, SceneManagerEvent event) {
@@ -135,12 +135,9 @@ void subghz_scene_show_gps_on_exit(void* context) {
SubGhz* subghz = context;
if(subghz->last_settings->gps_enabled) {
furi_thread_flags_set(furi_thread_get_id(subghz->gps->thread), WorkerEvtStop);
furi_thread_join(subghz->gps->thread);
furi_timer_stop(subghz->gps->timer);
furi_timer_free(subghz->gps->timer);
}
furi_timer_stop(subghz->gps->timer);
furi_timer_free(subghz->gps->timer);
widget_reset(subghz->widget);
}