17#include "configuration.h"
75 char name[CONFIG_MENU_MAX_NAME_LEN];
129 .help =
"Scroll up or down, usage: menu scroll <menu> <up|down>",
134 .help =
"Shows menu information, usage: menu info",
180 "menu_init_subsys: cmd_register error"
188 "menu_init_subsys: subsys initialized"
205 "menu_deinit_subsys: subsys is not initialized or not stopped"
213 "menu_deinit_subsys: subsys deinitialized"
227 "menu_start_subsys: subsys started"
234 "menu_start_subsys: subsys not initialized or already started"
251 "menu_stop_subsys: subsys stopped"
258 "menu_stop_subsys: subsys not initialized or already already stopped"
273 uint8_t options_count = 0;
274 while(menu_cfg->
options[options_count][0] !=
'\0')
277 if(options_count == 0)
279 else if(options_count > CONFIG_MENU_MAX_OPTIONS)
282 for(uint32_t i = 0; i < CONFIG_MENU_MAX_OBJECTS; i++) {
299 for(uint8_t j = 0; j < options_count; j++) {
312 if(options_count > 7) {
357 for(uint32_t i = 0; i < CONFIG_MENU_MAX_OBJECTS; i++) {
388 switch(vertical_dir) {
510 uint8_t line_counter = 0;
511 for(uint8_t i = menu_handle->
first_visible_option; i <= menu_handle->last_visible_option; i++) {
607 uint8_t line_counter = 0;
608 uint8_t real_counter = 0;
613 for(uint8_t i = menu_handle->
first_visible_option; i <= menu_handle->last_visible_option; i++) {
631 line_counter,
false);
670 "menu_cmd_info_handler: invalid arguments"
678 for(uint32_t i = 0; i < CONFIG_MENU_MAX_OBJECTS; i++) {
716 "menu_cmd_scroll_handler: invalid arguments"
722 for(uint32_t i = 0; i < CONFIG_MENU_MAX_OBJECTS; i++) {
724 if(
str_cmp(argv[3],
"up") ==
true) {
727 else if(
str_cmp(argv[3],
"down") ==
true) {
734 "menu_cmd_scroll_handler: invalid arguments"
746 "menu_cmd_scroll_handler: invalid arguments"
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
Command subsystem public API.
Common utility module public API.
System-wide error code definitions.
ERR_te cmd_deregister(CMD_CLIENT_INFO_ts const *cmd_client_info)
Deregisters a client from the command subsystem.
ERR_te cmd_register(CMD_CLIENT_INFO_ts *cmd_client_info)
Registers a client with the command subsystem.
bool str_cmp(const char *str1, const char *str2)
Compares two null-terminated strings for equality.
int str_cpy(char *str_to, const char *str_from, uint32_t len)
Copies a null-terminated string into a destination buffer.
uint32_t get_str_len(char const *str)
Returns the length of a string, excluding the null terminator.
int txt_cpy(char *txt_to, const char *txt_from, uint32_t len)
Copies a fixed-length block of text into a destination buffer.
VERTICAL_DIR_te
Represents a vertical movement direction.
ERR_te
Standard return type used by all public API functions.
@ ERR_DEINITIALIZATION_FAILURE
@ ERR_MODULE_ALREADY_INITIALIZED
@ ERR_DATA_ACQUISITION_FAILURE
ERR_te init_log(void)
Initializes the logging subsystem.
#define LOG_ERROR(subsys, lvl, fmt,...)
#define LOG_INFO(subsys, lvl, fmt,...)
LOG_LEVEL_te
Log severity levels, in ascending order of severity.
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.
MODULES_te
Identifies a subsystem for use in logging and CLI output.
ERR_te ssd1309_update(bool force)
Flushes the internal framebuffer to the display over I2C.
ERR_te ssd1309_invert_line(uint8_t line, bool force)
Inverts all pixels in a single display line in the framebuffer.
ERR_te ssd1309_clear_rect(uint8_t x_src, uint8_t y_src, uint8_t x_dest, uint8_t y_dest, bool force)
Clears a rectangular region in the framebuffer (sets all pixels off).
ERR_te ssd1309_draw_text(char const *text, uint8_t text_len, uint8_t line, bool force)
Draws a text string into the framebuffer at the specified line.
#define SSD1309_MAX_CHARS_IN_LINE
Common initialization public API.
Log subsystem public API.
SSD1309 OLED display driver public API.
Describes a subsystem client registering with the command module.
Describes a single command exposed by a client.
Internal state of the SysTick driver.
struct menu_handle_s menus[CONFIG_MENU_MAX_OBJECTS]
Internal structure representing a single menu instance.
int8_t last_visible_option
int8_t first_visible_option
char title[SSD1309_MAX_CHARS_IN_LINE]
char name[CONFIG_MENU_MAX_NAME_LEN]
int8_t prev_selected_option
ERR_te(* get_value_fn)(uint8_t index, char **value_o)
MENU_HANDLE_ts * prev_menu[CONFIG_MENU_MAX_BUF_SIZE]
char options[CONFIG_MENU_MAX_OPTIONS][SSD1309_MAX_CHARS_IN_LINE]
uint8_t line_to_highlight