Skip to content

Commit 284498d

Browse files
author
David Lee
committed
Added limitations to first/last pager/station
1 parent 9d8cc15 commit 284498d

10 files changed

+59
-3
lines changed

application.fam

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ App(
77
fap_icon="icons/meal_pager_10px.png",
88
fap_icon_assets="icons",
99
fap_category="Sub-Ghz",
10-
fap_version="1.1",
10+
fap_version="1.2",
1111
fap_libs=["assets"],
1212
fap_author="leedave",
1313
fap_weburl="https://github.com/leedave/flipper-zero-meal-pager",

docs/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.2
2+
- Fixed Memory bug in Last Station UI
3+
- Added auto-correction when entries in First/Last station/pager are out of range
4+
15
## v1.1
26
- Created a new UI Input View as FW does not supply one for numbers
37
- New UI to Set First Station

helpers/meal_pager_storage.c

+24
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,28 @@ void meal_pager_set_max_values(void* context) {
221221
app->max_pager = 999;
222222
break;
223223
}
224+
if(app->first_station > app->max_station) {
225+
app->first_station = app->max_station;
226+
snprintf(app->text_store[0], 5, "%lu", app->first_station);
227+
}
228+
if(app->last_station > app->max_station) {
229+
app->last_station = app->max_station;
230+
snprintf(app->text_store[1], 5, "%lu", app->last_station);
231+
}
232+
if(app->last_station < app->first_station) {
233+
app->last_station = app->first_station;
234+
snprintf(app->text_store[1], 5, "%lu", app->last_station);
235+
}
236+
if(app->first_pager > app->max_pager) {
237+
app->first_pager = app->max_pager;
238+
snprintf(app->text_store[2], 4, "%lu", app->first_pager);
239+
}
240+
if(app->last_pager > app->max_pager) {
241+
app->last_pager = app->max_pager;
242+
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
243+
}
244+
if(app->last_pager < app->first_pager) {
245+
app->last_pager = app->first_pager;
246+
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
247+
}
224248
}

meal_pager_i.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ typedef struct {
6464
char* text_buffer;
6565
uint32_t max_station;
6666
uint32_t max_pager;
67-
char text_store[6][129];
67+
char text_store[6][36];
6868
} Meal_Pager;
6969

7070
typedef enum {

scenes/meal_pager_scene_menu.c

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "../meal_pager_i.h"
22
#include "../helpers/meal_pager_led.h"
3+
#include "../helpers/meal_pager_storage.h"
34
#include "../views/meal_pager_transmit.h"
45

56
enum SubmenuIndex {
@@ -22,6 +23,8 @@ void meal_pager_scene_menu_submenu_callback(void* context, uint32_t index) {
2223
void meal_pager_scene_menu_on_enter(void* context) {
2324
Meal_Pager* app = context;
2425

26+
meal_pager_set_max_values(app);
27+
2528
submenu_add_item(
2629
app->submenu,
2730
"Send Data",

scenes/meal_pager_scene_set_first_pager.c

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ bool meal_pager_scene_set_first_pager_on_event(void* context, SceneManagerEvent
4141
return true;
4242
} else if(event.type == SceneManagerEventTypeCustom) {
4343
app->first_pager = atoi(app->text_store[2]);
44+
if(app->first_pager > app->max_pager) {
45+
app->first_pager = app->max_pager;
46+
snprintf(app->text_store[2], 4, "%lu", app->first_pager);
47+
}
4448
app->first_pager_char = app->text_store[2];
4549
scene_manager_previous_scene(app->scene_manager);
4650
return true;

scenes/meal_pager_scene_set_first_station.c

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ bool meal_pager_scene_set_first_station_on_event(void* context, SceneManagerEven
4141
return true;
4242
} else if(event.type == SceneManagerEventTypeCustom) {
4343
app->first_station = atoi(app->text_store[0]);
44+
if(app->first_station > app->max_station) {
45+
app->first_station = app->max_station;
46+
snprintf(app->text_store[0], 5, "%lu", app->first_station);
47+
}
4448
app->first_station_char = app->text_store[0];
4549
scene_manager_previous_scene(app->scene_manager);
4650
return true;

scenes/meal_pager_scene_set_last_pager.c

+8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ bool meal_pager_scene_set_last_pager_on_event(void* context, SceneManagerEvent e
4141
return true;
4242
} else if(event.type == SceneManagerEventTypeCustom) {
4343
app->last_pager = atoi(app->text_store[3]);
44+
if(app->last_pager > app->max_pager) {
45+
app->last_pager = app->max_pager;
46+
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
47+
}
48+
if(app->last_pager < app->first_pager) {
49+
app->last_pager = app->first_pager;
50+
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
51+
}
4452
app->last_pager_char = app->text_store[3];
4553
scene_manager_previous_scene(app->scene_manager);
4654
return true;

scenes/meal_pager_scene_set_last_station.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void meal_pager_scene_set_last_station_on_enter(void* context) {
1717
meal_pager_set_max_values(app);
1818
char* str = "Set Last Station (0 - 9999)";
1919
const char* constStr = str;
20-
snprintf(str, 36, "Set Last Station (%lu - %lu)", app->last_station, app->max_station);
20+
snprintf(str, 36, "Set Last Station (%lu - %lu)", app->first_station, app->max_station);
2121

2222
int_input_set_header_text(int_input, constStr);
2323

@@ -41,6 +41,14 @@ bool meal_pager_scene_set_last_station_on_event(void* context, SceneManagerEvent
4141
return true;
4242
} else if(event.type == SceneManagerEventTypeCustom) {
4343
app->last_station = atoi(app->text_store[1]);
44+
if(app->last_station > app->max_station) {
45+
app->last_station = app->max_station;
46+
snprintf(app->text_store[1], 5, "%lu", app->last_station);
47+
}
48+
if(app->last_station < app->first_station) {
49+
app->last_station = app->first_station;
50+
snprintf(app->text_store[1], 5, "%lu", app->last_station);
51+
}
4452
app->last_station_char = app->text_store[1];
4553
scene_manager_previous_scene(app->scene_manager);
4654
return true;

scenes/meal_pager_scene_settings.c

+1
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,5 @@ void meal_pager_scene_settings_on_exit(void* context) {
233233
Meal_Pager* app = context;
234234
variable_item_list_set_selected_item(app->variable_item_list, 0);
235235
variable_item_list_reset(app->variable_item_list);
236+
meal_pager_set_max_values(app);
236237
}

0 commit comments

Comments
 (0)