Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
adi_console_menu.h
00001 /*! 00002 ***************************************************************************** 00003 @file: adi_console_menu.h 00004 00005 @brief: A simple console menu manager handler 00006 00007 @details: 00008 ----------------------------------------------------------------------------- 00009 Copyright (c) 2019, 2020 Analog Devices, Inc. 00010 All rights reserved. 00011 00012 This software is proprietary to Analog Devices, Inc. and its licensors. 00013 By using this software you agree to the terms of the associated 00014 Analog Devices Software License Agreement. 00015 00016 *****************************************************************************/ 00017 00018 #ifndef ADI_CONSOLE_MENU_H_ 00019 #define ADI_CONSOLE_MENU_H_ 00020 00021 #include <stdbool.h> 00022 #include <stdint.h> 00023 00024 #define MENU_ESCAPED -1 00025 #define MENU_CONTINUE 0 00026 #define MENU_DONE 1 00027 00028 #define ESCAPE_KEY_CODE (char)0x1B 00029 00030 #define EOL "\r\n" 00031 00032 #ifndef ARRAY_SIZE 00033 #define ARRAY_SIZE(x) ((sizeof (x)) / (sizeof ((x)[0]))) 00034 #endif 00035 00036 /* Type Definitions */ 00037 // Each menu item is defined by this struct 00038 typedef struct { 00039 // String displayed for menu item 00040 char * text; 00041 // character that can be pressed to select menu item 00042 char shortcutKey; 00043 // Function to be called when menu item is selected, if NULL, no function is called 00044 int32_t (*action)(uint32_t option); 00045 // id value passed as the option value when calling menuAction 00046 uint32_t id; 00047 } console_menu_item; 00048 00049 // This defines a complete menu with items 00050 typedef struct { 00051 // String to be displayed as the menu title 00052 char * title; 00053 // Array of all the menu items 00054 console_menu_item * items; 00055 // Number of menuItems 00056 uint8_t itemCount; 00057 // Function alled before Menu title is displayed if defined 00058 void (*headerItem)(void); 00059 // Function called after menu items are displayed if defined 00060 void (*footerItem)(void); 00061 // Should the escape key to exit the menu be enabled? 00062 bool enableEscapeKey; 00063 } console_menu; 00064 00065 /* Function Declarations */ 00066 /* Display a console menu, and handle user interactions */ 00067 int32_t adi_do_console_menu(const console_menu * menu); 00068 int32_t adi_get_decimal_int(uint8_t input_len); 00069 uint32_t adi_get_hex_integer(uint8_t input_len); 00070 float adi_get_decimal_float(uint8_t input_len); 00071 void adi_clear_console(void); 00072 void adi_press_any_key_to_continue(void); 00073 00074 #endif /* ADI_CONSOLE_MENU_H_ */
Generated on Wed Jul 20 2022 16:03:27 by
1.7.2