2018-07-16 00:13:52 +00:00
|
|
|
//menu.h
|
|
|
|
#ifndef _MENU_H
|
|
|
|
#define _MENU_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
2019-06-20 14:40:53 +00:00
|
|
|
#include "eeprom.h"
|
2018-07-16 00:13:52 +00:00
|
|
|
|
2018-08-19 11:59:33 +00:00
|
|
|
#define MENU_DATA_SIZE 32
|
2018-07-16 00:13:52 +00:00
|
|
|
|
|
|
|
//Function pointer to menu functions.
|
|
|
|
typedef void (*menu_func_t)(void);
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
menu_func_t menu;
|
2018-08-22 14:09:19 +00:00
|
|
|
int8_t position;
|
2018-07-16 00:13:52 +00:00
|
|
|
} menu_record_t;
|
|
|
|
|
2018-08-22 16:55:42 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
//Variables used when editing values.
|
|
|
|
const char* editLabel;
|
|
|
|
void* editValue;
|
|
|
|
int32_t minEditValue;
|
|
|
|
int32_t maxEditValue;
|
|
|
|
} menu_data_edit_t;
|
2018-07-16 00:13:52 +00:00
|
|
|
|
|
|
|
extern uint8_t menu_data[MENU_DATA_SIZE];
|
|
|
|
|
|
|
|
extern uint8_t menu_depth;
|
|
|
|
|
2019-05-24 06:46:44 +00:00
|
|
|
//! definition of serious errors possibly blocking the main menu
|
|
|
|
//! Use them as bit mask, so that the code may set various errors at the same time
|
|
|
|
enum ESeriousErrors {
|
|
|
|
SERIOUS_ERR_NONE = 0,
|
|
|
|
SERIOUS_ERR_MINTEMP_HEATER = 0x01,
|
|
|
|
SERIOUS_ERR_MINTEMP_BED = 0x02
|
|
|
|
}; // and possibly others in the future.
|
|
|
|
|
|
|
|
//! this is a flag for disabling entering the main menu. If this is set
|
|
|
|
//! to anything != 0, the only the main status screen will be shown on the
|
|
|
|
//! LCD and the user will be prevented from entering the menu.
|
|
|
|
//! Now used only to block doing anything with the printer when there is
|
|
|
|
//! the infamous MINTEMP error (SERIOUS_ERR_MINTEMP).
|
|
|
|
extern uint8_t menu_block_entering_on_serious_errors;
|
|
|
|
|
|
|
|
//! a pair of macros for manipulating the serious errors
|
|
|
|
//! a c++ class would have been better
|
|
|
|
#define menu_set_serious_error(x) menu_block_entering_on_serious_errors |= x;
|
|
|
|
#define menu_unset_serious_error(x) menu_block_entering_on_serious_errors &= ~x;
|
|
|
|
#define menu_is_serious_error(x) (menu_block_entering_on_serious_errors & x) != 0
|
|
|
|
|
2018-07-16 00:13:52 +00:00
|
|
|
extern uint8_t menu_line;
|
|
|
|
extern uint8_t menu_item;
|
|
|
|
extern uint8_t menu_row;
|
2018-08-19 11:59:33 +00:00
|
|
|
|
2018-07-16 00:13:52 +00:00
|
|
|
//scroll offset in the current menu
|
|
|
|
extern uint8_t menu_top;
|
|
|
|
|
|
|
|
extern uint8_t menu_clicked;
|
|
|
|
|
2018-08-19 11:59:33 +00:00
|
|
|
extern uint8_t menu_leaving;
|
|
|
|
|
2018-07-16 00:13:52 +00:00
|
|
|
//function pointer to the currently active menu
|
|
|
|
extern menu_func_t menu_menu;
|
|
|
|
|
2020-03-04 20:20:53 +00:00
|
|
|
extern void menu_data_reset(void);
|
2018-07-16 00:13:52 +00:00
|
|
|
|
|
|
|
extern void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bool reset_menu_state);
|
|
|
|
|
|
|
|
#define MENU_BEGIN() menu_start(); for(menu_row = 0; menu_row < LCD_HEIGHT; menu_row++, menu_line++) { menu_item = 0;
|
|
|
|
void menu_start(void);
|
|
|
|
|
|
|
|
#define MENU_END() menu_end(); }
|
|
|
|
extern void menu_end(void);
|
|
|
|
|
|
|
|
extern void menu_back(void);
|
2019-05-25 15:49:18 +00:00
|
|
|
extern void menu_back_no_reset(void);
|
2019-02-20 02:01:33 +00:00
|
|
|
extern void menu_back(uint8_t nLevel);
|
2018-07-16 00:13:52 +00:00
|
|
|
|
|
|
|
extern void menu_back_if_clicked(void);
|
|
|
|
|
|
|
|
extern void menu_back_if_clicked_fb(void);
|
|
|
|
|
|
|
|
extern void menu_submenu(menu_func_t submenu);
|
2019-05-25 15:49:18 +00:00
|
|
|
extern void menu_submenu_no_reset(menu_func_t submenu);
|
2018-07-16 00:13:52 +00:00
|
|
|
|
|
|
|
extern uint8_t menu_item_ret(void);
|
|
|
|
|
2018-08-09 15:43:43 +00:00
|
|
|
//extern int menu_draw_item_printf_P(char type_char, const char* format, ...);
|
2018-07-16 00:13:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
//int menu_draw_item_puts_P_int16(char type_char, const char* str, int16_t val, );
|
|
|
|
|
|
|
|
#define MENU_ITEM_DUMMY() menu_item_dummy()
|
|
|
|
extern void menu_item_dummy(void);
|
|
|
|
|
|
|
|
#define MENU_ITEM_TEXT_P(str) do { if (menu_item_text_P(str)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_text_P(const char* str);
|
|
|
|
|
|
|
|
#define MENU_ITEM_SUBMENU_P(str, submenu) do { if (menu_item_submenu_P(str, submenu)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu);
|
|
|
|
|
2019-06-26 13:51:58 +00:00
|
|
|
#define MENU_ITEM_SUBMENU_E(sheet, submenu) do { if (menu_item_submenu_E(sheet, submenu)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu);
|
2019-06-20 14:40:53 +00:00
|
|
|
|
2019-08-29 18:13:10 +00:00
|
|
|
#define MENU_ITEM_FUNCTION_E(sheet, submenu) do { if (menu_item_function_E(sheet, submenu)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_function_E(const Sheet &sheet, menu_func_t func);
|
2019-06-20 14:40:53 +00:00
|
|
|
|
2018-07-16 00:13:52 +00:00
|
|
|
#define MENU_ITEM_BACK_P(str) do { if (menu_item_back_P(str)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_back_P(const char* str);
|
|
|
|
|
2019-05-06 13:33:13 +00:00
|
|
|
// leaving menu - this condition must be immediately before MENU_ITEM_BACK_P
|
2021-01-26 08:29:17 +00:00
|
|
|
#define ON_MENU_LEAVE(func) do { if (menu_item_leave()){ func } } while (0)
|
|
|
|
extern bool menu_item_leave();
|
2019-05-06 13:33:13 +00:00
|
|
|
|
2018-07-16 00:13:52 +00:00
|
|
|
#define MENU_ITEM_FUNCTION_P(str, func) do { if (menu_item_function_P(str, func)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_function_P(const char* str, menu_func_t func);
|
|
|
|
|
2019-05-14 13:47:25 +00:00
|
|
|
#define MENU_ITEM_FUNCTION_NR_P(str, number, func, fn_par) do { if (menu_item_function_P(str, number, func, fn_par)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_function_P(const char* str, char number, void (*func)(uint8_t), uint8_t fn_par);
|
|
|
|
|
2019-09-13 18:21:42 +00:00
|
|
|
#define MENU_ITEM_TOGGLE_P(str, toggle, func) do { if (menu_item_toggle_P(str, toggle, func, 0x02)) return; } while (0)
|
|
|
|
#define MENU_ITEM_TOGGLE(str, toggle, func) do { if (menu_item_toggle_P(str, toggle, func, 0x00)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_toggle_P(const char* str, const char* toggle, menu_func_t func, const uint8_t settings);
|
2019-08-10 05:42:33 +00:00
|
|
|
|
2018-07-16 00:13:52 +00:00
|
|
|
#define MENU_ITEM_GCODE_P(str, str_gcode) do { if (menu_item_gcode_P(str, str_gcode)) return; } while (0)
|
|
|
|
extern uint8_t menu_item_gcode_P(const char* str, const char* str_gcode);
|
|
|
|
|
|
|
|
|
|
|
|
extern const char menu_fmt_int3[];
|
2018-07-19 14:57:31 +00:00
|
|
|
|
|
|
|
extern const char menu_fmt_float31[];
|
2019-05-16 14:43:44 +00:00
|
|
|
extern const char menu_fmt_float13[];
|
2018-07-19 14:57:31 +00:00
|
|
|
|
2019-05-16 14:43:44 +00:00
|
|
|
extern void menu_draw_float31(const char* str, float val);
|
2018-07-19 14:57:31 +00:00
|
|
|
|
2019-05-16 14:43:44 +00:00
|
|
|
extern void menu_draw_float13(const char* str, float val);
|
2018-07-30 17:24:04 +00:00
|
|
|
|
2019-06-26 13:23:55 +00:00
|
|
|
struct SheetFormatBuffer
|
|
|
|
{
|
|
|
|
char c[19];
|
|
|
|
};
|
|
|
|
|
2019-06-26 13:51:58 +00:00
|
|
|
extern void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer);
|
2019-06-26 13:23:55 +00:00
|
|
|
|
2018-07-19 14:57:31 +00:00
|
|
|
|
2018-08-24 18:06:09 +00:00
|
|
|
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_P(str, pval, minval, maxval)) return; } while (0)
|
2018-07-16 00:13:52 +00:00
|
|
|
//#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) MENU_ITEM_EDIT(int3, str, pval, minval, maxval)
|
2018-08-24 15:33:43 +00:00
|
|
|
template <typename T>
|
|
|
|
extern uint8_t menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_val);
|
2018-07-16 00:13:52 +00:00
|
|
|
|
2018-07-16 02:13:26 +00:00
|
|
|
|
2018-07-16 00:13:52 +00:00
|
|
|
#endif //_MENU_H
|