2018-10-23 23:00:34 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2018-10-23 23:00:34 +02: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 12:58:43 +02:00
|
|
|
#include "../../libs/numtostr.h"
|
2018-10-23 23:00:34 +02:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
2019-04-16 22:45:31 +02:00
|
|
|
#include "limits.h"
|
|
|
|
|
2018-10-23 23:00:34 +02:00
|
|
|
extern int8_t encoderLine, encoderTopLine, screen_items;
|
|
|
|
extern bool screen_changed;
|
|
|
|
|
2019-09-10 09:20:49 +02:00
|
|
|
#if HOTENDS
|
2019-09-28 22:30:41 +02:00
|
|
|
constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP);
|
2019-09-10 09:20:49 +02:00
|
|
|
#endif
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
void scroll_screen(const uint8_t limit, const bool is_menu);
|
|
|
|
bool printer_busy();
|
2018-11-06 05:51:10 +01:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
////////// Menu Item Numeric Types /////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define DECLARE_MENU_EDIT_TYPE(TYPE, NAME, STRFUNC, SCALE) \
|
2019-10-03 02:04:16 +02:00
|
|
|
struct MenuEditItemInfo_##NAME { \
|
2018-11-06 05:51:10 +01:00
|
|
|
typedef TYPE type_t; \
|
|
|
|
static constexpr float scale = SCALE; \
|
|
|
|
static inline char* strfunc(const float value) { return STRFUNC((TYPE) value); } \
|
|
|
|
};
|
|
|
|
|
2019-08-21 10:49:43 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(uint8_t, percent, ui8tostr4pct, 100.0/255); // 100% right-justified
|
2019-01-29 03:18:58 +01:00
|
|
|
DECLARE_MENU_EDIT_TYPE(int16_t, int3, i16tostr3, 1 ); // 123, -12 right-justified
|
|
|
|
DECLARE_MENU_EDIT_TYPE(int16_t, int4, i16tostr4sign, 1 ); // 1234, -123 right-justified
|
|
|
|
DECLARE_MENU_EDIT_TYPE(int8_t, int8, i8tostr3, 1 ); // 123, -12 right-justified
|
|
|
|
DECLARE_MENU_EDIT_TYPE(uint8_t, uint8, ui8tostr3, 1 ); // 123 right-justified
|
2019-06-28 06:06:49 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_3, ui16tostr3, 1 ); // 123 right-justified
|
|
|
|
DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_4, ui16tostr4, 0.1 ); // 1234 right-justified
|
|
|
|
DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_5, ui16tostr5, 0.01 ); // 12345 right-justified
|
2019-01-29 03:18:58 +01:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float3, ftostr3, 1 ); // 123 right-justified
|
2019-05-25 22:24:26 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float52, ftostr42_52, 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
2019-01-29 03:18:58 +01:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000 ); // 1.234
|
2019-09-04 20:06:23 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 1 ); // 12345 right-justified
|
2019-05-05 00:21:58 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
|
2019-07-20 08:41:34 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float51, ftostr51rj, 10 ); // 1234.5 right-justified
|
2019-04-16 22:45:31 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float51sign, ftostr51sign, 10 ); // +1234.5
|
2019-01-29 03:18:58 +01:00
|
|
|
DECLARE_MENU_EDIT_TYPE(float, float52sign, ftostr52sign, 100 ); // +123.45
|
|
|
|
DECLARE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f ); // 12345 right-justified
|
2019-05-05 00:21:58 +02:00
|
|
|
DECLARE_MENU_EDIT_TYPE(uint32_t, long5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
///////// Menu Item Draw Functions /////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2019-04-24 17:13:44 +02:00
|
|
|
typedef void (*selectFunc_t)();
|
2019-04-08 20:44:35 +02:00
|
|
|
void draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff);
|
2019-05-09 18:45:55 +02:00
|
|
|
void do_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);
|
|
|
|
inline void do_select_screen_yn(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
|
2019-04-24 17:13:44 +02:00
|
|
|
do_select_screen(PSTR(MSG_YES), PSTR(MSG_NO), yesFunc, noFunc, pref, string, suff);
|
2019-04-08 20:44:35 +02:00
|
|
|
}
|
2019-04-24 17:13:44 +02:00
|
|
|
|
2019-09-27 10:06:23 +02:00
|
|
|
#define SS_LEFT 0x00
|
|
|
|
#define SS_CENTER 0x01
|
|
|
|
#define SS_INVERT 0x02
|
|
|
|
|
2019-05-09 18:45:55 +02:00
|
|
|
void draw_edit_screen(PGM_P const pstr, const char* const value=nullptr);
|
2018-11-14 20:13:51 +01:00
|
|
|
void draw_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
|
2019-09-27 10:06:23 +02:00
|
|
|
void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_CENTER, const char * const valstr=nullptr);
|
2018-11-14 20:13:51 +01:00
|
|
|
void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm);
|
|
|
|
FORCE_INLINE void draw_menu_item_back(const bool sel, const uint8_t row, PGM_P const pstr) { draw_menu_item(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); }
|
|
|
|
FORCE_INLINE void draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { _draw_menu_item_edit(sel, row, pstr, data, false); }
|
|
|
|
FORCE_INLINE void draw_menu_item_edit_P(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { _draw_menu_item_edit(sel, row, pstr, data, true); }
|
|
|
|
#define draw_menu_item_submenu(sel, row, pstr, data) draw_menu_item(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
|
|
|
|
#define draw_menu_item_gcode(sel, row, pstr, gcode) draw_menu_item(sel, row, pstr, '>', ' ')
|
|
|
|
#define draw_menu_item_function(sel, row, pstr, data) draw_menu_item(sel, row, pstr, '>', ' ')
|
|
|
|
#define DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(VAL) draw_menu_item_edit(sel, row, pstr, VAL)
|
|
|
|
#define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_edit_P(sel, row, pstr, (*(data))?PSTR(MSG_LCD_ON):PSTR(MSG_LCD_OFF))
|
|
|
|
|
2018-10-23 23:00:34 +02:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
class CardReader;
|
2018-11-14 20:13:51 +01:00
|
|
|
void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
|
|
|
|
FORCE_INLINE void draw_menu_item_sdfile(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, false); }
|
|
|
|
FORCE_INLINE void draw_menu_item_sdfolder(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, true); }
|
2018-10-23 23:00:34 +02:00
|
|
|
#endif
|
2018-11-14 20:13:51 +01:00
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
|
2018-11-14 20:13:51 +01:00
|
|
|
void _lcd_zoffset_overlay_gfx(const float zvalue);
|
2018-10-23 23:00:34 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
/////// Edit Setting Draw Functions ////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2018-11-14 20:13:51 +01:00
|
|
|
#define _DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(TYPE, NAME, STRFUNC) \
|
2019-10-03 02:04:16 +02:00
|
|
|
FORCE_INLINE void draw_menu_item_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, TYPE * const data, ...) { \
|
2018-11-14 20:13:51 +01:00
|
|
|
DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \
|
2018-10-23 23:00:34 +02:00
|
|
|
} \
|
2019-10-03 02:04:16 +02:00
|
|
|
FORCE_INLINE void draw_menu_item_accessor_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, TYPE (*pget)(), void (*)(TYPE), ...) { \
|
2018-11-14 20:13:51 +01:00
|
|
|
DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(pget())); \
|
2018-10-23 23:00:34 +02:00
|
|
|
} \
|
|
|
|
typedef void NAME##_void
|
2019-10-03 02:04:16 +02:00
|
|
|
#define DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(NAME) _DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(MenuEditItemInfo_##NAME::type_t, NAME, MenuEditItemInfo_##NAME::strfunc)
|
2018-11-14 20:13:51 +01:00
|
|
|
|
2019-03-29 20:07:43 +01:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(percent); // 100% right-justified
|
2019-01-29 03:18:58 +01:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int3); // 123, -12 right-justified
|
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int4); // 1234, -123 right-justified
|
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int8); // 123, -12 right-justified
|
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint8); // 123 right-justified
|
2019-06-28 06:06:49 +02:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_3); // 123 right-justified
|
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_4); // 1234 right-justified
|
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_5); // 12345 right-justified
|
2019-01-29 03:18:58 +01:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float3); // 123 right-justified
|
2019-05-25 22:24:26 +02:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
2019-01-29 03:18:58 +01:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float43); // 1.234
|
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5); // 12345 right-justified
|
2019-05-05 00:21:58 +02:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5_25); // 12345 right-justified (25 increment)
|
2019-05-12 01:44:35 +02:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float51); // _1234.5 right-justified
|
2019-04-16 22:45:31 +02:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float51sign); // +1234.5
|
2019-01-29 03:18:58 +01:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52sign); // +123.45
|
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(long5); // 12345 right-justified
|
2019-05-05 00:21:58 +02:00
|
|
|
DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(long5_25); // 12345 right-justified (25 increment)
|
2018-11-14 20:13:51 +01:00
|
|
|
|
2019-10-03 02:04:16 +02:00
|
|
|
#define draw_menu_item_bool(sel, row, pstr, data, ...) DRAW_BOOL_SETTING(sel, row, pstr, data)
|
|
|
|
#define draw_menu_item_accessor_bool(sel, row, pstr, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
/////////////// Menu Actions ///////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2018-11-14 20:13:51 +01:00
|
|
|
class MenuItem_back {
|
2018-11-06 05:51:10 +01:00
|
|
|
public:
|
2019-10-01 04:44:07 +02:00
|
|
|
static inline void action(PGM_P const=nullptr) {
|
2019-08-21 02:37:03 +02:00
|
|
|
ui.goto_previous_screen(
|
|
|
|
#if ENABLED(TURBO_BACK_MENU_ITEM)
|
|
|
|
true
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
2018-11-06 05:51:10 +01:00
|
|
|
};
|
|
|
|
|
2018-11-14 20:13:51 +01:00
|
|
|
class MenuItem_submenu {
|
2018-11-06 05:51:10 +01:00
|
|
|
public:
|
2019-10-01 05:53:34 +02:00
|
|
|
static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
|
2018-11-06 05:51:10 +01:00
|
|
|
};
|
|
|
|
|
2018-11-14 20:13:51 +01:00
|
|
|
class MenuItem_gcode {
|
2018-11-06 05:51:10 +01:00
|
|
|
public:
|
2019-10-01 05:53:34 +02:00
|
|
|
static void action(PGM_P const, const char * const pgcode);
|
2018-11-06 05:51:10 +01:00
|
|
|
};
|
|
|
|
|
2018-11-14 20:13:51 +01:00
|
|
|
class MenuItem_function {
|
2018-11-06 05:51:10 +01:00
|
|
|
public:
|
2019-10-01 05:53:34 +02:00
|
|
|
static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
|
2018-11-06 05:51:10 +01:00
|
|
|
};
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
/////////// Menu Editing Actions ///////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
2019-10-08 02:44:33 +02:00
|
|
|
//
|
|
|
|
// The Menu Edit shadow value
|
|
|
|
// Only one edit value is needed at a time
|
|
|
|
//
|
|
|
|
|
|
|
|
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-10-03 02:04:16 +02:00
|
|
|
// Edit items use long integer encoder units
|
|
|
|
class MenuEditItemBase {
|
2019-04-09 04:10:41 +02:00
|
|
|
private:
|
|
|
|
static PGM_P editLabel;
|
|
|
|
static void *editValue;
|
2019-10-03 02:04:16 +02:00
|
|
|
static int32_t minEditValue, maxEditValue; // Encoder value range
|
2019-04-09 04:10:41 +02:00
|
|
|
static screenFunc_t callbackFunc;
|
|
|
|
static bool liveEdit;
|
2018-11-06 05:51:10 +01:00
|
|
|
protected:
|
2019-05-12 01:44:35 +02:00
|
|
|
typedef char* (*strfunc_t)(const int32_t);
|
|
|
|
typedef void (*loadfunc_t)(void *, const int32_t);
|
|
|
|
static void init(PGM_P const el, void * const ev, const int32_t minv, const int32_t maxv, const uint16_t ep, const screenFunc_t cs, const screenFunc_t cb, const bool le);
|
2018-11-06 05:51:10 +01:00
|
|
|
static void edit(strfunc_t, loadfunc_t);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename NAME>
|
2019-10-03 02:04:16 +02:00
|
|
|
class TMenuEditItem : MenuEditItemBase {
|
2018-11-06 05:51:10 +01:00
|
|
|
private:
|
|
|
|
typedef typename NAME::type_t type_t;
|
2019-01-11 02:15:17 +01:00
|
|
|
static inline float unscale(const float value) { return value * (1.0f / NAME::scale); }
|
|
|
|
static inline float scale(const float value) { return value * NAME::scale; }
|
2019-05-12 01:44:35 +02:00
|
|
|
static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); }
|
|
|
|
static char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
|
2018-11-06 05:51:10 +01:00
|
|
|
public:
|
2019-10-03 02:04:16 +02: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-04-16 22:45:31 +02:00
|
|
|
init(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv, edit, callback, live);
|
2018-11-06 05:51:10 +01:00
|
|
|
}
|
2019-10-03 02:04:16 +02:00
|
|
|
static void edit() { MenuEditItemBase::edit(to_string, load); }
|
2018-11-06 05:51:10 +01:00
|
|
|
};
|
|
|
|
|
2019-10-03 02:04:16 +02:00
|
|
|
#define DECLARE_MENU_EDIT_ITEM(NAME) typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME;
|
2018-11-06 05:51:10 +01:00
|
|
|
|
2019-03-29 20:07:43 +01:00
|
|
|
DECLARE_MENU_EDIT_ITEM(percent);
|
2018-11-06 05:51:10 +01:00
|
|
|
DECLARE_MENU_EDIT_ITEM(int3);
|
|
|
|
DECLARE_MENU_EDIT_ITEM(int4);
|
|
|
|
DECLARE_MENU_EDIT_ITEM(int8);
|
2019-01-12 23:01:04 +01:00
|
|
|
DECLARE_MENU_EDIT_ITEM(uint8);
|
2019-01-17 20:17:16 +01:00
|
|
|
DECLARE_MENU_EDIT_ITEM(uint16_3);
|
|
|
|
DECLARE_MENU_EDIT_ITEM(uint16_4);
|
2019-06-28 06:06:49 +02:00
|
|
|
DECLARE_MENU_EDIT_ITEM(uint16_5);
|
2018-11-06 05:51:10 +01:00
|
|
|
DECLARE_MENU_EDIT_ITEM(float3);
|
|
|
|
DECLARE_MENU_EDIT_ITEM(float52);
|
|
|
|
DECLARE_MENU_EDIT_ITEM(float43);
|
|
|
|
DECLARE_MENU_EDIT_ITEM(float5);
|
2019-05-05 00:21:58 +02:00
|
|
|
DECLARE_MENU_EDIT_ITEM(float5_25);
|
2018-11-06 05:51:10 +01:00
|
|
|
DECLARE_MENU_EDIT_ITEM(float51);
|
2019-04-16 22:45:31 +02:00
|
|
|
DECLARE_MENU_EDIT_ITEM(float51sign);
|
2018-11-06 05:51:10 +01:00
|
|
|
DECLARE_MENU_EDIT_ITEM(float52sign);
|
|
|
|
DECLARE_MENU_EDIT_ITEM(long5);
|
2019-05-05 00:21:58 +02:00
|
|
|
DECLARE_MENU_EDIT_ITEM(long5_25);
|
2018-11-06 05:51:10 +01:00
|
|
|
|
2018-11-14 20:13:51 +01:00
|
|
|
class MenuItem_bool {
|
2018-11-06 05:51:10 +01:00
|
|
|
public:
|
2019-10-03 02:04:16 +02:00
|
|
|
static void action(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=nullptr);
|
2018-11-06 05:51:10 +01:00
|
|
|
};
|
2018-10-23 23:00:34 +02: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
|
|
|
|
*/
|
|
|
|
#define SCREEN_OR_MENU_LOOP() \
|
|
|
|
int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
|
2018-10-27 20:07:03 +02:00
|
|
|
for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
|
2018-10-23 23:00:34 +02: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.
|
|
|
|
*/
|
|
|
|
#define START_SCREEN() \
|
2018-10-27 20:07:03 +02:00
|
|
|
scroll_screen(LCD_HEIGHT, false); \
|
2018-10-23 23:00:34 +02:00
|
|
|
bool _skipStatic = false; \
|
|
|
|
SCREEN_OR_MENU_LOOP()
|
|
|
|
|
|
|
|
#define START_MENU() \
|
|
|
|
scroll_screen(1, true); \
|
|
|
|
bool _skipStatic = true; \
|
|
|
|
SCREEN_OR_MENU_LOOP()
|
|
|
|
|
|
|
|
#define END_SCREEN() \
|
|
|
|
} \
|
|
|
|
screen_items = _thisItemNr
|
|
|
|
|
|
|
|
#define END_MENU() \
|
|
|
|
} \
|
|
|
|
screen_items = _thisItemNr; \
|
|
|
|
UNUSED(_skipStatic)
|
|
|
|
|
|
|
|
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
2018-11-11 19:16:24 +01: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 23:00:34 +02:00
|
|
|
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
|
2018-11-11 19:16:24 +01:00
|
|
|
#else
|
2018-10-23 23:00:34 +02:00
|
|
|
#define ENCODER_RATE_MULTIPLY(F) NOOP
|
2018-11-06 05:51:10 +01:00
|
|
|
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
|
2018-11-11 19:16:24 +01:00
|
|
|
#endif
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
|
|
|
|
*
|
2019-10-03 02:04:16 +02:00
|
|
|
* draw_menu_item_<type>(sel, row, label, arg3...)
|
|
|
|
* MenuItem_<type>::action(arg3...)
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
* Examples:
|
2019-10-03 12:38:30 +02:00
|
|
|
* BACK_ITEM(MSG_WATCH)
|
|
|
|
* MENU_ITEM(back, MSG_WATCH)
|
2018-11-11 19:16:24 +01:00
|
|
|
* draw_menu_item_back(sel, row, PSTR(MSG_WATCH))
|
2018-11-14 20:13:51 +01:00
|
|
|
* MenuItem_back::action()
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
2019-10-03 12:38:30 +02:00
|
|
|
* ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
|
2018-10-23 23:00:34 +02:00
|
|
|
* MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
|
2018-11-11 19:16:24 +01:00
|
|
|
* draw_menu_item_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
|
2018-11-14 20:13:51 +01:00
|
|
|
* MenuItem_function::action(lcd_sdcard_pause)
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
2019-10-03 12:38:30 +02:00
|
|
|
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
2019-10-03 02:04:16 +02:00
|
|
|
* draw_menu_item_int3(sel, row, PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
|
|
|
|
* MenuItem_int3::action(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
|
2018-10-23 23:00:34 +02:00
|
|
|
*
|
|
|
|
*/
|
2019-10-03 02:04:16 +02:00
|
|
|
#define _MENU_ITEM_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
|
2019-10-01 05:56:12 +02:00
|
|
|
_skipStatic = false; \
|
|
|
|
if (_menuLineNr == _thisItemNr) { \
|
|
|
|
PGM_P const plabel = PLABEL; \
|
|
|
|
if (encoderLine == _thisItemNr && ui.use_click()) { \
|
|
|
|
_MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
|
2019-10-03 02:04:16 +02:00
|
|
|
MenuItem_##TYPE ::action(plabel, ##V); \
|
2019-10-01 05:56:12 +02:00
|
|
|
if (screen_changed) return; \
|
|
|
|
} \
|
|
|
|
if (ui.should_draw()) \
|
2019-10-03 02:04:16 +02:00
|
|
|
draw_menu_item_ ## TYPE \
|
2019-10-01 05:56:12 +02:00
|
|
|
(encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \
|
|
|
|
} \
|
|
|
|
++_thisItemNr; \
|
2018-11-06 05:51:10 +01:00
|
|
|
}while(0)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
// Used to print static text with no visible cursor.
|
|
|
|
// Parameters: label [, bool center [, bool invert [, char *value] ] ]
|
2019-10-01 05:56:12 +02:00
|
|
|
#define STATIC_ITEM_P(PLABEL, V...) do{ \
|
|
|
|
if (_menuLineNr == _thisItemNr) { \
|
|
|
|
if (_skipStatic && encoderLine <= _thisItemNr) { \
|
|
|
|
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
|
|
|
|
++encoderLine; \
|
|
|
|
} \
|
|
|
|
if (ui.should_draw()) \
|
|
|
|
draw_menu_item_static(_lcdLineNr, PLABEL, ##V); \
|
|
|
|
} \
|
|
|
|
++_thisItemNr; \
|
2018-11-06 05:51:10 +01:00
|
|
|
} while(0)
|
|
|
|
|
2019-03-17 11:57:25 +01:00
|
|
|
#define MENU_ITEM_ADDON_START(X) do{ \
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \
|
2018-11-06 05:51:10 +01:00
|
|
|
SETCURSOR(X, _lcdLineNr)
|
|
|
|
|
2019-03-17 11:57:25 +01:00
|
|
|
#define MENU_ITEM_ADDON_END() } }while(0)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2019-09-27 11:30:48 +02:00
|
|
|
#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P(PSTR(LABEL), ##V)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
2019-10-03 02:04:16 +02:00
|
|
|
#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
|
|
|
|
#define MENU_ITEM(TYPE, LABEL, V...) _MENU_ITEM_P(TYPE, false, PSTR(LABEL), ##V)
|
|
|
|
#define EDIT_ITEM(TYPE, LABEL, V...) _MENU_ITEM_P(TYPE, false, PSTR(LABEL), ##V)
|
|
|
|
#define EDIT_ITEM_FAST(TYPE, LABEL, V...) _MENU_ITEM_P(TYPE, true, PSTR(LABEL), ##V)
|
2019-10-03 12:38:30 +02:00
|
|
|
|
|
|
|
#define SKIP_ITEM() (_thisItemNr++)
|
|
|
|
#define BACK_ITEM(LABEL) MENU_ITEM(back,LABEL)
|
|
|
|
#define SUBMENU(LABEL, DEST) MENU_ITEM(submenu, LABEL, DEST)
|
|
|
|
#define GCODES_ITEM(LABEL, GCODES) MENU_ITEM(gcode, LABEL, GCODES)
|
|
|
|
#define ACTION_ITEM(LABEL, ACTION) MENU_ITEM(function, LABEL, ACTION)
|
2018-10-23 23:00:34 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////
|
|
|
|
/////////////// Menu Screens ///////////////
|
|
|
|
////////////////////////////////////////////
|
|
|
|
|
|
|
|
void menu_main();
|
|
|
|
void menu_move();
|
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT)
|
2019-08-15 00:52:14 +02:00
|
|
|
void menu_media();
|
2018-10-23 23:00:34 +02: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-17 05:43:06 +01:00
|
|
|
#define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LEVEL_BED_CORNERS)
|
2018-10-28 08:59:21 +01:00
|
|
|
|
|
|
|
#if HAS_LINE_TO_Z
|
|
|
|
void line_to_z(const float &z);
|
|
|
|
#endif
|
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
|
2019-06-19 07:00:19 +02:00
|
|
|
void lcd_enqueue_one_now(const char * const cmd);
|
|
|
|
void lcd_enqueue_one_now_P(PGM_P const cmd);
|
2018-10-23 23:00:34 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#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 19:16:24 +01:00
|
|
|
|
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
|
|
|
void menu_job_recovery();
|
|
|
|
#endif
|