reflow-oven-control-sw/stm-firmware/include/reflow-controller/ui/menu.h

93 lines
2.9 KiB
C

/* Reflow Oven Controller
*
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of the Reflow Oven Controller Project.
*
* The reflow oven controller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the reflow oven controller project.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MENU_H__
#define __MENU_H__
#include <stdint.h>
#include <reflow-controller/ui/button.h>
#include <stdbool.h>
struct lcd_menu;
enum menu_entry_func_entry {MENU_ENTRY_FIRST_ENTER, MENU_ENTRY_CONTINUE, MENU_ENTRY_DROPBACK};
typedef void (*menu_func_t)(struct lcd_menu *menu, enum menu_entry_func_entry entry_type,
void *parent);
struct menu_inputs {
int16_t rotary_encoder_delta;
enum button_state push_button;
bool button_ready;
};
struct lcd_menu {
menu_func_t active_entry;
menu_func_t root_entry;
enum menu_entry_func_entry active_entry_type;
menu_func_t init_parent;
struct menu_inputs inputs;
void (*update_display)(uint8_t row, const char *data);
};
struct menu_list {
void (*update_display)(uint8_t row, const char *data);
const char * const * entry_names;
uint32_t entry_count;
uint32_t currently_selected;
const menu_func_t *submenu_list;
};
void menu_handle(struct lcd_menu *menu, int16_t rotary_encoder_delta, enum button_state push_button);
void menu_init(struct lcd_menu *menu, menu_func_t root_node, void (*display_update)(uint8_t row, const char *data));
void menu_ack_rotary_delta(struct lcd_menu *menu);
void menu_display_clear(struct lcd_menu *menu);
void menu_entry_dropback(struct lcd_menu *menu, menu_func_t parent_func);
void menu_entry_enter(struct lcd_menu *menu, menu_func_t entry, bool handle_immediately);
void menu_lcd_output(struct lcd_menu *menu, uint8_t row_num, const char *text);
void menu_lcd_outputf(struct lcd_menu *menu, uint8_t row_num, const char *format, ...);
void menu_list_display(struct menu_list *list, uint32_t top_row, uint32_t bottom_row);
int16_t menu_get_rotary_delta(const struct lcd_menu *menu);
enum button_state menu_get_button_state(const struct lcd_menu *menu);
bool menu_get_button_ready_state(const struct lcd_menu *menu);
void menu_list_compute_count(struct menu_list *list);
void menu_list_scroll_down(struct menu_list *list);
void menu_list_scroll_up(struct menu_list *list);
void menu_list_enter_selected_entry(struct menu_list *list, struct lcd_menu *menu);
uint32_t menu_list_get_currently_selected(struct menu_list *list);
#endif /* __MENU_H__ */