2018-10-23 16:00:34 -05:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 08:00:57 -06:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2018-10-23 16:00:34 -05:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-27 23:57:50 -05:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2018-10-23 16:00:34 -05:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../ultralcd.h"
|
2019-06-11 05:58:43 -05:00
|
|
|
#include "../../libs/numtostr.h"
|
2018-10-23 16:00:34 -05:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
2019-04-16 15:45:31 -05:00
|
|
|
#include "limits.h"
|
|
|
|
|
2018-10-23 16:00:34 -05:00
|
|
|
extern int8_t encoderLine, encoderTopLine, screen_items;
|
|
|
|
|
|
|
|
void scroll_screen(const uint8_t limit, const bool is_menu);
|
|
|
|
bool printer_busy();
|
2018-11-05 22:51:10 -06:00
|
|
|
|
2019-04-24 10:13:44 -05:00
|
|
|
typedef void (*selectFunc_t)();
|
|
|
|
|
2019-10-09 19:46:10 -05:00
|
|
|
#define SS_LEFT 0x00
|
|
|
|
#define SS_CENTER 0x01
|
|
|
|
#define SS_INVERT 0x02
|
|
|
|
#define SS_DEFAULT SS_CENTER
|
2019-09-27 03:06:23 -05:00
|
|
|
|
2019-03-16 23:43:06 -05:00
|
|
|
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
|
2018-11-14 13:13:51 -06:00
|
|
|
void _lcd_zoffset_overlay_gfx(const float zvalue);
|
2018-10-23 16:00:34 -05:00
|
|
|
#endif
|
|
|
|
|
2020-03-17 15:12:52 -05:00
|
|
|
#if HAS_BED_PROBE
|
|
|
|
#if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
|
|
|
|
#define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000
|
|
|
|
#else
|
|
|
|
#define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
|
|
|
|
#define BABYSTEP_TO_STR(N) ftostr43sign(N)
|
|
|
|
#elif ENABLED(BABYSTEPPING)
|
|
|
|
#define BABYSTEP_TO_STR(N) ftostr53sign(N)
|
2020-01-02 20:40:40 -06:00
|
|
|
#endif
|
|
|
|
|
2018-10-23 16:00:34 -05:00
|
|
|
////////////////////////////////////////////
|
2019-11-02 07:28:20 -05:00
|
|
|
///////////// Base Menu Items //////////////
|
2018-10-23 16:00:34 -05:00
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2019-11-02 07:28:20 -05:00
|
|
|
class MenuItemBase {
|
|
|
|
public:
|
2019-11-14 20:30:30 -06:00
|
|
|
// An index to interject in the item label and for
|
|
|
|
// use by the action
|
|
|
|
static uint8_t itemIndex;
|
|
|
|
|
|
|
|
// Store the index of the item ahead of use by indexed items
|
|
|
|
FORCE_INLINE static void init(const uint8_t ind) { itemIndex = ind; }
|
|
|
|
|
2019-11-02 07:28:20 -05:00
|
|
|
// Draw an item either selected (pre_char) or not (space) with post_char
|
|
|
|
static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
|
|
|
|
|
|
|
|
// Draw an item either selected ('>') or not (space) with post_char
|
2019-11-14 20:30:30 -06:00
|
|
|
FORCE_INLINE static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char post_char) {
|
2019-11-02 07:28:20 -05:00
|
|
|
_draw(sel, row, pstr, '>', post_char);
|
|
|
|
}
|
|
|
|
};
|
2018-10-23 16:00:34 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
class MenuItem_static : public MenuItemBase {
|
|
|
|
public:
|
|
|
|
static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const valstr=nullptr);
|
|
|
|
};
|
|
|
|
|
|
|
|
// CONFIRM_ITEM(LABEL,Y,N,FY,FN,V...),
|
|
|
|
// YESNO_ITEM(LABEL,FY,FN,V...)
|
|
|
|
class MenuItem_confirm : public MenuItemBase {
|
2018-11-05 22:51:10 -06:00
|
|
|
public:
|
2019-11-02 07:28:20 -05:00
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
|
|
|
_draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
|
|
|
|
}
|
|
|
|
// Implemented for HD44780 and DOGM
|
|
|
|
// Draw the prompt, buttons, and state
|
|
|
|
static void draw_select_screen(
|
|
|
|
PGM_P const yes, // Right option label
|
|
|
|
PGM_P const no, // Left option label
|
|
|
|
const bool yesno, // Is "yes" selected?
|
|
|
|
PGM_P const pref, // Prompt prefix
|
|
|
|
const char * const string, // Prompt runtime string
|
|
|
|
PGM_P const suff // Prompt suffix
|
|
|
|
);
|
|
|
|
static void select_screen(
|
|
|
|
PGM_P const yes, PGM_P const no,
|
|
|
|
selectFunc_t yesFunc, selectFunc_t noFunc,
|
|
|
|
PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr
|
|
|
|
);
|
|
|
|
static inline void select_screen(
|
|
|
|
PGM_P const yes, PGM_P const no,
|
|
|
|
selectFunc_t yesFunc, selectFunc_t noFunc,
|
|
|
|
PGM_P const pref, const progmem_str string, PGM_P const suff=nullptr
|
|
|
|
) {
|
|
|
|
char str[strlen_P((PGM_P)string) + 1];
|
|
|
|
strcpy_P(str, (PGM_P)string);
|
|
|
|
select_screen(yes, no, yesFunc, noFunc, pref, str, suff);
|
|
|
|
}
|
|
|
|
// Shortcut for prompt with "NO"/ "YES" labels
|
|
|
|
FORCE_INLINE static void confirm_screen(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
|
|
|
|
select_screen(GET_TEXT(MSG_YES), GET_TEXT(MSG_NO), yesFunc, noFunc, pref, string, suff);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
// BACK_ITEM(LABEL)
|
2019-11-02 07:28:20 -05:00
|
|
|
class MenuItem_back : public MenuItemBase {
|
|
|
|
public:
|
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
|
|
|
|
_draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
|
|
|
|
}
|
2019-11-14 20:30:30 -06:00
|
|
|
// Back Item action goes back one step in history
|
|
|
|
FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); }
|
2018-11-05 22:51:10 -06:00
|
|
|
};
|
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
// SUBMENU(LABEL, screen_handler)
|
2019-11-02 07:28:20 -05:00
|
|
|
class MenuItem_submenu : public MenuItemBase {
|
2018-11-05 22:51:10 -06:00
|
|
|
public:
|
2019-11-02 07:28:20 -05:00
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
|
|
|
_draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
|
|
|
|
}
|
2019-09-30 22:53:34 -05:00
|
|
|
static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
|
2018-11-05 22:51:10 -06:00
|
|
|
};
|
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
// Any menu item that invokes an immediate action
|
|
|
|
class MenuItem_button : public MenuItemBase {
|
2018-11-05 22:51:10 -06:00
|
|
|
public:
|
2019-11-14 20:30:30 -06:00
|
|
|
// Button-y Items are selectable lines with no other indicator
|
|
|
|
static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
2019-11-02 07:28:20 -05:00
|
|
|
_draw(sel, row, pstr, '>', ' ');
|
|
|
|
}
|
2018-11-05 22:51:10 -06:00
|
|
|
};
|
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
// GCODES_ITEM(LABEL, GCODES)
|
|
|
|
class MenuItem_gcode : public MenuItem_button {
|
2018-11-05 22:51:10 -06:00
|
|
|
public:
|
2019-11-02 07:28:20 -05:00
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
|
|
|
_draw(sel, row, pstr, '>', ' ');
|
|
|
|
}
|
2019-11-14 20:30:30 -06:00
|
|
|
static void action(PGM_P const, const char * const pgcode);
|
|
|
|
static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); }
|
|
|
|
};
|
|
|
|
|
|
|
|
// ACTION_ITEM(LABEL, FUNC)
|
|
|
|
class MenuItem_function : public MenuItem_button {
|
|
|
|
public:
|
|
|
|
//static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); };
|
2019-09-30 22:53:34 -05:00
|
|
|
static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
|
2018-11-05 22:51:10 -06:00
|
|
|
};
|
2018-10-23 16:00:34 -05:00
|
|
|
|
2019-11-02 07:28:20 -05:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
class CardReader;
|
|
|
|
class MenuItem_sdbase {
|
|
|
|
public:
|
2019-11-14 20:30:30 -06:00
|
|
|
// Implemented for HD44780 and DOGM
|
2019-11-02 07:28:20 -05:00
|
|
|
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-10-23 16:00:34 -05:00
|
|
|
////////////////////////////////////////////
|
2019-11-02 07:28:20 -05:00
|
|
|
///////////// Edit Menu Items //////////////
|
2018-10-23 16:00:34 -05:00
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2019-10-07 19:44:33 -05:00
|
|
|
// The Menu Edit shadow value
|
|
|
|
typedef union {
|
|
|
|
bool state;
|
|
|
|
float decimal;
|
|
|
|
int8_t int8;
|
|
|
|
int16_t int16;
|
|
|
|
int32_t int32;
|
|
|
|
uint8_t uint8;
|
|
|
|
uint16_t uint16;
|
|
|
|
uint32_t uint32;
|
|
|
|
} chimera_t;
|
|
|
|
extern chimera_t editable;
|
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
// Base class for Menu Edit Items
|
2019-11-02 07:28:20 -05:00
|
|
|
class MenuEditItemBase : public MenuItemBase {
|
2019-04-08 21:10:41 -05:00
|
|
|
private:
|
2019-11-14 20:30:30 -06:00
|
|
|
// These values are statically constructed by init() via action()
|
|
|
|
// The action() method acts like the instantiator. The entire lifespan
|
|
|
|
// of a menu item is within its declaration, so all these values decompose
|
|
|
|
// into behavior and unused items get optimized out.
|
2019-04-08 21:10:41 -05:00
|
|
|
static PGM_P editLabel;
|
|
|
|
static void *editValue;
|
2019-10-02 19:04:16 -05:00
|
|
|
static int32_t minEditValue, maxEditValue; // Encoder value range
|
2019-04-08 21:10:41 -05:00
|
|
|
static screenFunc_t callbackFunc;
|
|
|
|
static bool liveEdit;
|
2018-11-05 22:51:10 -06:00
|
|
|
protected:
|
2019-10-10 21:03:33 -05:00
|
|
|
typedef const char* (*strfunc_t)(const int32_t);
|
2019-05-11 18:44:35 -05:00
|
|
|
typedef void (*loadfunc_t)(void *, const int32_t);
|
2019-11-14 20:30:30 -06:00
|
|
|
static void goto_edit_screen(
|
|
|
|
PGM_P const el, // Edit label
|
|
|
|
void * const ev, // Edit value pointer
|
|
|
|
const int32_t minv, // Encoder minimum
|
|
|
|
const int32_t maxv, // Encoder maximum
|
|
|
|
const uint16_t ep, // Initial encoder value
|
|
|
|
const screenFunc_t cs, // MenuItem_type::draw_edit_screen => MenuEditItemBase::edit()
|
|
|
|
const screenFunc_t cb, // Callback after edit
|
|
|
|
const bool le // Flag to call cb() during editing
|
|
|
|
);
|
|
|
|
static void edit_screen(strfunc_t, loadfunc_t); // Edit value handler
|
2019-11-02 07:28:20 -05:00
|
|
|
public:
|
|
|
|
// Implemented for HD44780 and DOGM
|
|
|
|
// Draw the current item at specified row with edit data
|
2019-11-14 20:30:30 -06:00
|
|
|
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm=false);
|
2019-11-02 07:28:20 -05:00
|
|
|
|
|
|
|
// Implemented for HD44780 and DOGM
|
|
|
|
// This low-level method is good to draw from anywhere
|
2019-11-14 20:30:30 -06:00
|
|
|
static void draw_edit_screen(PGM_P const pstr, const char* const value);
|
|
|
|
|
|
|
|
// This method is for the current menu item
|
|
|
|
static inline void draw_edit_screen(const char* const value) { draw_edit_screen(editLabel, value); }
|
2018-11-05 22:51:10 -06:00
|
|
|
};
|
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
// Template for specific Menu Edit Item Types
|
2018-11-05 22:51:10 -06:00
|
|
|
template<typename NAME>
|
2019-10-02 19:04:16 -05:00
|
|
|
class TMenuEditItem : MenuEditItemBase {
|
2018-11-05 22:51:10 -06:00
|
|
|
private:
|
|
|
|
typedef typename NAME::type_t type_t;
|
2020-02-15 02:35:36 -06:00
|
|
|
static inline float scale(const float value) { return NAME::scale(value); }
|
|
|
|
static inline float unscale(const float value) { return NAME::unscale(value); }
|
2019-10-10 21:03:33 -05:00
|
|
|
static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
|
2020-02-15 02:35:36 -06:00
|
|
|
static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); }
|
2018-11-05 22:51:10 -06:00
|
|
|
public:
|
2019-11-02 07:28:20 -05:00
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) {
|
|
|
|
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data)));
|
|
|
|
}
|
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) {
|
|
|
|
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget()));
|
|
|
|
}
|
2019-11-14 20:30:30 -06:00
|
|
|
// Edit screen for this type of item
|
|
|
|
static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); }
|
2019-10-02 19:04:16 -05:00
|
|
|
static void action(
|
|
|
|
PGM_P const pstr, // Edit label
|
|
|
|
type_t * const ptr, // Value pointer
|
|
|
|
const type_t minValue, // Value range
|
|
|
|
const type_t maxValue,
|
|
|
|
const screenFunc_t callback=nullptr, // Value update callback
|
|
|
|
const bool live=false // Callback during editing
|
|
|
|
) {
|
|
|
|
// Make sure minv and maxv fit within int32_t
|
|
|
|
const int32_t minv = _MAX(scale(minValue), INT32_MIN),
|
|
|
|
maxv = _MIN(scale(maxValue), INT32_MAX);
|
2019-11-14 20:30:30 -06:00
|
|
|
goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv,
|
|
|
|
edit_screen, callback, live);
|
2018-11-05 22:51:10 -06:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-11-02 07:28:20 -05:00
|
|
|
// Provide a set of Edit Item Types which encompass a primitive
|
|
|
|
// type, a string function, and a scale factor for edit and display.
|
|
|
|
// These items call the Edit Item draw method passing the prepared string.
|
2020-03-08 19:42:18 -05:00
|
|
|
#define __DOFIXfloat PROBE()
|
|
|
|
#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V)))
|
|
|
|
#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \
|
2020-02-15 02:44:34 -06:00
|
|
|
struct MenuEditItemInfo_##NAME { \
|
|
|
|
typedef TYPE type_t; \
|
|
|
|
static inline float scale(const float value) { return value * (SCALE) + (V+0); } \
|
|
|
|
static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \
|
2020-03-08 19:42:18 -05:00
|
|
|
static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \
|
2020-02-15 02:44:34 -06:00
|
|
|
}; \
|
2019-11-02 07:28:20 -05:00
|
|
|
typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME
|
|
|
|
|
2020-03-08 19:42:18 -05:00
|
|
|
// NAME TYPE STRFUNC SCALE +ROUND
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, 0.5f); // 100% right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3 , 1 ); // 123 right-justified
|
2020-03-17 15:12:52 -05:00
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
2020-03-08 19:42:18 -05:00
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); // -1.234, _1.234, +1.234
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float51 ,float ,ftostr51rj , 10 ); // 1234.5 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 ); // +123.45
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified
|
|
|
|
DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
|
2019-11-02 07:28:20 -05:00
|
|
|
|
|
|
|
class MenuItem_bool : public MenuEditItemBase {
|
2018-11-05 22:51:10 -06:00
|
|
|
public:
|
2019-11-02 07:28:20 -05:00
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) {
|
|
|
|
MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true);
|
|
|
|
}
|
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) {
|
|
|
|
draw(sel, row, pstr, *data);
|
|
|
|
}
|
|
|
|
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) {
|
|
|
|
draw(sel, row, pstr, pget());
|
|
|
|
}
|
|
|
|
static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr);
|
2018-11-05 22:51:10 -06:00
|
|
|
};
|
2018-10-23 16:00:34 -05:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
//////////// Menu System Macros ////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SCREEN_OR_MENU_LOOP generates init code for a screen or menu
|
|
|
|
*
|
|
|
|
* encoderTopLine is the top menu line to display
|
|
|
|
* _lcdLineNr is the index of the LCD line (e.g., 0-3)
|
|
|
|
* _menuLineNr is the menu item to draw and process
|
|
|
|
* _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
|
|
|
|
*/
|
2020-03-02 13:14:08 -06:00
|
|
|
#define SCREEN_OR_MENU_LOOP(IS_MENU) \
|
|
|
|
scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU); \
|
|
|
|
int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \
|
|
|
|
bool _skipStatic = IS_MENU; UNUSED(_thisItemNr); \
|
2018-10-27 13:07:03 -05:00
|
|
|
for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
|
2018-10-23 16:00:34 -05:00
|
|
|
_thisItemNr = 0
|
|
|
|
|
|
|
|
/**
|
|
|
|
* START_SCREEN Opening code for a screen having only static items.
|
|
|
|
* Do simplified scrolling of the entire screen.
|
|
|
|
*
|
|
|
|
* START_MENU Opening code for a screen with menu items.
|
|
|
|
* Scroll as-needed to keep the selected line in view.
|
|
|
|
*/
|
2019-11-14 20:30:30 -06:00
|
|
|
#define START_SCREEN() SCREEN_OR_MENU_LOOP(false)
|
|
|
|
#define START_MENU() SCREEN_OR_MENU_LOOP(true)
|
|
|
|
#define NEXT_ITEM() (++_thisItemNr)
|
|
|
|
#define SKIP_ITEM() NEXT_ITEM()
|
|
|
|
#define END_SCREEN() } screen_items = _thisItemNr
|
2019-10-27 19:50:21 -05:00
|
|
|
#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
|
2018-10-23 16:00:34 -05:00
|
|
|
|
|
|
|
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
2018-11-11 12:16:24 -06:00
|
|
|
#define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)
|
|
|
|
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0)
|
2018-10-23 16:00:34 -05:00
|
|
|
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
|
2018-11-11 12:16:24 -06:00
|
|
|
#else
|
2018-10-23 16:00:34 -05:00
|
|
|
#define ENCODER_RATE_MULTIPLY(F) NOOP
|
2018-11-05 22:51:10 -06:00
|
|
|
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
|
2018-11-11 12:16:24 -06:00
|
|
|
#endif
|
2018-10-23 16:00:34 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
|
|
|
|
*
|
2019-11-02 07:28:20 -05:00
|
|
|
* MenuItem_<type>::draw(sel, row, label, arg3...)
|
2019-10-02 19:04:16 -05:00
|
|
|
* MenuItem_<type>::action(arg3...)
|
2018-10-23 16:00:34 -05:00
|
|
|
*
|
|
|
|
* Examples:
|
2020-01-03 19:46:05 -06:00
|
|
|
* BACK_ITEM(MSG_INFO_SCREEN)
|
2019-11-14 20:30:30 -06:00
|
|
|
* MenuItem_back::action(plabel, ...)
|
|
|
|
* MenuItem_back::draw(sel, row, plabel, ...)
|
2018-10-23 16:00:34 -05:00
|
|
|
*
|
2019-10-03 05:38:30 -05:00
|
|
|
* ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
|
2019-11-14 20:30:30 -06:00
|
|
|
* MenuItem_function::action(plabel, lcd_sdcard_pause)
|
|
|
|
* MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause)
|
2018-10-23 16:00:34 -05:00
|
|
|
*
|
2019-10-03 05:38:30 -05:00
|
|
|
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
2019-11-14 20:30:30 -06:00
|
|
|
* MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
|
|
|
|
* MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999)
|
2018-10-23 16:00:34 -05:00
|
|
|
*/
|
2019-11-14 20:30:30 -06:00
|
|
|
|
|
|
|
#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
|
|
|
|
PGM_P const plabel = PLABEL; \
|
|
|
|
if (encoderLine == _thisItemNr && ui.use_click()) { \
|
|
|
|
_MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
|
|
|
|
MenuItem_##TYPE::action(plabel, ##V); \
|
|
|
|
if (ui.screen_changed) return; \
|
|
|
|
} \
|
|
|
|
if (ui.should_draw()) \
|
|
|
|
MenuItem_##TYPE::draw \
|
|
|
|
(encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define _MENU_ITEM_P(TYPE, V...) do { \
|
|
|
|
_skipStatic = false; \
|
|
|
|
if (_menuLineNr == _thisItemNr) \
|
|
|
|
_MENU_INNER_P(TYPE, ##V); \
|
|
|
|
NEXT_ITEM(); \
|
2018-11-05 22:51:10 -06:00
|
|
|
}while(0)
|
2018-10-23 16:00:34 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
// Indexed items set a global index value
|
|
|
|
#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \
|
|
|
|
_skipStatic = false; \
|
|
|
|
if (_menuLineNr == _thisItemNr) { \
|
|
|
|
MenuItemBase::init(N); \
|
|
|
|
_MENU_INNER_P(TYPE, ##V); \
|
|
|
|
} \
|
|
|
|
NEXT_ITEM(); \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
// STATIC_ITEM draws a styled string with no highlight.
|
|
|
|
// Parameters: label [, style [, char *value] ]
|
|
|
|
|
|
|
|
#define STATIC_ITEM_INNER_P(PLABEL, V...) do{ \
|
|
|
|
if (_skipStatic && encoderLine <= _thisItemNr) { \
|
|
|
|
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
|
|
|
|
++encoderLine; \
|
|
|
|
} \
|
|
|
|
if (ui.should_draw()) \
|
|
|
|
MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \
|
2018-11-05 22:51:10 -06:00
|
|
|
} while(0)
|
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define STATIC_ITEM_P(PLABEL, V...) do{ \
|
|
|
|
if (_menuLineNr == _thisItemNr) \
|
|
|
|
STATIC_ITEM_INNER_P(PLABEL, ##V); \
|
|
|
|
NEXT_ITEM(); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \
|
|
|
|
if (_menuLineNr == _thisItemNr) { \
|
|
|
|
MenuItemBase::init(N); \
|
|
|
|
STATIC_ITEM_INNER_P(PLABEL, ##V); \
|
|
|
|
} \
|
|
|
|
NEXT_ITEM(); \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P( GET_TEXT(LABEL), ##V)
|
|
|
|
#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
|
|
|
|
#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V)
|
|
|
|
#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
|
2018-10-23 16:00:34 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL)
|
2019-10-03 05:38:30 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define ACTION_ITEM_P(PLABEL, ACTION) MENU_ITEM_P(function, PLABEL, ACTION)
|
|
|
|
#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_P(GET_TEXT(LABEL), ACTION)
|
2019-10-09 19:46:10 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define ACTION_ITEM_N_P(N, PLABEL, ACTION) MENU_ITEM_N_P(function, N, PLABEL, ACTION)
|
|
|
|
#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION)
|
2019-10-09 19:46:10 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define GCODES_ITEM_P(PLABEL, GCODES) MENU_ITEM_P(gcode, PLABEL, GCODES)
|
|
|
|
#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_P(GET_TEXT(LABEL), GCODES)
|
2019-10-09 19:46:10 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define GCODES_ITEM_N_P(N, PLABEL, GCODES) MENU_ITEM_N_P(gcode, N, PLABEL, GCODES)
|
|
|
|
#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES)
|
2019-10-09 19:46:10 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define SUBMENU_P(PLABEL, DEST) MENU_ITEM_P(submenu, PLABEL, DEST)
|
|
|
|
#define SUBMENU(LABEL, DEST) SUBMENU_P(GET_TEXT(LABEL), DEST)
|
2019-10-09 19:46:10 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define SUBMENU_N_P(N, PLABEL, DEST) MENU_ITEM_N_P(submenu, N, PLABEL, DEST)
|
|
|
|
#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_P(N, GET_TEXT(LABEL), DEST)
|
2018-10-23 16:00:34 -05:00
|
|
|
|
2019-11-14 20:30:30 -06:00
|
|
|
#define EDIT_ITEM_P(TYPE, PLABEL, V...) MENU_ITEM_P(TYPE, PLABEL, ##V)
|
|
|
|
#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...) MENU_ITEM_N_P(TYPE, N, PLABEL, ##V)
|
|
|
|
#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, true, PLABEL, ##V)
|
|
|
|
#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V)
|
|
|
|
#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \
|
|
|
|
if (encoderLine == _thisItemNr && ui.use_click()) { \
|
|
|
|
ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
if (ui.should_draw()) MenuItem_confirm::draw \
|
|
|
|
(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define _CONFIRM_ITEM_P(PLABEL, V...) do { \
|
|
|
|
_skipStatic = false; \
|
|
|
|
if (_menuLineNr == _thisItemNr) \
|
|
|
|
_CONFIRM_ITEM_INNER_P(PLABEL, ##V); \
|
|
|
|
NEXT_ITEM(); \
|
|
|
|
}while(0)
|
|
|
|
|
|
|
|
// Indexed items set a global index value
|
|
|
|
#define _CONFIRM_ITEM_N_P(N, V...) do{ \
|
|
|
|
_skipStatic = false; \
|
|
|
|
if (_menuLineNr == _thisItemNr) { \
|
|
|
|
MenuItemBase::init(N); \
|
|
|
|
_CONFIRM_ITEM_INNER_P(TYPE, ##V); \
|
|
|
|
} \
|
|
|
|
NEXT_ITEM(); \
|
2019-11-02 07:28:20 -05:00
|
|
|
}while(0)
|
|
|
|
|
|
|
|
#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
|
|
|
|
#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
|
2019-11-14 20:30:30 -06:00
|
|
|
|
2019-11-02 07:28:20 -05:00
|
|
|
#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V)
|
2019-11-14 20:30:30 -06:00
|
|
|
#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
|
|
|
|
#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
|
|
|
|
|
|
|
|
#define YESNO_ITEM_N_P(N,PLABEL, V...) _CONFIRM_ITEM_N_P(N, PLABEL, ##V)
|
|
|
|
#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
|
2019-11-02 07:28:20 -05:00
|
|
|
|
2018-10-23 16:00:34 -05:00
|
|
|
////////////////////////////////////////////
|
|
|
|
/////////////// Menu Screens ///////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
void menu_main();
|
|
|
|
void menu_move();
|
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT)
|
2019-08-14 17:52:14 -05:00
|
|
|
void menu_media();
|
2018-10-23 16:00:34 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// First Fan Speed title in "Tune" and "Control>Temperature" menus
|
|
|
|
#if FAN_COUNT > 0 && HAS_FAN0
|
|
|
|
#if FAN_COUNT > 1
|
|
|
|
#define FAN_SPEED_1_SUFFIX " 1"
|
|
|
|
#else
|
|
|
|
#define FAN_SPEED_1_SUFFIX ""
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
//////// Menu Item Helper Functions ////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
void lcd_move_z();
|
|
|
|
void _lcd_draw_homing();
|
|
|
|
|
2019-03-16 23:43:06 -05:00
|
|
|
#define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LEVEL_BED_CORNERS)
|
2018-10-28 02:59:21 -05:00
|
|
|
|
|
|
|
#if HAS_LINE_TO_Z
|
|
|
|
void line_to_z(const float &z);
|
|
|
|
#endif
|
|
|
|
|
2019-10-29 16:38:17 -05:00
|
|
|
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
|
|
|
|
void _lcd_zoffset_overlay_gfx(const float zvalue);
|
|
|
|
#endif
|
|
|
|
|
2018-10-23 16:00:34 -05:00
|
|
|
#if ENABLED(LEVEL_BED_CORNERS)
|
|
|
|
void _lcd_level_bed_corners();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
|
|
|
|
void _lcd_toggle_bed_leveling();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(BABYSTEPPING)
|
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
void lcd_babystep_zoffset();
|
|
|
|
#else
|
|
|
|
void lcd_babystep_z();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(EEPROM_SETTINGS)
|
|
|
|
void lcd_store_settings();
|
|
|
|
void lcd_load_settings();
|
|
|
|
#endif
|
2018-11-11 12:16:24 -06:00
|
|
|
|
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
|
|
|
void menu_job_recovery();
|
|
|
|
#endif
|