From 51a7257cbabfa608a2f685e634ac9b37a17c4086 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Thu, 27 May 2021 19:41:20 -0400 Subject: Use NUM_CHOICES to avoid having magic number --- apps/settings/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apps/settings/main.cpp') diff --git a/apps/settings/main.cpp b/apps/settings/main.cpp index 5e8857b..f10a65b 100644 --- a/apps/settings/main.cpp +++ b/apps/settings/main.cpp @@ -43,7 +43,8 @@ namespace app_settings { // Time and date settings void set0_menu(Api *app_api) { - static const char *choices[9] = {"Hour", "Minute", "Second", "Year", "Month", "Day", "Day of week", STR_SET_APPLY, STR_SET_CANCEL}; + #define NUM_CHOICES 9 + static const char *choices[NUM_CHOICES] = {"Hour", "Minute", "Second", "Year", "Month", "Day", "Day of week", STR_SET_APPLY, STR_SET_CANCEL}; uint max_value; uint min_value; uint default_value; @@ -52,7 +53,7 @@ namespace app_settings { int choice = 0; while (true) { - choice = app_api->gui_popup_strchoice(SET0_NAME, SET0_DESC, choices, 9, 0, -1, choice); + choice = app_api->gui_popup_strchoice(SET0_NAME, SET0_DESC, choices, NUM_CHOICES, 0, -1, choice); min_value = 0; switch (choice) { @@ -112,6 +113,7 @@ namespace app_settings { case 5: datetime.day = new_value; break; } } + #undef NUM_CHOICES } // Display settings -- cgit v1.2.3-54-g00ecf