GPS Device
Loading...
Searching...
No Matches
Menu Command Handlers

Functions

static ERR_te menu_cmd_info_handler (uint32_t argc, char **argv)
 CLI handler for the "info" command. Logs the names of all active menu handles.
static ERR_te menu_cmd_scroll_handler (uint32_t argc, char **argv)
 CLI handler for the "scroll" command. Scrolls a named menu and re-renders it.

Detailed Description

Function Documentation

◆ menu_cmd_info_handler()

ERR_te menu_cmd_info_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "info" command. Logs the names of all active menu handles.

Expected invocation: menu info

Parameters
[in]argcArgument count. Must be exactly 2.
[in]argvArgument list: argv[0] = "menu", argv[1] = "info".
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 2

Definition at line 665 of file menu.c.

665 {
666 if(argc != 2) {
667 LOG_ERROR(
668 internal_state.subsys,
669 internal_state.log_level,
670 "menu_cmd_info_handler: invalid arguments"
671 );
672
674 }
675
676 LOG_INFO(internal_state.subsys, internal_state.log_level, "Printing menu information:");
677
678 for(uint32_t i = 0; i < CONFIG_MENU_MAX_OBJECTS; i++) {
679 if(internal_state.menus[i].in_use == true) {
680 LOG_INFO(
681 internal_state.subsys,
682 internal_state.log_level,
683 "name: %s",
684 internal_state.menus[i].name
685 );
686 }
687 }
688
689 return ERR_OK;
690}
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
@ ERR_OK
Definition err.h:36
@ ERR_INVALID_ARGUMENT
Definition err.h:38
#define LOG_ERROR(subsys, lvl, fmt,...)
Definition log.h:258
#define LOG_INFO(subsys, lvl, fmt,...)
Definition log.h:255

◆ menu_cmd_scroll_handler()

ERR_te menu_cmd_scroll_handler ( uint32_t argc,
char ** argv )
static

CLI handler for the "scroll" command. Scrolls a named menu and re-renders it.

Expected invocation: menu scroll <n> <up|down>

Searches the registered menu pool for a handle whose name matches argv[2], calls menu_scroll in the specified direction, then calls menu_run_handle to update the display.

Parameters
[in]argcArgument count. Must be exactly 4.
[in]argvArgument list: argv[0] = "menu", argv[1] = "scroll", argv[2] = menu name, argv[3] = "up" or "down".
Returns
  • ERR_OK on success
  • ERR_INVALID_ARGUMENT if argc != 4, the name is not found, or the direction string is not recognized

Definition at line 711 of file menu.c.

711 {
712 if(argc != 4) {
713 LOG_ERROR(
714 internal_state.subsys,
715 internal_state.log_level,
716 "menu_cmd_scroll_handler: invalid arguments"
717 );
718
720 }
721
722 for(uint32_t i = 0; i < CONFIG_MENU_MAX_OBJECTS; i++) {
723 if(str_cmp(argv[2], internal_state.menus[i].name) == true) {
724 if(str_cmp(argv[3], "up") == true) {
725 menu_scroll(&internal_state.menus[i], UP);
726 }
727 else if(str_cmp(argv[3], "down") == true) {
728 menu_scroll(&internal_state.menus[i], DOWN);
729 }
730 else {
731 LOG_ERROR(
732 internal_state.subsys,
733 internal_state.log_level,
734 "menu_cmd_scroll_handler: invalid arguments"
735 );
737 }
739
740 return ERR_OK;
741 }
742 if(i == internal_state.menu_num - 1) {
743 LOG_ERROR(
744 internal_state.subsys,
745 internal_state.log_level,
746 "menu_cmd_scroll_handler: invalid arguments"
747 );
748
750 }
751 }
752
753 return ERR_OK;
754}
bool str_cmp(const char *str1, const char *str2)
Compares two null-terminated strings for equality.
Definition common.c:248
@ DOWN
Definition common.h:108
@ UP
Definition common.h:111
ERR_te menu_run_handle(MENU_HANDLE_ts *menu_handle)
Renders a single menu to the display.
Definition menu.c:340
ERR_te menu_scroll(MENU_HANDLE_ts *menu_handle, VERTICAL_DIR_te vertical_dir)
Moves the menu selection cursor by one step in the given direction.
Definition menu.c:387
Here is the call graph for this function: