mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGHz: Show Geo info when GPS is disabled
This commit is contained in:
@@ -162,7 +162,7 @@ static float subghz_gps_calc_angle(float lat1, float lon1, float lat2, float lon
|
||||
return atan2(lat1 - lat2, lon1 - lon2) * 180 / (double)M_PI;
|
||||
}
|
||||
|
||||
static void subghz_gps_get_descr(
|
||||
static void subghz_gps_cat_realtime(
|
||||
SubGhzGPS* subghz_gps,
|
||||
FuriString* descr,
|
||||
float latitude,
|
||||
@@ -192,16 +192,11 @@ static void subghz_gps_get_descr(
|
||||
angle_str = "W";
|
||||
}
|
||||
|
||||
furi_string_printf(
|
||||
furi_string_cat_printf(
|
||||
descr,
|
||||
"Captured at: %f,\r\n"
|
||||
"%f\r\n"
|
||||
"\r\n"
|
||||
"Realtime: Sats: %d\r\n"
|
||||
"Distance: %.2f%s Dir: %s\r\n"
|
||||
"GPS time: %02d:%02d:%02d UTC",
|
||||
(double)latitude,
|
||||
(double)longitude,
|
||||
subghz_gps->satellites,
|
||||
(double)(subghz_gps->satellites > 0 ? distance > 1 ? distance : distance * 1000 : 0),
|
||||
distance > 1 ? "km" : "m",
|
||||
@@ -236,7 +231,7 @@ static void subghz_gps_init(SubGhzGPS* subghz_gps, uint32_t baudrate) {
|
||||
subghz_gps->serial_handle, subghz_gps_uart_on_irq_cb, subghz_gps, false);
|
||||
|
||||
subghz_gps->deinit = &subghz_gps_deinit;
|
||||
subghz_gps->get_descr = &subghz_gps_get_descr;
|
||||
subghz_gps->cat_realtime = &subghz_gps_cat_realtime;
|
||||
}
|
||||
|
||||
#include <flipper_application/flipper_application.h>
|
||||
|
||||
@@ -32,7 +32,7 @@ struct SubGhzGPS {
|
||||
void (*deinit)(SubGhzGPS* subghz_gps);
|
||||
|
||||
/**
|
||||
* Get description for signal info
|
||||
* Concatenate realtime GPS info to string
|
||||
*
|
||||
* @param subghz_gps SubGhzGPS object
|
||||
* @param descr Output string
|
||||
@@ -40,7 +40,7 @@ struct SubGhzGPS {
|
||||
* @param longitude Longitude
|
||||
* @return void
|
||||
*/
|
||||
void (*get_descr)(SubGhzGPS* subghz_gps, FuriString* descr, float latitude, float longitude);
|
||||
void (*cat_realtime)(SubGhzGPS* subghz_gps, FuriString* descr, float latitude, float longitude);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,8 +35,8 @@ void subghz_scene_saved_menu_on_enter(void* context) {
|
||||
subghz_scene_saved_menu_submenu_callback,
|
||||
subghz);
|
||||
|
||||
if(!isnanf(subghz_txrx_get_latitude(subghz->txrx)) &&
|
||||
!isnanf(subghz_txrx_get_longitude(subghz->txrx))) {
|
||||
if(!isnanf(subghz_txrx_get_latitude(subghz->txrx)) ||
|
||||
!isnanf(subghz_txrx_get_longitude(subghz->txrx)) || subghz->gps) {
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Geographic info",
|
||||
|
||||
@@ -3,7 +3,25 @@
|
||||
|
||||
void subghz_scene_show_gps_draw_satellites(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
widget_reset(subghz->widget);
|
||||
|
||||
float latitude, longitude;
|
||||
// Get from saved file or from history
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowGps)) {
|
||||
latitude = subghz_txrx_get_latitude(subghz->txrx);
|
||||
longitude = subghz_txrx_get_longitude(subghz->txrx);
|
||||
} else {
|
||||
latitude = subghz_history_get_latitude(subghz->history, subghz->idx_menu_chosen);
|
||||
longitude = subghz_history_get_longitude(subghz->history, subghz->idx_menu_chosen);
|
||||
}
|
||||
FuriString* text_str = furi_string_alloc_printf(
|
||||
"Captured at: %f,\r\n"
|
||||
"%f\r\n"
|
||||
"\r\n",
|
||||
(double)latitude,
|
||||
(double)longitude);
|
||||
|
||||
if(subghz->gps) {
|
||||
DateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
if((datetime.second - subghz->gps->fix_second) > 15) {
|
||||
@@ -15,28 +33,13 @@ void subghz_scene_show_gps_draw_satellites(void* context) {
|
||||
subghz->gps->fix_second = 0;
|
||||
}
|
||||
|
||||
float latitude, longitude;
|
||||
// Get from saved file or from history
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowGps)) {
|
||||
latitude = subghz_txrx_get_latitude(subghz->txrx);
|
||||
longitude = subghz_txrx_get_longitude(subghz->txrx);
|
||||
} else {
|
||||
latitude = subghz_history_get_latitude(subghz->history, subghz->idx_menu_chosen);
|
||||
longitude = subghz_history_get_longitude(subghz->history, subghz->idx_menu_chosen);
|
||||
subghz->gps->cat_realtime(subghz->gps, text_str, latitude, longitude);
|
||||
}
|
||||
|
||||
FuriString* text_str = furi_string_alloc();
|
||||
subghz->gps->get_descr(subghz->gps, text_str, latitude, longitude);
|
||||
widget_add_text_scroll_element(subghz->widget, 0, 0, 128, 64, furi_string_get_cstr(text_str));
|
||||
furi_string_free(text_str);
|
||||
}
|
||||
|
||||
void subghz_scene_show_gps_refresh_screen(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
widget_reset(subghz->widget);
|
||||
subghz_scene_show_gps_draw_satellites(subghz);
|
||||
}
|
||||
|
||||
void subghz_scene_show_gps_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
@@ -44,7 +47,7 @@ void subghz_scene_show_gps_on_enter(void* context) {
|
||||
|
||||
if(subghz->gps) {
|
||||
subghz->gps->timer =
|
||||
furi_timer_alloc(subghz_scene_show_gps_refresh_screen, FuriTimerTypePeriodic, subghz);
|
||||
furi_timer_alloc(subghz_scene_show_gps_draw_satellites, FuriTimerTypePeriodic, subghz);
|
||||
furi_timer_start(subghz->gps->timer, 1000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user