precision-converters-firmware
|
: A simple console menu manager handler More...
#include <stdbool.h>
#include <stdint.h>
#include <limits.h>
Go to the source code of this file.
Classes | |
struct | console_menu_state |
struct | console_menu_item |
struct | console_menu |
Macros | |
#define | MENU_ESCAPED INT_MAX |
#define | MENU_CONTINUE INT_MAX-1 |
#define | MENU_DONE INT_MAX-2 |
#define | ESCAPE_KEY_CODE (char)0x1B |
#define | EOL "\r\n" |
#define | VT100_MOVE_UP_1_LINE "\033[A" |
#define | VT100_MOVE_UP_N_LINES "\x1B[%dA" |
#define | VT100_CLEAR_CURRENT_LINE "\x1B[J" |
#define | VT100_CLEAR_CONSOLE "\x1B[2J" |
#define | VT100_MOVE_TO_HOME "\x1B[H" |
#define | VT100_COLORED_TEXT "\x1B[%dm" |
#define | ARRAY_SIZE(x) ((sizeof (x)) / (sizeof ((x)[0]))) |
Enumerations | |
enum | vt100_colors { VT_FG_DEFAULT = 0 , VT_FG_RED = 31 , VT_FG_GREEN = 32 , VT_FG_YELLOW = 33 , VT_FG_BLUE = 34 , VT_FG_MAGENTA = 35 , VT_FG_CYAN = 36 , VT_FG_WHITE = 37 } |
Functions | |
int32_t | adi_do_console_menu (const console_menu *menu) |
Display a consoleMenu and handle User interaction. More... | |
int32_t | adi_get_decimal_int (uint8_t input_len) |
Reads a decimal string from the user. More... | |
uint32_t | adi_get_hex_integer (uint8_t input_len) |
Reads a hexadecimal number from the user. More... | |
float | adi_get_decimal_float (uint8_t input_len) |
Reads a floating string from the user. More... | |
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. More... | |
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. More... | |
void | adi_clear_console (void) |
Clears the console terminal. More... | |
void | adi_clear_last_menu_error (void) |
Clears the error code from the last menu. More... | |
int32_t | adi_get_last_menu_error (void) |
Returns the error code from the last menu. More... | |
void | adi_press_any_key_to_continue (void) |
waits for any key to be pressed, and displays a prompt to the user More... | |
Variables | |
console_menu_state | adi_console_menu_state |
: A simple console menu manager handler
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.
#define ARRAY_SIZE | ( | x | ) | ((sizeof (x)) / (sizeof ((x)[0]))) |
#define EOL "\r\n" |
#define ESCAPE_KEY_CODE (char)0x1B |
#define MENU_CONTINUE INT_MAX-1 |
#define MENU_DONE INT_MAX-2 |
#define MENU_ESCAPED INT_MAX |
#define VT100_CLEAR_CONSOLE "\x1B[2J" |
#define VT100_CLEAR_CURRENT_LINE "\x1B[J" |
#define VT100_COLORED_TEXT "\x1B[%dm" |
#define VT100_MOVE_TO_HOME "\x1B[H" |
#define VT100_MOVE_UP_1_LINE "\033[A" |
#define VT100_MOVE_UP_N_LINES "\x1B[%dA" |
enum vt100_colors |
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.
void adi_clear_last_menu_error | ( | void | ) |
Clears the error code from the last menu.
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.
float adi_get_decimal_float | ( | uint8_t | input_len | ) |
Reads a floating string from the user.
input_len | max number of character to accept from the user |
Allows a user to type in number, echoing back to the user, up to input_len chars
int32_t adi_get_decimal_int | ( | uint8_t | input_len | ) |
Reads a decimal string from the user.
input_len | max number of character to accept from the user |
Allows a user to type in number, echoing back to the user, up to input_len chars
uint32_t adi_get_hex_integer | ( | uint8_t | input_len | ) |
Reads a hexadecimal number from the user.
input_len | max number of character to accept from the user |
Allows a user to type in a hexnumber, echoing back to the user, up to input_len chars
int32_t adi_get_last_menu_error | ( | void | ) |
Returns the error code from the last menu.
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.
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. |
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.
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. |
void adi_press_any_key_to_continue | ( | void | ) |
waits for any key to be pressed, and displays a prompt to the user
|
extern |