Displays user interactions with menus displayed on a console or a serial terminal.

Dependents:   EVAL-AD568x-AD569x EVAL-AD7124 EVAL-AD5592R EVAL-AD717x-AD411x ... more

Embed: (wiki syntax)

« Back to documentation index

adi_console_menu.c File Reference

adi_console_menu.c File Reference

: A simple console menu manager handler More...

Go to the source code of this file.

Functions

static void adi_display_console_menu (const console_menu *menu)
 displays the text of a console menu
int32_t adi_do_console_menu (const console_menu *menu)
 Display a consoleMenu and handle User interaction.
int32_t adi_get_decimal_int (uint8_t input_len)
 Reads a decimal string from the user.
uint32_t adi_get_hex_integer (uint8_t input_len)
 Reads a hexadecimal number from the user.
float adi_get_decimal_float (uint8_t input_len)
 Reads a floating string from the user.
int32_t adi_handle_user_input_integer (const char *menu_prompt, uint16_t min_val, uint16_t max_val, uint16_t *input_val, uint8_t input_len, uint8_t max_attempts, uint8_t clear_lines)
 Handles the integer type input from the user by displaying the menu message and provides a set number of input attempts for the user.
int32_t adi_handle_user_input_float (const char *menu_prompt, float min_val, float max_val, float *input_val, uint8_t input_len, uint8_t max_attempts, uint8_t clear_lines)
 Handles the float type input from the user by displaying the menu message and provides a set number of input attempts for the user.
void adi_clear_console (void)
 Clears the console terminal.
void adi_clear_last_menu_error (void)
 Clears the error code from the last menu.
int32_t adi_get_last_menu_error (void)
 Returns the error code from the last menu.
void adi_press_any_key_to_continue (void)
 waits for any key to be pressed, and displays a prompt to the user

Detailed Description

: A simple console menu manager handler

: A way to define using arrays of structs a set of menus that can be displayed to a user, easily, with all user interaction handled by the library, leaving only the implementation of the menu actions to be done by the library user. ----------------------------------------------------------------------------- Copyright (c) 2019-2022 Analog Devices, Inc. All rights reserved.

This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Definition in file adi_console_menu.c.


Function Documentation

void adi_clear_console ( void   )

Clears the console terminal.

Clears the console terminal using VT100 escape code, or can be changed to output blank lines if serial link doesn't support VT100.

Definition at line 438 of file adi_console_menu.c.

void adi_clear_last_menu_error ( void   )

Clears the error code from the last menu.

Definition at line 459 of file adi_console_menu.c.

static void adi_display_console_menu ( const console_menu *  menu ) [static]

displays the text of a console menu

Definition at line 54 of file adi_console_menu.c.

int32_t adi_do_console_menu ( const console_menu *  menu )

Display a consoleMenu and handle User interaction.

This displays the menuItems defined by the console menu, and handles all user interaction for the menu.

Note:
The function will return either the item selected or error code from the last action. One at a time. Either define the menu action or sub menu. If both are defined the function would return error. If both menu action and sub menu are defined NULL, then the function will return the item selected

Definition at line 111 of file adi_console_menu.c.

float adi_get_decimal_float ( uint8_t  input_len )

Reads a floating string from the user.

Parameters:
input_lenmax number of character to accept from the user
Returns:
The float value entered

Allows a user to type in number, echoing back to the user, up to input_len chars

Note:
Only positive floating point numbers are supported currently

Definition at line 284 of file adi_console_menu.c.

int32_t adi_get_decimal_int ( uint8_t  input_len )

Reads a decimal string from the user.

Parameters:
input_lenmax number of character to accept from the user
Returns:
The integer value entered

Allows a user to type in number, echoing back to the user, up to input_len chars

Note:
Only positive integer numbers are supported currently

Definition at line 200 of file adi_console_menu.c.

uint32_t adi_get_hex_integer ( uint8_t  input_len )

Reads a hexadecimal number from the user.

Parameters:
input_lenmax number of character to accept from the user
Returns:
The integer value entered

Allows a user to type in a hexnumber, echoing back to the user, up to input_len chars

Definition at line 241 of file adi_console_menu.c.

int32_t adi_get_last_menu_error ( void   )

Returns the error code from the last menu.

Returns:
The error code value

Definition at line 469 of file adi_console_menu.c.

int32_t adi_handle_user_input_float ( const char *  menu_prompt,
float  min_val,
float  max_val,
float *  input_val,
uint8_t  input_len,
uint8_t  max_attempts,
uint8_t  clear_lines 
)

Handles the float type input from the user by displaying the menu message and provides a set number of input attempts for the user.

Parameters:
menu_prompt[in]- User specified prompt.
min_val[in]- minimum input value.
max_val[in]- maximum input value.
input_val[in,out]- User provided input value.
input_len[in]- User provided input length.
max_attempts[in]- Maximum number of input attempts.
clear_lines[in]- lines to clear in case of invalid input.
Returns:
0 in case of success. -1 otherwise.

Definition at line 387 of file adi_console_menu.c.

int32_t adi_handle_user_input_integer ( const char *  menu_prompt,
uint16_t  min_val,
uint16_t  max_val,
uint16_t *  input_val,
uint8_t  input_len,
uint8_t  max_attempts,
uint8_t  clear_lines 
)

Handles the integer type input from the user by displaying the menu message and provides a set number of input attempts for the user.

Parameters:
menu_prompt[in]- User specified prompt.
min_val[in]- minimum input value.
max_val[in]- maximum input value.
input_val[in,out]- User provided input value.
input_len[in]- User provided input length.
max_attempts[in]- Maximum number of input attempts.
clear_lines[in]- lines to clear in case of invalid input.
Returns:
0 in case of success. -1 otherwise.

Definition at line 329 of file adi_console_menu.c.

void adi_press_any_key_to_continue ( void   )

waits for any key to be pressed, and displays a prompt to the user

Definition at line 479 of file adi_console_menu.c.