mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 07:18:35 -07:00
Update subghz GPS changable baudrate --nobuild
This commit is contained in:
@@ -132,7 +132,6 @@ SubGhzGPS* subghz_gps_init() {
|
||||
}
|
||||
|
||||
furi_hal_uart_set_irq_cb(UART_CH, subghz_gps_uart_on_irq_cb, subghz_gps);
|
||||
furi_hal_uart_set_br(UART_CH, 9600);
|
||||
|
||||
return subghz_gps;
|
||||
}
|
||||
@@ -160,6 +159,10 @@ void subghz_gps_stop(SubGhzGPS* subghz_gps) {
|
||||
furi_thread_join(subghz_gps->thread);
|
||||
}
|
||||
|
||||
void subghz_gps_set_baudrate(uint32_t baudrate) {
|
||||
furi_hal_uart_set_br(UART_CH, baudrate);
|
||||
}
|
||||
|
||||
double subghz_gps_deg2rad(double deg) {
|
||||
return (deg * (double)M_PI / 180);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,14 @@ void subghz_gps_start(SubGhzGPS* subghz_gps);
|
||||
*/
|
||||
void subghz_gps_stop(SubGhzGPS* subghz_gps);
|
||||
|
||||
/**
|
||||
* Set baudrate for GPS
|
||||
*
|
||||
* @param baudrate Baudrate
|
||||
* @return void
|
||||
*/
|
||||
void subghz_gps_set_baudrate(uint32_t baudrate);
|
||||
|
||||
/**
|
||||
* Convert degree to radian
|
||||
*
|
||||
|
||||
@@ -32,10 +32,14 @@ const char* const debug_pin_text[DEBUG_P_COUNT] = {
|
||||
"17(1W)",
|
||||
};
|
||||
|
||||
#define GPS_COUNT 2
|
||||
#define GPS_COUNT 6
|
||||
const char* const gps_text[GPS_COUNT] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
"9600",
|
||||
"19200",
|
||||
"38400",
|
||||
"57600",
|
||||
"115200",
|
||||
};
|
||||
|
||||
#define DEBUG_COUNTER_COUNT 13
|
||||
@@ -127,11 +131,30 @@ static void subghz_scene_receiver_config_set_gps(VariableItem* item) {
|
||||
|
||||
variable_item_set_current_value_text(item, gps_text[index]);
|
||||
|
||||
subghz->last_settings->gps_enabled = index == 1;
|
||||
subghz_last_settings_save(
|
||||
subghz->last_settings); //TODO, make it to choose baudrate. now it is 9600
|
||||
switch(index) {
|
||||
case 0:
|
||||
subghz->last_settings->gps_baudrate = 0;
|
||||
break;
|
||||
case 1:
|
||||
subghz->last_settings->gps_baudrate = 9600;
|
||||
break;
|
||||
case 2:
|
||||
subghz->last_settings->gps_baudrate = 19200;
|
||||
break;
|
||||
case 3:
|
||||
subghz->last_settings->gps_baudrate = 38400;
|
||||
break;
|
||||
case 4:
|
||||
subghz->last_settings->gps_baudrate = 57600;
|
||||
break;
|
||||
case 5:
|
||||
subghz->last_settings->gps_baudrate = 115200;
|
||||
break;
|
||||
}
|
||||
subghz_last_settings_save(subghz->last_settings);
|
||||
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
subghz_gps_set_baudrate(subghz->last_settings->gps_baudrate);
|
||||
subghz_gps_start(subghz->gps);
|
||||
} else {
|
||||
subghz_gps_stop(subghz->gps);
|
||||
@@ -181,8 +204,15 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
||||
variable_item_set_current_value_text(item, ext_mod_power_amp_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
variable_item_list, "GPS", GPS_COUNT, subghz_scene_receiver_config_set_gps, subghz);
|
||||
value_index = subghz->last_settings->gps_enabled ? 1 : 0;
|
||||
variable_item_list,
|
||||
"GPS Baudrate",
|
||||
GPS_COUNT,
|
||||
subghz_scene_receiver_config_set_gps,
|
||||
subghz);
|
||||
value_index = value_index_uint32(
|
||||
subghz->last_settings->gps_baudrate,
|
||||
(const uint32_t[]){0, 9600, 19200, 38400, 57600, 115200},
|
||||
GPS_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, gps_text[value_index]);
|
||||
|
||||
|
||||
@@ -290,7 +290,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzThresholdRssiData ret_rssi = subghz_threshold_get_rssi_data(
|
||||
subghz->threshold_rssi, subghz_txrx_radio_device_get_rssi(subghz->txrx));
|
||||
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
FuriHalRtcDateTime datetime;
|
||||
furi_hal_rtc_get_datetime(&datetime);
|
||||
if((datetime.second - subghz->gps->fix_second) > 15) {
|
||||
@@ -310,7 +310,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
switch(subghz->state_notifications) {
|
||||
case SubGhzNotificationStateRx:
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
if(subghz->gps->satellites > 0) {
|
||||
notification_message(subghz->notifications, &sequence_blink_green_10);
|
||||
} else {
|
||||
|
||||
@@ -19,7 +19,7 @@ void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, v
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoSave);
|
||||
} else if(
|
||||
(result == GuiButtonTypeLeft) && (type == InputTypeShort) &&
|
||||
subghz->last_settings->gps_enabled) {
|
||||
subghz->last_settings->gps_baudrate != 0) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoSats);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) {
|
||||
widget_add_string_multiline_element(
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(text));
|
||||
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
widget_add_button_element(
|
||||
subghz->widget,
|
||||
GuiButtonTypeLeft,
|
||||
@@ -185,7 +185,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventSceneReceiverInfoSats) {
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowGps);
|
||||
return true;
|
||||
} else {
|
||||
@@ -201,7 +201,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
notification_message(subghz->notifications, &sequence_blink_magenta_10);
|
||||
break;
|
||||
case SubGhzNotificationStateRx:
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
if(subghz->gps->satellites > 0) {
|
||||
notification_message(subghz->notifications, &sequence_blink_green_10);
|
||||
} else {
|
||||
|
||||
@@ -80,7 +80,7 @@ void subghz_scene_saved_show_gps_on_enter(void* context) {
|
||||
|
||||
subghz_scene_saved_show_gps_draw_satellites(subghz);
|
||||
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
subghz->gps->timer = furi_timer_alloc(
|
||||
subghz_scene_saved_show_gps_refresh_screen, FuriTimerTypePeriodic, subghz);
|
||||
furi_timer_start(subghz->gps->timer, 1000);
|
||||
@@ -98,7 +98,7 @@ bool subghz_scene_saved_show_gps_on_event(void* context, SceneManagerEvent event
|
||||
void subghz_scene_saved_show_gps_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
furi_timer_stop(subghz->gps->timer);
|
||||
furi_timer_free(subghz->gps->timer);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ void subghz_scene_show_gps_on_enter(void* context) {
|
||||
|
||||
subghz_scene_show_gps_draw_satellites(subghz);
|
||||
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
subghz->gps->timer =
|
||||
furi_timer_alloc(subghz_scene_show_gps_refresh_screen, FuriTimerTypePeriodic, subghz);
|
||||
furi_timer_start(subghz->gps->timer, 1000);
|
||||
@@ -117,7 +117,7 @@ bool subghz_scene_show_gps_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeTick) {
|
||||
if(subghz->state_notifications == SubGhzNotificationStateRx) {
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
if(subghz->gps->satellites > 0) {
|
||||
notification_message(subghz->notifications, &sequence_blink_green_10);
|
||||
} else {
|
||||
@@ -134,7 +134,7 @@ bool subghz_scene_show_gps_on_event(void* context, SceneManagerEvent event) {
|
||||
void subghz_scene_show_gps_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
furi_timer_stop(subghz->gps->timer);
|
||||
furi_timer_free(subghz->gps->timer);
|
||||
}
|
||||
|
||||
@@ -245,7 +245,8 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
||||
subghz->error_str = furi_string_alloc();
|
||||
|
||||
subghz->gps = subghz_gps_init();
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
subghz_gps_set_baudrate(subghz->last_settings->gps_baudrate);
|
||||
subghz_gps_start(subghz->gps);
|
||||
}
|
||||
|
||||
@@ -344,7 +345,7 @@ void subghz_free(SubGhz* subghz, bool alloc_for_tx_only) {
|
||||
furi_string_free(subghz->file_path_tmp);
|
||||
|
||||
// GPS
|
||||
if(subghz->last_settings->gps_enabled) {
|
||||
if(subghz->last_settings->gps_baudrate != 0) {
|
||||
subghz_gps_stop(subghz->gps);
|
||||
}
|
||||
subghz_gps_deinit(subghz->gps);
|
||||
|
||||
@@ -56,7 +56,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
bool ignore_filter_was_read = false;
|
||||
bool frequency_analyzer_feedback_level_was_read = false;
|
||||
bool frequency_analyzer_trigger_was_read = false;
|
||||
bool temp_gps_enabled = false;
|
||||
uint32_t temp_gps_baudrate = 0;
|
||||
|
||||
if(FSE_OK == storage_sd_status(storage) && SUBGHZ_LAST_SETTINGS_PATH &&
|
||||
flipper_format_file_open_existing(fff_data_file, SUBGHZ_LAST_SETTINGS_PATH)) {
|
||||
@@ -94,8 +94,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP,
|
||||
(bool*)&temp_external_module_power_amp,
|
||||
1);
|
||||
flipper_format_read_bool(
|
||||
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_GPS, (bool*)&temp_gps_enabled, 1);
|
||||
flipper_format_read_uint32(
|
||||
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_GPS, (uint32_t*)&temp_gps_baudrate, 1);
|
||||
flipper_format_read_bool(
|
||||
fff_data_file,
|
||||
SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE,
|
||||
@@ -125,7 +125,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
instance->external_module_enabled = false;
|
||||
instance->timestamp_file_names = false;
|
||||
instance->external_module_power_amp = false;
|
||||
instance->gps_enabled = false;
|
||||
instance->gps_baudrate = 0;
|
||||
instance->enable_hopping = false;
|
||||
instance->ignore_filter = 0x00;
|
||||
// See bin_raw_value in applications/main/subghz/scenes/subghz_scene_receiver_config.c
|
||||
@@ -181,7 +181,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
|
||||
// Set globally in furi hal
|
||||
furi_hal_subghz_set_ext_power_amp(instance->external_module_power_amp);
|
||||
|
||||
instance->gps_enabled = temp_gps_enabled;
|
||||
instance->gps_baudrate = temp_gps_baudrate;
|
||||
}
|
||||
|
||||
flipper_format_file_close(fff_data_file);
|
||||
@@ -261,8 +261,8 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
|
||||
1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
file, SUBGHZ_LAST_SETTING_FIELD_GPS, &instance->gps_enabled, 1)) {
|
||||
if(!flipper_format_insert_or_update_uint32(
|
||||
file, SUBGHZ_LAST_SETTING_FIELD_GPS, &instance->gps_baudrate, 1)) {
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_bool(
|
||||
@@ -313,7 +313,7 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) {
|
||||
FURI_LOG_I(
|
||||
TAG,
|
||||
"Frequency: %03ld.%02ld, FeedbackLevel: %ld, FATrigger: %.2f, External: %s, ExtPower: %s, TimestampNames: %s, ExtPowerAmp: %s,\n"
|
||||
"Hopping: %s,\nPreset: %ld, RSSI: %.2f, "
|
||||
"GPSBaudrate: %ld, Hopping: %s,\nPreset: %ld, RSSI: %.2f, "
|
||||
"Starline: %s, Cars: %s, Magellan: %s, BinRAW: %s",
|
||||
instance->frequency / 1000000 % 1000,
|
||||
instance->frequency / 10000 % 100,
|
||||
@@ -323,6 +323,7 @@ void subghz_last_settings_log(SubGhzLastSettings* instance) {
|
||||
bool_to_char(instance->external_module_power_5v_disable),
|
||||
bool_to_char(instance->timestamp_file_names),
|
||||
bool_to_char(instance->external_module_power_amp),
|
||||
instance->gps_baudrate,
|
||||
bool_to_char(instance->enable_hopping),
|
||||
instance->preset_index,
|
||||
(double)instance->rssi,
|
||||
|
||||
@@ -26,7 +26,7 @@ typedef struct {
|
||||
bool external_module_power_amp;
|
||||
// saved so as not to change the version
|
||||
bool timestamp_file_names;
|
||||
bool gps_enabled;
|
||||
uint32_t gps_baudrate;
|
||||
bool enable_hopping;
|
||||
uint32_t ignore_filter;
|
||||
uint32_t filter;
|
||||
|
||||
Reference in New Issue
Block a user