95 lines
2.6 KiB
C
95 lines
2.6 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/>.
|
|
*/
|
|
|
|
#include <reflow-controller/ui/menu.h>
|
|
#include <stddef.h>
|
|
|
|
void menu_handle(struct lcd_menu *menu, uint16_t rotary_encoder_delta, enum button_state push_button)
|
|
{
|
|
menu_func_t tmp;
|
|
|
|
if (!menu)
|
|
return;
|
|
|
|
menu->inputs.push_button = push_button;
|
|
menu->inputs.rotary_encoder_delta = rotary_encoder_delta;
|
|
|
|
if (menu->active_entry == NULL)
|
|
menu->active_entry = menu->root_entry;
|
|
|
|
tmp = menu->active_entry;
|
|
|
|
|
|
if (menu->active_entry_type == MENU_ENTRY_FIRST_ENTER) {
|
|
menu->active_entry(menu, menu->active_entry_type, menu->init_parent);
|
|
} else {
|
|
menu->active_entry(menu, menu->active_entry_type, NULL);
|
|
}
|
|
|
|
if (menu->active_entry_type != MENU_ENTRY_CONTINUE && tmp == menu->active_entry) {
|
|
menu->active_entry_type = MENU_ENTRY_CONTINUE;
|
|
}
|
|
}
|
|
|
|
void menu_init(struct lcd_menu *menu, menu_func_t root_node, void (*display_update)(uint8_t row, const char *data))
|
|
{
|
|
if (!menu)
|
|
return;
|
|
|
|
menu->root_entry = root_node;
|
|
menu->active_entry = root_node;
|
|
menu->init_parent = NULL;
|
|
menu->inputs.push_button = BUTTON_IDLE;
|
|
menu->inputs.rotary_encoder_delta = 0;
|
|
menu->active_entry_type = MENU_ENTRY_FIRST_ENTER;
|
|
menu->update_display = display_update;
|
|
}
|
|
|
|
void menu_entry_dropback(struct lcd_menu *menu, menu_func_t parent_func)
|
|
{
|
|
if (!menu)
|
|
return;
|
|
if (parent_func)
|
|
menu->active_entry = parent_func;
|
|
else
|
|
menu->active_entry = menu->root_entry;
|
|
|
|
menu->active_entry_type = MENU_ENTRY_DROPBACK;
|
|
}
|
|
|
|
void menu_entry_enter(struct lcd_menu *menu, menu_func_t parent_func, bool handle_immediately)
|
|
{
|
|
menu->init_parent = menu->active_entry;
|
|
menu->active_entry_type = MENU_ENTRY_FIRST_ENTER;
|
|
}
|
|
|
|
void menu_override_lcd_output(struct lcd_menu *menu, uint8_t row_num, const char *text)
|
|
{
|
|
if (!menu || !menu->update_display)
|
|
return;
|
|
|
|
menu->update_display(row_num, text);
|
|
}
|
|
|
|
void menu_list_display(struct menu_list *list, uint8_t top_row, uint8_t bottom_row)
|
|
{
|
|
|
|
}
|