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

88 lines
2.7 KiB
C
Raw Normal View History

/* 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__
2020-06-01 21:42:31 +02:00
#include <stdint.h>
#include <reflow-controller/button.h>
#include <stdbool.h>
struct lcd_menu;
enum menu_entry_func_entry {MENU_ENTRY_FIRST_ENTER, MENU_ENTRY_CONTINUE, MENU_ENTRY_DROPBACK};
2020-06-04 21:20:59 +02:00
typedef void (*menu_func_t)(struct lcd_menu *menu, enum menu_entry_func_entry entry_type,
2020-06-01 21:42:31 +02:00
void *parent);
struct menu_inputs {
2020-06-04 21:20:59 +02:00
int16_t rotary_encoder_delta;
2020-06-01 21:42:31 +02:00
enum button_state push_button;
};
struct lcd_menu {
menu_func_t active_entry;
menu_func_t root_entry;
enum menu_entry_func_entry active_entry_type;
2020-06-04 21:20:59 +02:00
menu_func_t init_parent;
2020-06-01 21:42:31 +02:00
struct menu_inputs inputs;
2020-06-04 21:20:59 +02:00
void (*update_display)(uint8_t row, const char *data);
2020-06-01 21:42:31 +02:00
};
struct menu_list {
void (*update_display)(uint8_t row, const char *data);
const char * const * entry_names;
uint32_t entry_count;
2020-06-01 21:42:31 +02:00
uint32_t currently_selected;
const menu_func_t *submenu_list;
};
2020-06-04 21:53:00 +02:00
void menu_handle(struct lcd_menu *menu, int16_t rotary_encoder_delta, enum button_state push_button);
2020-06-01 21:42:31 +02:00
2020-06-04 21:20:59 +02:00
void menu_init(struct lcd_menu *menu, menu_func_t root_node, void (*display_update)(uint8_t row, const char *data));
2020-06-01 21:42:31 +02:00
void menu_ack_rotary_delta(struct lcd_menu *menu);
void menu_display_clear(struct lcd_menu *menu);
2020-06-01 21:42:31 +02:00
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);
2020-06-01 21:42:31 +02:00
void menu_lcd_output(struct lcd_menu *menu, uint8_t row_num, const char *text);
2020-06-01 21:42:31 +02:00
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);
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);
2020-06-01 21:42:31 +02:00
void menu_list_enter_selected_entry(struct menu_list *list, struct lcd_menu *menu);
#endif /* __MENU_H__ */