Skip to content

Commit 67349d4

Browse files
committed
Add option for storing current frequency offset from lora info menu, apply manual frequency offset
1 parent 44bdf4e commit 67349d4

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

main/lora_settings_handler.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,9 @@ esp_err_t lora_apply_settings(void) {
3737
nvs_settings_get_lora_automatic_offset(&config.use_automatic_correction);
3838
nvs_settings_get_lora_low_data_rate_optimization(&config.low_data_rate_optimization);
3939

40-
esp_err_t res = lora_set_config(lora_get_handle(), &config);
41-
if (res != ESP_OK) {
42-
return res;
43-
}
44-
45-
return res;
46-
4740
int32_t offset = 0;
4841
nvs_settings_get_lora_offset(&offset);
49-
return lora_set_frequency_offset(lora_get_handle(), offset);
42+
lora_set_frequency_offset(lora_get_handle(), offset);
43+
44+
return lora_set_config(lora_get_handle(), &config);
5045
}

main/menu/lora_information.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "lora.h"
1212
#include "menu/menu_helpers.h"
1313
#include "menu/message_dialog.h"
14+
#include "nvs_settings_lora.h"
1415
#include "pax_gfx.h"
1516
#include "pax_matrix.h"
1617
#include "pax_text.h"
@@ -21,7 +22,10 @@ static const char TAG[] = "LoRa information menu";
2122
extern lora_handle_t* lora_get_handle(void);
2223

2324
#if defined(CONFIG_BSP_TARGET_TANMATSU) || defined(CONFIG_BSP_TARGET_KONSOOL)
24-
#define FOOTER_LEFT ((gui_element_icontext_t[]){{get_icon(ICON_ESC), "/"}, {get_icon(ICON_F1), "Back"}}), 2
25+
#define FOOTER_LEFT \
26+
((gui_element_icontext_t[]){ \
27+
{get_icon(ICON_ESC), "/"}, {get_icon(ICON_F1), "Back"}, {get_icon(ICON_F4), "Store offset"}}), \
28+
3
2529
#define FOOTER_RIGHT NULL, 0
2630
#define TEXT_FONT pax_font_sky_mono
2731
#define TEXT_SIZE 18
@@ -45,7 +49,7 @@ static void render(bool partial, bool icons, size_t num_packets, lora_protocol_l
4549
pax_vec2_t position = menu_calc_position(buffer, theme);
4650

4751
render_base_screen_statusbar(buffer, theme, true, true, true,
48-
((gui_element_icontext_t[]){{get_icon(ICON_INFO), "LoRa information"}}), 1,
52+
((gui_element_icontext_t[]){{get_icon(ICON_WORKSPACES), "LoRa information"}}), 1,
4953
FOOTER_LEFT, FOOTER_RIGHT);
5054

5155
char text_buffer[256];
@@ -209,6 +213,13 @@ void test_tx(void) {
209213
}
210214
}
211215

216+
static void store_offset(void) {
217+
float applied_frequency_offset = 0;
218+
lora_get_frequency_offset(lora_get_handle(), NULL, NULL, &applied_frequency_offset);
219+
nvs_settings_set_lora_offset(applied_frequency_offset);
220+
message_dialog(get_icon(ICON_WORKSPACES), "LoRa information", "Frequency offset stored", "OK");
221+
}
222+
212223
void menu_lora_information(void) {
213224
QueueHandle_t input_event_queue = NULL;
214225
ESP_ERROR_CHECK(bsp_input_get_queue(&input_event_queue));
@@ -257,6 +268,9 @@ void menu_lora_information(void) {
257268
case BSP_INPUT_NAVIGATION_KEY_F1:
258269
case BSP_INPUT_NAVIGATION_KEY_GAMEPAD_B:
259270
return;
271+
case BSP_INPUT_NAVIGATION_KEY_F4:
272+
store_offset();
273+
break;
260274
case BSP_INPUT_NAVIGATION_KEY_F6:
261275
test_tx();
262276
break;

0 commit comments

Comments
 (0)