Skip to content

Commit

Permalink
Issue #80 network status sec
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoparrilla authored Feb 9, 2024
2 parents 32115b8 + 8b44a1e commit 832a3a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configurator/src/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "screen.h"
#include "commands.h"

#define MAX_ENTRIES 21
#define MAX_ENTRIES 22
#define MAX_KEY_LENGTH 20
#define MAX_STRING_VALUE_LENGTH 64

Expand Down
3 changes: 2 additions & 1 deletion configurator/src/include/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static __uint32_t random_number = 0x0;
#define NETWORKLOAD_WAIT_TIME 40
#define ROMS_JSON_WAIT_TIME 5
#define ROMSLOAD_WAIT_TIME 40
#define FLOPPYDB_WAIT_TIME 5
#define FLOPPYDB_WAIT_TIME 10
#define FLOPPYLOAD_WAIT_TIME 40
#define FLOPPYLIST_WAIT_TIME 10
#define CONFIG_WAIT_TIME 10
Expand All @@ -103,6 +103,7 @@ static __uint32_t random_number = 0x0;
#define KEY_ESC 0x1001B

#define PARAM_DOWNLOAD_TIMEOUT_SEC "DOWNLOAD_TIMEOUT_SEC"
#define PARAM_MENU_REFRESH_SEC "MENU_REFRESH_SEC"

#define PRINT_APP_HEADER(version) \
do \
Expand Down
19 changes: 14 additions & 5 deletions configurator/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
#define MENU_ALIGN_Y 4
#define PROMT_ALIGN_X 7
#define PROMT_ALIGN_Y 20
#define MENU_CALLBACK_INTERVAL 6 // Every 6 seconds poll for the connection status
#define ALLOWED_KEYS "123456DWCRE" // Only these keys are allowed
#define MENU_CALLBACK_INTERVAL 6 // Default poll for the connection status in seconds
#define MENU_CALLBACK_INTERVAL_MIN 2 // Minimum value for the menu callback interval in seconds
#define ALLOWED_KEYS "123456DWCRE" // Only these keys are allowed

typedef struct
{
Expand Down Expand Up @@ -81,7 +82,7 @@ static void blink_if_new_version_available(__uint16_t blink_toogle)
}
}

static __int8_t get_number_active_wait(CallbackFunction networkCallback, CallbackFunction storageCallback)
static __int8_t get_number_active_wait(CallbackFunction networkCallback, CallbackFunction storageCallback, __uint8_t refresh_interval_sec)
{
__uint16_t callback_interval = 0;
__uint16_t first_time = TRUE;
Expand Down Expand Up @@ -117,7 +118,7 @@ static __int8_t get_number_active_wait(CallbackFunction networkCallback, Callbac
{
networkCallback(TRUE);
}
callback_interval = MENU_CALLBACK_INTERVAL * 50;
callback_interval = refresh_interval_sec * 50;
if (first_time)
{
first_time = FALSE;
Expand Down Expand Up @@ -158,12 +159,20 @@ static __int8_t get_number_active_wait(CallbackFunction networkCallback, Callbac

static __int8_t menu()
{
ConfigEntry *menu_refresh_sec = get_config_entry(PARAM_MENU_REFRESH_SEC);
__uint8_t menu_callback_interval = menu_refresh_sec != NULL ? atoi(menu_refresh_sec->value) : MENU_CALLBACK_INTERVAL;
// If the value is less than the minimum, set the minimum value
if (menu_callback_interval < MENU_CALLBACK_INTERVAL_MIN)
{
menu_callback_interval = MENU_CALLBACK_INTERVAL_MIN;
}

PRINT_APP_HEADER(VERSION);

locate(PROMT_ALIGN_X, PROMT_ALIGN_Y);
char *prompt;
asprintf(&prompt, "Choose the feature (1 to %d), or press 0 to exit: ", LAST_OPTION);
__int8_t feature = get_number_active_wait((CallbackFunction)get_connection_status, (CallbackFunction)get_storage_status);
__int8_t feature = get_number_active_wait((CallbackFunction)get_connection_status, (CallbackFunction)get_storage_status, menu_callback_interval);

if (feature <= 0)
feature = -1;
Expand Down

0 comments on commit 832a3a4

Please sign in to comment.