Skip to content

Commit

Permalink
Merge pull request #22 from leedave/feature/stationSet
Browse files Browse the repository at this point in the history
Added limitations to first/last pager/station
  • Loading branch information
leedave authored Jan 8, 2024
2 parents 42049b3 + 284498d commit 663a985
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 3 deletions.
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ App(
fap_icon="icons/meal_pager_10px.png",
fap_icon_assets="icons",
fap_category="Sub-Ghz",
fap_version="1.1",
fap_version="1.2",
fap_libs=["assets"],
fap_author="leedave",
fap_weburl="https://github.com/leedave/flipper-zero-meal-pager",
Expand Down
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2
- Fixed Memory bug in Last Station UI
- Added auto-correction when entries in First/Last station/pager are out of range

## v1.1
- Created a new UI Input View as FW does not supply one for numbers
- New UI to Set First Station
Expand Down
24 changes: 24 additions & 0 deletions helpers/meal_pager_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,28 @@ void meal_pager_set_max_values(void* context) {
app->max_pager = 999;
break;
}
if(app->first_station > app->max_station) {
app->first_station = app->max_station;
snprintf(app->text_store[0], 5, "%lu", app->first_station);
}
if(app->last_station > app->max_station) {
app->last_station = app->max_station;
snprintf(app->text_store[1], 5, "%lu", app->last_station);
}
if(app->last_station < app->first_station) {
app->last_station = app->first_station;
snprintf(app->text_store[1], 5, "%lu", app->last_station);
}
if(app->first_pager > app->max_pager) {
app->first_pager = app->max_pager;
snprintf(app->text_store[2], 4, "%lu", app->first_pager);
}
if(app->last_pager > app->max_pager) {
app->last_pager = app->max_pager;
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
}
if(app->last_pager < app->first_pager) {
app->last_pager = app->first_pager;
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
}
}
2 changes: 1 addition & 1 deletion meal_pager_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef struct {
char* text_buffer;
uint32_t max_station;
uint32_t max_pager;
char text_store[6][129];
char text_store[6][36];
} Meal_Pager;

typedef enum {
Expand Down
3 changes: 3 additions & 0 deletions scenes/meal_pager_scene_menu.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "../meal_pager_i.h"
#include "../helpers/meal_pager_led.h"
#include "../helpers/meal_pager_storage.h"
#include "../views/meal_pager_transmit.h"

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

meal_pager_set_max_values(app);

submenu_add_item(
app->submenu,
"Send Data",
Expand Down
4 changes: 4 additions & 0 deletions scenes/meal_pager_scene_set_first_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ bool meal_pager_scene_set_first_pager_on_event(void* context, SceneManagerEvent
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
app->first_pager = atoi(app->text_store[2]);
if(app->first_pager > app->max_pager) {
app->first_pager = app->max_pager;
snprintf(app->text_store[2], 4, "%lu", app->first_pager);
}
app->first_pager_char = app->text_store[2];
scene_manager_previous_scene(app->scene_manager);
return true;
Expand Down
4 changes: 4 additions & 0 deletions scenes/meal_pager_scene_set_first_station.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ bool meal_pager_scene_set_first_station_on_event(void* context, SceneManagerEven
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
app->first_station = atoi(app->text_store[0]);
if(app->first_station > app->max_station) {
app->first_station = app->max_station;
snprintf(app->text_store[0], 5, "%lu", app->first_station);
}
app->first_station_char = app->text_store[0];
scene_manager_previous_scene(app->scene_manager);
return true;
Expand Down
8 changes: 8 additions & 0 deletions scenes/meal_pager_scene_set_last_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ bool meal_pager_scene_set_last_pager_on_event(void* context, SceneManagerEvent e
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
app->last_pager = atoi(app->text_store[3]);
if(app->last_pager > app->max_pager) {
app->last_pager = app->max_pager;
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
}
if(app->last_pager < app->first_pager) {
app->last_pager = app->first_pager;
snprintf(app->text_store[3], 4, "%lu", app->last_pager);
}
app->last_pager_char = app->text_store[3];
scene_manager_previous_scene(app->scene_manager);
return true;
Expand Down
10 changes: 9 additions & 1 deletion scenes/meal_pager_scene_set_last_station.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void meal_pager_scene_set_last_station_on_enter(void* context) {
meal_pager_set_max_values(app);
char* str = "Set Last Station (0 - 9999)";
const char* constStr = str;
snprintf(str, 36, "Set Last Station (%lu - %lu)", app->last_station, app->max_station);
snprintf(str, 36, "Set Last Station (%lu - %lu)", app->first_station, app->max_station);

int_input_set_header_text(int_input, constStr);

Expand All @@ -41,6 +41,14 @@ bool meal_pager_scene_set_last_station_on_event(void* context, SceneManagerEvent
return true;
} else if(event.type == SceneManagerEventTypeCustom) {
app->last_station = atoi(app->text_store[1]);
if(app->last_station > app->max_station) {
app->last_station = app->max_station;
snprintf(app->text_store[1], 5, "%lu", app->last_station);
}
if(app->last_station < app->first_station) {
app->last_station = app->first_station;
snprintf(app->text_store[1], 5, "%lu", app->last_station);
}
app->last_station_char = app->text_store[1];
scene_manager_previous_scene(app->scene_manager);
return true;
Expand Down
1 change: 1 addition & 0 deletions scenes/meal_pager_scene_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,5 @@ void meal_pager_scene_settings_on_exit(void* context) {
Meal_Pager* app = context;
variable_item_list_set_selected_item(app->variable_item_list, 0);
variable_item_list_reset(app->variable_item_list);
meal_pager_set_max_values(app);
}

0 comments on commit 663a985

Please sign in to comment.