Encapsulate common display code in a singleton (#12395)

* Encapsulate common LCD code in a singleton
* Depend more UBL code on UBL_DEVEL_DEBUGGING
  - Since most users don't need the debugging on at all times, this helps reduce the default build size for UBL by over 2K, a little closer to fitting on 128K boards.
This commit is contained in:
Scott Lahteine
2018-11-11 12:16:24 -06:00
committed by GitHub
parent 9da6809ac3
commit a0c795b097
65 changed files with 1881 additions and 1997 deletions

View File

@ -30,6 +30,7 @@
#include "../../module/motion.h"
#include "../../gcode/queue.h"
#include "../../sd/cardreader.h"
#include "../../libs/buzzer.h"
#if ENABLED(EEPROM_SETTINGS)
#include "../../module/configuration_store.h"
@ -61,10 +62,6 @@ menuPosition screen_history[6];
uint8_t screen_history_depth = 0;
bool screen_changed;
#if LCD_TIMEOUT_TO_STATUS
bool defer_return_to_status;
#endif
// Value Editing
PGM_P editLabel;
void *editValue;
@ -79,9 +76,9 @@ bool no_reentry = false;
//////// Menu Navigation & History /////////
////////////////////////////////////////////
void lcd_return_to_status() { lcd_goto_screen(lcd_status_screen); }
void MarlinUI::return_to_status() { goto_screen(status_screen); }
void lcd_save_previous_screen() {
void MarlinUI::save_previous_screen() {
if (screen_history_depth < COUNT(screen_history)) {
screen_history[screen_history_depth].menu_function = currentScreen;
screen_history[screen_history_depth].encoder_position = encoderPosition;
@ -89,25 +86,18 @@ void lcd_save_previous_screen() {
}
}
void lcd_goto_previous_menu() {
void MarlinUI::goto_previous_screen() {
if (screen_history_depth > 0) {
--screen_history_depth;
lcd_goto_screen(
goto_screen(
screen_history[screen_history_depth].menu_function,
screen_history[screen_history_depth].encoder_position
);
}
else
lcd_return_to_status();
return_to_status();
}
#if LCD_TIMEOUT_TO_STATUS
void lcd_goto_previous_menu_no_defer() {
set_defer_return_to_status(false);
lcd_goto_previous_menu();
}
#endif
////////////////////////////////////////////
/////////// Common Menu Actions ////////////
////////////////////////////////////////////
@ -142,34 +132,33 @@ void menu_item_gcode::action(PGM_P pgcode) { enqueue_and_echo_commands_P(pgcode)
* ...which calls:
* menu_item_int3::action_setting_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
*/
void menu_item_invariants::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
ENCODER_DIRECTION_NORMAL();
if ((int32_t)encoderPosition < 0) encoderPosition = 0;
if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue;
if (lcdDrawUpdate)
lcd_implementation_drawedit(editLabel, strfunc(encoderPosition + minEditValue));
if (lcd_clicked || (liveEdit && lcdDrawUpdate)) {
if (editValue != NULL) loadfunc(editValue, encoderPosition + minEditValue);
if (callbackFunc && (liveEdit || lcd_clicked)) (*callbackFunc)();
if (lcd_clicked) lcd_goto_previous_menu();
lcd_clicked = false;
void MenuItemBase::edit(strfunc_t strfunc, loadfunc_t loadfunc) {
ui.encoder_direction_normal();
if ((int32_t)ui.encoderPosition < 0) ui.encoderPosition = 0;
if ((int32_t)ui.encoderPosition > maxEditValue) ui.encoderPosition = maxEditValue;
if (ui.should_draw())
draw_edit_screen(editLabel, strfunc(ui.encoderPosition + minEditValue));
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
if (editValue != NULL) loadfunc(editValue, ui.encoderPosition + minEditValue);
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
if (ui.use_click()) ui.goto_previous_screen();
}
}
void menu_item_invariants::init(PGM_P const el, void * const ev, const int32_t minv, const int32_t maxv, const uint32_t ep, const screenFunc_t cs, const screenFunc_t cb, const bool le) {
lcd_save_previous_screen();
lcd_refresh();
void MenuItemBase::init(PGM_P const el, void * const ev, const int32_t minv, const int32_t maxv, const uint32_t ep, const screenFunc_t cs, const screenFunc_t cb, const bool le) {
ui.save_previous_screen();
ui.refresh();
editLabel = el;
editValue = ev;
minEditValue = minv;
maxEditValue = maxv;
encoderPosition = ep;
currentScreen = cs;
ui.encoderPosition = ep;
ui.currentScreen = cs;
callbackFunc = cb;
liveEdit = le;
}
#define DEFINE_MENU_EDIT_ITEM(NAME) template class menu_item_template<NAME ## _item_info>;
#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuItem<NAME ## _item_info>;
DEFINE_MENU_EDIT_ITEM(int3);
DEFINE_MENU_EDIT_ITEM(int4);
@ -184,7 +173,7 @@ DEFINE_MENU_EDIT_ITEM(float62);
DEFINE_MENU_EDIT_ITEM(long5);
void menu_item_bool::action_setting_edit(PGM_P pstr, bool *ptr, screenFunc_t callback) {
UNUSED(pstr); *ptr ^= true; lcd_refresh();
UNUSED(pstr); *ptr ^= true; ui.refresh();
if (callback) (*callback)();
}
@ -202,7 +191,7 @@ bool printer_busy() { return planner.movesplanned() || IS_SD_PRINTING(); }
/**
* General function to go directly to a screen
*/
void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
void MarlinUI::goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
if (currentScreen != screen) {
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
@ -215,10 +204,10 @@ void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
// Going to menu_main from status screen? Remember first click time.
// Going back to status screen within a very short time? Go to Z babystepping.
if (screen == menu_main) {
if (currentScreen == lcd_status_screen)
if (on_status_screen())
doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
}
else if (screen == lcd_status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
if (printer_busy()) {
screen =
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
@ -239,25 +228,25 @@ void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
currentScreen = screen;
encoderPosition = encoder;
if (screen == lcd_status_screen) {
set_defer_return_to_status(false);
if (screen == status_screen) {
ui.defer_status_screen(false);
#if ENABLED(AUTO_BED_LEVELING_UBL)
ubl.lcd_map_control = false;
#endif
screen_history_depth = 0;
}
lcd_implementation_clear();
clear_lcd();
// Re-initialize custom characters that may be re-used
#if HAS_CHARACTER_LCD
#if ENABLED(AUTO_BED_LEVELING_UBL)
if (!ubl.lcd_map_control)
#endif
LCD_SET_CHARSET(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
LCD_SET_CHARSET(screen == status_screen ? CHARSET_INFO : CHARSET_MENU);
#endif
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
refresh(LCDVIEW_CALL_REDRAW_NEXT);
screen_changed = true;
#if HAS_GRAPHICAL_LCD
drawing_screen = false;
@ -276,24 +265,24 @@ void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder/*=0*/) {
//
static PGM_P sync_message;
void _lcd_synchronize() {
if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
void MarlinUI::_synchronize() {
if (should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, sync_message);
if (no_reentry) return;
// Make this the current handler till all moves are done
no_reentry = true;
const screenFunc_t old_screen = currentScreen;
lcd_goto_screen(_lcd_synchronize);
goto_screen(_synchronize);
planner.synchronize(); // idle() is called until moves complete
no_reentry = false;
lcd_goto_screen(old_screen);
goto_screen(old_screen);
}
// Display the synchronize screen with a custom message
// ** This blocks the command queue! **
void lcd_synchronize(PGM_P const msg/*=NULL*/) {
void MarlinUI::synchronize(PGM_P const msg/*=NULL*/) {
static const char moving[] PROGMEM = MSG_MOVING;
sync_message = msg ? msg : moving;
_lcd_synchronize();
_synchronize();
}
/**
@ -308,16 +297,16 @@ void lcd_synchronize(PGM_P const msg/*=NULL*/) {
*/
int8_t encoderLine, screen_items;
void scroll_screen(const uint8_t limit, const bool is_menu) {
ENCODER_DIRECTION_MENUS();
ui.encoder_direction_menus();
ENCODER_RATE_MULTIPLY(false);
if (encoderPosition > 0x8000) encoderPosition = 0;
if (first_page) {
encoderLine = encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
if (ui.encoderPosition > 0x8000) ui.encoderPosition = 0;
if (ui.first_page) {
encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
screen_changed = false;
}
if (screen_items > 0 && encoderLine >= screen_items - limit) {
encoderLine = MAX(0, screen_items - limit);
encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
ui.encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
}
if (is_menu) {
NOMORE(encoderTopLine, encoderLine);
@ -328,12 +317,12 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
encoderTopLine = encoderLine;
}
void lcd_completion_feedback(const bool good/*=true*/) {
void MarlinUI::completion_feedback(const bool good/*=true*/) {
if (good) {
lcd_buzz(100, 659);
lcd_buzz(100, 698);
BUZZ(100, 659);
BUZZ(100, 698);
}
else lcd_buzz(20, 440);
else BUZZ(20, 440);
}
#if HAS_LINE_TO_Z
@ -348,17 +337,17 @@ void lcd_completion_feedback(const bool good/*=true*/) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
void lcd_babystep_zoffset() {
if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
set_defer_return_to_status(true);
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
ui.defer_status_screen(true);
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
const bool do_probe = (active_extruder == 0);
#else
constexpr bool do_probe = true;
#endif
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
encoderPosition = 0;
ui.encoder_direction_normal();
if (ui.encoderPosition) {
const int16_t babystep_increment = (int32_t)ui.encoderPosition * (BABYSTEP_MULTIPLICATOR);
ui.encoderPosition = 0;
const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
new_probe_offset = zprobe_zoffset + diff,
@ -378,16 +367,16 @@ void lcd_completion_feedback(const bool good/*=true*/) {
else hotend_offset[Z_AXIS][active_extruder] = new_offs;
#endif
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
}
}
if (lcdDrawUpdate) {
if (ui.should_draw()) {
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
if (!do_probe)
lcd_implementation_drawedit(PSTR(MSG_IDEX_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
draw_edit_screen(PSTR(MSG_IDEX_Z_OFFSET), ftostr43sign(hotend_offset[Z_AXIS][active_extruder]));
else
#endif
lcd_implementation_drawedit(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
draw_edit_screen(PSTR(MSG_ZPROBE_ZOFFSET), ftostr43sign(zprobe_zoffset));
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
if (do_probe) _lcd_zoffset_overlay_gfx(zprobe_zoffset);
@ -447,14 +436,14 @@ void watch_temp_callback_bed() {
#endif
#if ENABLED(EEPROM_SETTINGS)
void lcd_store_settings() { lcd_completion_feedback(settings.save()); }
void lcd_load_settings() { lcd_completion_feedback(settings.load()); }
void lcd_store_settings() { ui.completion_feedback(settings.save()); }
void lcd_load_settings() { ui.completion_feedback(settings.load()); }
#endif
void _lcd_draw_homing() {
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
if (lcdDrawUpdate) lcd_implementation_drawmenu_static(line, PSTR(MSG_LEVEL_BED_HOMING));
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
if (ui.should_draw()) draw_menu_item_static(line, PSTR(MSG_LEVEL_BED_HOMING));
ui.refresh(LCDVIEW_CALL_NO_REDRAW);
}
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))

View File

@ -31,14 +31,6 @@ constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, H
void scroll_screen(const uint8_t limit, const bool is_menu);
bool printer_busy();
void lcd_completion_feedback(const bool good=true);
void lcd_save_previous_screen();
void lcd_goto_previous_menu();
#if LCD_TIMEOUT_TO_STATUS
void lcd_goto_previous_menu_no_defer();
#else
#define lcd_goto_previous_menu_no_defer() lcd_goto_previous_menu()
#endif
////////////////////////////////////////////
////////// Menu Item Numeric Types /////////
@ -67,60 +59,46 @@ DECLARE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f);
///////// Menu Item Draw Functions /////////
////////////////////////////////////////////
void draw_menu_item_generic(const bool isSelected, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const bool center=true, const bool invert=false, const char *valstr=NULL);
void draw_edit_screen(PGM_P const pstr, const char* const value=NULL);
#if ENABLED(SDSUPPORT)
class CardReader;
#endif
void lcd_implementation_drawmenu_generic(const bool isSelected, const uint8_t row, const char* pstr, const char pre_char, const char post_char);
void lcd_implementation_drawmenu_static(const uint8_t row, const char* pstr, const bool center=true, const bool invert=false, const char *valstr=NULL);
void lcd_implementation_drawedit(const char* const pstr, const char* const value=NULL);
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void lcd_implementation_hotend_status(const uint8_t row, const uint8_t extruder);
void draw_sd_menu_item(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
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); }
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); }
#endif
#if HAS_GRAPHICAL_LCD
void _drawmenu_setting_edit_generic(const bool isSelected, const uint8_t row, const char* pstr, const char* const data, const bool pgm);
#define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
#define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
#define DRAWMENU_SETTING_EDIT_GENERIC(SRC) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, SRC)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
#if ENABLED(SDSUPPORT)
void _drawmenu_sd(const bool isSelected, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, false)
#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, theCard) _drawmenu_sd(sel, row, pstr, theCard, true)
#endif
#define draw_menu_item_back(sel, row, pstr) draw_menu_item_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define draw_menu_item_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
#define draw_menu_item_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
#define DRAWMENU_SETTING_EDIT_GENERIC(SRC) draw_menu_item_setting_edit_generic(sel, row, pstr, SRC)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY) || ENABLED(MESH_EDIT_GFX_OVERLAY)
void _lcd_zoffset_overlay_gfx(const float zvalue);
#endif
#else
#define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_UPLEVEL_CHAR, LCD_UPLEVEL_CHAR)
void lcd_implementation_drawmenu_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
void lcd_implementation_drawmenu_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
#define DRAWMENU_SETTING_EDIT_GENERIC(SRC) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', SRC)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
#if ENABLED(SDSUPPORT)
void lcd_implementation_drawmenu_sdfile(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard);
void lcd_implementation_drawmenu_sddirectory(const bool sel, const uint8_t row, PGM_P pstr, CardReader &theCard);
#endif
#endif
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#if ENABLED(AUTO_BED_LEVELING_UBL)
void lcd_implementation_ubl_plot(const uint8_t x, const uint8_t inverted_y);
#define draw_menu_item_back(sel, row, pstr) draw_menu_item_generic(sel, row, pstr, LCD_UPLEVEL_CHAR, LCD_UPLEVEL_CHAR)
void draw_menu_item_setting_edit_generic(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
void draw_menu_item_setting_edit_generic_P(const bool sel, const uint8_t row, const char* pstr, const char pre_char, const char* const data);
#define DRAWMENU_SETTING_EDIT_GENERIC(SRC) draw_menu_item_setting_edit_generic(sel, row, pstr, '>', SRC)
#define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_setting_edit_generic_P(sel, row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
#endif
#define draw_menu_item_submenu(sel, row, pstr, data) draw_menu_item_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define draw_menu_item_gcode(sel, row, pstr, gcode) draw_menu_item_generic(sel, row, pstr, '>', ' ')
#define draw_menu_item_function(sel, row, pstr, data) draw_menu_item_generic(sel, row, pstr, '>', ' ')
////////////////////////////////////////////
/////// Edit Setting Draw Functions ////////
////////////////////////////////////////////
#define _DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(TYPE, NAME, STRFUNC) \
FORCE_INLINE void lcd_implementation_drawmenu_setting_edit_ ## NAME (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, TYPE * const data, ...) { \
FORCE_INLINE void draw_menu_item_setting_edit_ ## NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE * const data, ...) { \
UNUSED(pstr2); \
DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \
} \
FORCE_INLINE void lcd_implementation_drawmenu_setting_edit_accessor_ ## NAME (const bool sel, const uint8_t row, PGM_P pstr, PGM_P pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \
FORCE_INLINE void draw_menu_item_setting_edit_accessor_ ## NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \
UNUSED(pstr2); UNUSED(pset); \
DRAWMENU_SETTING_EDIT_GENERIC(STRFUNC(pget())); \
} \
@ -139,8 +117,8 @@ DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float52sign);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float62);
DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(long5);
#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data, ...) DRAW_BOOL_SETTING(sel, row, pstr, data)
#define lcd_implementation_drawmenu_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
#define draw_menu_item_setting_edit_bool(sel, row, pstr, pstr2, data, ...) DRAW_BOOL_SETTING(sel, row, pstr, data)
#define draw_menu_item_setting_edit_accessor_bool(sel, row, pstr, pstr2, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
////////////////////////////////////////////
/////////////// Menu Actions ///////////////
@ -148,12 +126,12 @@ DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(long5);
class menu_item_back {
public:
static inline void action() { lcd_goto_previous_menu(); }
static inline void action() { ui.goto_previous_screen(); }
};
class menu_item_submenu {
public:
static inline void action(const screenFunc_t func) { lcd_save_previous_screen(); lcd_goto_screen(func); }
static inline void action(const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
};
class menu_item_gcode {
@ -170,7 +148,7 @@ class menu_item_function {
/////////// Menu Editing Actions ///////////
////////////////////////////////////////////
class menu_item_invariants {
class MenuItemBase {
protected:
typedef char* (*strfunc_t)(const int32_t);
typedef void (*loadfunc_t)(void *, const int32_t);
@ -179,7 +157,7 @@ class menu_item_invariants {
};
template<typename NAME>
class menu_item_template : menu_item_invariants {
class TMenuItem : MenuItemBase {
private:
typedef typename NAME::type_t type_t;
inline static float unscale(const float value) {return value * (1.0f / NAME::scale);}
@ -191,10 +169,10 @@ class menu_item_template : menu_item_invariants {
const int32_t minv = scale(minValue);
init(pstr, ptr, minv, int32_t(scale(maxValue)) - minv, int32_t(scale(*ptr)) - minv, edit, callback, live);
}
static void edit() {menu_item_invariants::edit(to_string, load);}
static void edit() { MenuItemBase::edit(to_string, load); }
};
#define DECLARE_MENU_EDIT_ITEM(NAME) typedef menu_item_template<NAME ## _item_info> menu_item_ ## NAME;
#define DECLARE_MENU_EDIT_ITEM(NAME) typedef TMenuItem<NAME ## _item_info> menu_item_ ## NAME;
DECLARE_MENU_EDIT_ITEM(int3);
DECLARE_MENU_EDIT_ITEM(int4);
@ -210,7 +188,7 @@ DECLARE_MENU_EDIT_ITEM(long5);
class menu_item_bool {
public:
static void action_setting_edit(PGM_P pstr, bool* ptr, const screenFunc_t callbackFunc=NULL);
static void action_setting_edit(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=NULL);
};
////////////////////////////////////////////
@ -256,69 +234,47 @@ class menu_item_bool {
screen_items = _thisItemNr; \
UNUSED(_skipStatic)
/**
* REVERSE_MENU_DIRECTION
*
* To reverse the menu direction we need a general way to reverse
* the direction of the encoder everywhere. So encoderDirection is
* added to allow the encoder to go the other way.
*
* This behavior is limited to scrolling Menus and SD card listings,
* and is disabled in other contexts.
*/
#if ENABLED(REVERSE_MENU_DIRECTION)
extern int8_t encoderDirection;
#define ENCODER_DIRECTION_NORMAL() (encoderDirection = 1)
#define ENCODER_DIRECTION_MENUS() (encoderDirection = -1)
#else
#define ENCODER_DIRECTION_NORMAL() NOOP
#define ENCODER_DIRECTION_MENUS() NOOP
#endif
#if ENABLED(ENCODER_RATE_MULTIPLIER)
extern millis_t lastEncoderMovementMillis;
extern bool encoderRateMultiplierEnabled;
#define ENCODER_RATE_MULTIPLY(F) (encoderRateMultiplierEnabled = F)
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) if (USE_MULTIPLIER) { encoderRateMultiplierEnabled = true; lastEncoderMovementMillis = 0; }
#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)
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
#else // !ENCODER_RATE_MULTIPLIER
#else
#define ENCODER_RATE_MULTIPLY(F) NOOP
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
#endif // !ENCODER_RATE_MULTIPLIER
#endif
/**
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
*
* lcd_implementation_drawmenu_<type>[_variant](sel, row, label, arg3...)
* draw_menu_item_<type>[_variant](sel, row, label, arg3...)
* menu_item_<type>::action[_variant](arg3...)
*
* Examples:
* MENU_ITEM(back, MSG_WATCH, 0 [dummy parameter] )
* or
* MENU_BACK(MSG_WATCH)
* lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH))
* draw_menu_item_back(sel, row, PSTR(MSG_WATCH))
* menu_item_back::action()
*
* MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
* lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
* draw_menu_item_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
* menu_item_function::action(lcd_sdcard_pause)
*
* MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
* lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
* draw_menu_item_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
* menu_item_int3::action_setting_edit(PSTR(MSG_SPEED), &feedrate_percentage, 10, 999)
*
*/
#define _MENU_ITEM_VARIANT_P(TYPE, VARIANT, USE_MULTIPLIER, PLABEL, ...) do { \
_skipStatic = false; \
if (_menuLineNr == _thisItemNr) { \
if (encoderLine == _thisItemNr && lcd_clicked) { \
lcd_clicked = false; \
if (encoderLine == _thisItemNr && ui.use_click()) { \
_MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
menu_item_ ## TYPE ::action ## VARIANT(__VA_ARGS__); \
if (screen_changed) return; \
} \
if (lcdDrawUpdate) \
lcd_implementation_drawmenu ## VARIANT ## _ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ## __VA_ARGS__); \
if (ui.should_draw()) \
draw_menu_item ## VARIANT ## _ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ## __VA_ARGS__); \
} \
++_thisItemNr; \
}while(0)
@ -328,17 +284,17 @@ class menu_item_bool {
#define STATIC_ITEM_P(PLABEL, ...) do{ \
if (_menuLineNr == _thisItemNr) { \
if (_skipStatic && encoderLine <= _thisItemNr) { \
encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
++encoderLine; \
} \
if (lcdDrawUpdate) \
lcd_implementation_drawmenu_static(_lcdLineNr, PLABEL, ## __VA_ARGS__); \
if (ui.should_draw()) \
draw_menu_item_static(_lcdLineNr, PLABEL, ## __VA_ARGS__); \
} \
++_thisItemNr; \
} while(0)
#define MENU_ITEM_ADDON_START(X) \
if (lcdDrawUpdate && _menuLineNr == _thisItemNr - 1) { \
if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \
SETCURSOR(X, _lcdLineNr)
#define MENU_ITEM_ADDON_END() } (0)
@ -347,12 +303,12 @@ class menu_item_bool {
#define MENU_BACK(LABEL) MENU_ITEM(back, LABEL)
#define MENU_ITEM_DUMMY() do { _thisItemNr++; }while(0)
#define MENU_ITEM_P(TYPE, PLABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , 0, PLABEL, ## __VA_ARGS__)
#define MENU_ITEM(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , 0, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 0, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 0, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 1, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, 1, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_P(TYPE, PLABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PLABEL, ## __VA_ARGS__)
#define MENU_ITEM(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, , false, PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, false, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_MULTIPLIER_ITEM_EDIT(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(TYPE, LABEL, ...) _MENU_ITEM_VARIANT_P(TYPE, _setting_edit, true, PSTR(LABEL), PSTR(LABEL), ## __VA_ARGS__)
////////////////////////////////////////////
/////////////// Menu Screens ///////////////
@ -379,7 +335,6 @@ void menu_move();
////////////////////////////////////////////
void lcd_move_z();
void lcd_synchronize(PGM_P const msg=NULL);
void _lcd_draw_homing();
void watch_temp_callback_E0();
@ -426,3 +381,7 @@ void watch_temp_callback_bed();
void lcd_store_settings();
void lcd_load_settings();
#endif
#if ENABLED(POWER_LOSS_RECOVERY)
void menu_job_recovery();
#endif

View File

@ -52,7 +52,7 @@
//
void _lcd_set_home_offsets() {
enqueue_and_echo_commands_P(PSTR("M428"));
lcd_return_to_status();
ui.return_to_status();
}
#endif
@ -65,9 +65,9 @@
//
static void _lcd_toggle_sd_update() {
const bool new_state = !settings.sd_update_status();
lcd_completion_feedback(settings.set_sd_update_status(new_state));
lcd_return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else lcd_reset_status();
ui.completion_feedback(settings.set_sd_update_status(new_state));
ui.return_to_status();
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
}
#endif
@ -539,8 +539,8 @@ void menu_advanced_temperature() {
#include "../../module/configuration_store.h"
static void lcd_init_eeprom() {
lcd_completion_feedback(settings.init_eeprom());
lcd_goto_previous_menu();
ui.completion_feedback(settings.init_eeprom());
ui.goto_previous_screen();
}
static void lcd_init_eeprom_confirm() {

View File

@ -77,7 +77,7 @@ void menu_level_bed_corners() {
MSG_NEXT_CORNER
#endif
, _lcd_goto_next_corner);
MENU_ITEM(function, MSG_BACK, lcd_goto_previous_menu_no_defer);
MENU_ITEM(function, MSG_BACK, ui.goto_previous_screen_no_defer);
END_MENU();
}
@ -85,18 +85,18 @@ void _lcd_level_bed_corners_homing() {
_lcd_draw_homing();
if (all_axes_homed()) {
bed_corner = 0;
lcd_goto_screen(menu_level_bed_corners);
ui.goto_screen(menu_level_bed_corners);
_lcd_goto_next_corner();
}
}
void _lcd_level_bed_corners() {
set_defer_return_to_status(true);
ui.defer_status_screen(true);
if (!all_axes_known()) {
set_all_unhomed();
enqueue_and_echo_commands_P(PSTR("G28"));
}
lcd_goto_screen(_lcd_level_bed_corners_homing);
ui.goto_screen(_lcd_level_bed_corners_homing);
}
#endif // HAS_LCD_MENU && LEVEL_BED_CORNERS

View File

@ -26,7 +26,7 @@
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU && ENABLED(LCD_BED_LEVELING)
#if ENABLED(LCD_BED_LEVELING)
#include "menu.h"
#include "../../module/planner.h"
@ -56,7 +56,7 @@
#endif
);
bool lcd_wait_for_move;
bool MarlinUI::wait_for_bl_move; // = false
//
// Bed leveling is done. Wait for G29 to complete.
@ -70,17 +70,17 @@
// ** This blocks the command queue! **
//
void _lcd_level_bed_done() {
if (!lcd_wait_for_move) {
if (!ui.wait_for_bl_move) {
#if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
// Display "Done" screen and wait for moves to complete
line_to_z(MANUAL_PROBE_HEIGHT);
lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
ui.synchronize(PSTR(MSG_LEVEL_BED_DONE));
#endif
lcd_goto_previous_menu_no_defer();
lcd_completion_feedback();
ui.goto_previous_screen_no_defer();
ui.completion_feedback();
}
if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
if (ui.should_draw()) draw_menu_item_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
}
void _lcd_level_goto_next_point();
@ -89,9 +89,9 @@
// Step 7: Get the Z coordinate, click goes to the next point or exits
//
void _lcd_level_bed_get_z() {
ENCODER_DIRECTION_NORMAL();
ui.encoder_direction_normal();
if (use_click()) {
if (ui.use_click()) {
//
// Save the current Z position and move
@ -102,8 +102,8 @@
//
// The last G29 records the point and enables bed leveling
//
lcd_wait_for_move = true;
lcd_goto_screen(_lcd_level_bed_done);
ui.wait_for_bl_move = true;
ui.goto_screen(_lcd_level_bed_done);
#if ENABLED(MESH_BED_LEVELING)
enqueue_and_echo_commands_P(PSTR("G29 S2"));
#elif ENABLED(PROBE_MANUALLY)
@ -119,19 +119,19 @@
//
// Encoder knob or keypad buttons adjust the Z position
//
if (encoderPosition) {
const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MESH_EDIT_Z_STEP);
if (ui.encoderPosition) {
const float z = current_position[Z_AXIS] + float((int32_t)ui.encoderPosition) * (MESH_EDIT_Z_STEP);
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
encoderPosition = 0;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
ui.encoderPosition = 0;
}
//
// Draw on first display, then only on Z change
//
if (lcdDrawUpdate) {
if (ui.should_draw()) {
const float v = current_position[Z_AXIS];
lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
draw_edit_screen(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
}
}
@ -139,23 +139,23 @@
// Step 6: Display "Next point: 1 / 9" while waiting for move to finish
//
void _lcd_level_bed_moving() {
if (lcdDrawUpdate) {
if (ui.should_draw()) {
char msg[10];
sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
draw_edit_screen(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
}
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
ui.refresh(LCDVIEW_CALL_NO_REDRAW);
if (!ui.wait_for_bl_move) ui.goto_screen(_lcd_level_bed_get_z);
}
//
// Step 5: Initiate a move to the next point
//
void _lcd_level_goto_next_point() {
lcd_goto_screen(_lcd_level_bed_moving);
ui.goto_screen(_lcd_level_bed_moving);
// G29 Records Z, moves, and signals when it pauses
lcd_wait_for_move = true;
ui.wait_for_bl_move = true;
#if ENABLED(MESH_BED_LEVELING)
enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
#elif ENABLED(PROBE_MANUALLY)
@ -168,8 +168,8 @@
// Move to the first probe position
//
void _lcd_level_bed_homing_done() {
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
if (use_click()) {
if (ui.should_draw()) draw_edit_screen(PSTR(MSG_LEVEL_BED_WAITING));
if (ui.use_click()) {
manual_probe_index = 0;
_lcd_level_goto_next_point();
}
@ -180,7 +180,7 @@
//
void _lcd_level_bed_homing() {
_lcd_draw_homing();
if (all_axes_homed()) lcd_goto_screen(_lcd_level_bed_homing_done);
if (all_axes_homed()) ui.goto_screen(_lcd_level_bed_homing_done);
}
#if ENABLED(PROBE_MANUALLY)
@ -191,9 +191,9 @@
// Step 2: Continue Bed Leveling...
//
void _lcd_level_bed_continue() {
set_defer_return_to_status(true);
ui.defer_status_screen(true);
set_all_unhomed();
lcd_goto_screen(_lcd_level_bed_homing);
ui.goto_screen(_lcd_level_bed_homing);
enqueue_and_echo_commands_P(PSTR("G28"));
}
@ -292,4 +292,4 @@ void menu_bed_leveling() {
END_MENU();
}
#endif // HAS_LCD_MENU && LCD_BED_LEVELING
#endif // LCD_BED_LEVELING

View File

@ -41,35 +41,31 @@
void menu_advanced_settings();
void menu_delta_calibrate();
#if HAS_LCD_CONTRAST
void lcd_callback_set_contrast() { set_lcd_contrast(lcd_contrast); }
#endif
static void lcd_factory_settings() {
settings.reset();
lcd_completion_feedback();
ui.completion_feedback();
}
#if ENABLED(LCD_PROGRESS_BAR_TEST)
static void progress_bar_test() {
static int8_t bar_percent = 0;
if (use_click()) {
lcd_goto_previous_menu();
if (ui.use_click()) {
ui.goto_previous_screen();
LCD_SET_CHARSET(CHARSET_MENU);
return;
}
bar_percent += (int8_t)encoderPosition;
bar_percent += (int8_t)ui.encoderPosition;
bar_percent = constrain(bar_percent, 0, 100);
encoderPosition = 0;
lcd_implementation_drawmenu_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
ui.encoderPosition = 0;
draw_menu_item_static(0, PSTR(MSG_PROGRESS_BAR_TEST), true, true);
lcd_moveto((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2);
lcd_put_u8str(int(bar_percent)); lcd_put_wchar('%');
lcd_moveto(0, LCD_HEIGHT - 1); lcd_draw_progress_bar(bar_percent);
}
void _progress_bar_test() {
lcd_goto_screen(progress_bar_test);
ui.goto_screen(progress_bar_test);
LCD_SET_CHARSET(CHARSET_INFO);
}
@ -271,12 +267,12 @@ static void lcd_factory_settings() {
#endif
START_MENU();
MENU_BACK(MSG_CONFIGURATION);
MENU_ITEM_EDIT(int8, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
MENU_ITEM_EDIT(int8, MSG_FAN_SPEED, &ui.preheat_fan_speed[material], 0, 255);
#if HAS_TEMP_HOTEND
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &ui.preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
#endif
#if HAS_HEATED_BED
MENU_ITEM_EDIT(int3, MSG_BED, &lcd_preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
MENU_ITEM_EDIT(int3, MSG_BED, &ui.preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 15);
#endif
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(function, MSG_STORE_EEPROM, lcd_store_settings);
@ -338,7 +334,7 @@ void menu_configuration() {
#endif
#if HAS_LCD_CONTRAST
MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &lcd_contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, lcd_callback_set_contrast, true);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
#endif
#if ENABLED(FWRETRACT)
MENU_ITEM(submenu, MSG_RETRACT, menu_config_retract);

View File

@ -40,10 +40,10 @@
void _lcd_user_gcode(PGM_P const cmd) {
enqueue_and_echo_commands_P(cmd);
#if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK)
lcd_completion_feedback();
ui.completion_feedback();
#endif
#if ENABLED(USER_SCRIPT_RETURN)
lcd_return_to_status();
ui.return_to_status();
#endif
}

View File

@ -38,9 +38,9 @@
void _man_probe_pt(const float &rx, const float &ry) {
do_blocking_move_to(rx, ry, Z_CLEARANCE_BETWEEN_PROBES);
lcd_synchronize();
ui.synchronize();
move_menu_scale = MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
lcd_goto_screen(lcd_move_z);
ui.goto_screen(lcd_move_z);
}
#if ENABLED(DELTA_AUTO_CALIBRATION)
@ -50,11 +50,11 @@ void _man_probe_pt(const float &rx, const float &ry) {
float lcd_probe_pt(const float &rx, const float &ry) {
_man_probe_pt(rx, ry);
KEEPALIVE_STATE(PAUSED_FOR_USER);
set_defer_return_to_status(true);
ui.defer_status_screen(true);
wait_for_user = true;
while (wait_for_user) idle();
KEEPALIVE_STATE(IN_HANDLER);
lcd_goto_previous_menu_no_defer();
ui.goto_previous_screen_no_defer();
return current_position[Z_AXIS];
}
@ -66,12 +66,12 @@ void _man_probe_pt(const float &rx, const float &ry) {
void _lcd_calibrate_homing() {
_lcd_draw_homing();
if (all_axes_homed()) lcd_goto_previous_menu();
if (all_axes_homed()) ui.goto_previous_screen();
}
void _lcd_delta_calibrate_home() {
enqueue_and_echo_commands_P(PSTR("G28"));
lcd_goto_screen(_lcd_calibrate_homing);
ui.goto_screen(_lcd_calibrate_homing);
}
void _goto_tower_x() { _man_probe_pt(cos(RADIANS(210)) * delta_calibration_radius, sin(RADIANS(210)) * delta_calibration_radius); }

View File

@ -323,15 +323,15 @@ static PGM_P advanced_pause_header() {
// Portions from STATIC_ITEM...
#define HOTEND_STATUS_ITEM() do { \
if (_menuLineNr == _thisItemNr) { \
if (lcdDrawUpdate) { \
lcd_implementation_drawmenu_static(_lcdLineNr, PSTR(MSG_FILAMENT_CHANGE_NOZZLE), false, true); \
lcd_implementation_hotend_status(_lcdLineNr, hotend_status_extruder); \
if (ui.should_draw()) { \
draw_menu_item_static(_lcdLineNr, PSTR(MSG_FILAMENT_CHANGE_NOZZLE), false, true); \
ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \
} \
if (_skipStatic && encoderLine <= _thisItemNr) { \
encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
++encoderLine; \
} \
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); \
} \
++_thisItemNr; \
}while(0)
@ -507,11 +507,11 @@ void lcd_advanced_pause_show_message(
hotend_status_extruder = extruder;
const screenFunc_t next_screen = ap_message_screen(message);
if (next_screen) {
set_defer_return_to_status(true);
lcd_goto_screen(next_screen);
ui.defer_status_screen(true);
ui.goto_screen(next_screen);
}
else
lcd_return_to_status();
ui.return_to_status();
}
#endif // HAS_LCD_MENU && ADVANCED_PAUSE_FEATURE

View File

@ -47,7 +47,7 @@
// About Printer > Printer Stats
//
void menu_info_stats() {
if (use_click()) { return lcd_goto_previous_menu(); }
if (ui.use_click()) return ui.goto_previous_screen();
char buffer[21];
printStatistics stats = print_job_timer.getStats();
@ -80,7 +80,7 @@
// About Printer > Thermistors
//
void menu_info_thermistors() {
if (use_click()) { return lcd_goto_previous_menu(); }
if (ui.use_click()) return ui.goto_previous_screen();
START_SCREEN();
#define THERMISTOR_ID TEMP_SENSOR_0
#include "../thermistornames.h"
@ -139,7 +139,7 @@ void menu_info_thermistors() {
// About Printer > Board Info
//
void menu_info_board() {
if (use_click()) { return lcd_goto_previous_menu(); }
if (ui.use_click()) return ui.goto_previous_screen();
START_SCREEN();
STATIC_ITEM(BOARD_NAME, true, true); // MyPrinterController
STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE), true); // Baud: 250000
@ -158,7 +158,7 @@ void menu_info_board() {
// About Printer > Printer Info
//
void menu_info_printer() {
if (use_click()) { return lcd_goto_previous_menu(); }
if (ui.use_click()) return ui.goto_previous_screen();
START_SCREEN();
STATIC_ITEM(MSG_MARLIN, true, true); // Marlin
STATIC_ITEM(SHORT_BUILD_VERSION, true); // x.x.x-Branch

View File

@ -37,7 +37,7 @@ static void lcd_power_loss_recovery_resume() {
char cmd[20];
// Return to status now
lcd_return_to_status();
ui.return_to_status();
// Turn leveling off and home
enqueue_and_echo_commands_P(PSTR("M420 S0\nG28 R0"
@ -91,11 +91,11 @@ static void lcd_power_loss_recovery_resume() {
static void lcd_power_loss_recovery_cancel() {
card.removeJobRecoveryFile();
card.autostart_index = 0;
lcd_return_to_status();
ui.return_to_status();
}
void menu_job_recovery() {
set_defer_return_to_status(true);
ui.defer_status_screen(true);
START_MENU();
STATIC_ITEM(MSG_POWER_LOSS_RECOVERY);
MENU_ITEM(function, MSG_RESUME_PRINT, lcd_power_loss_recovery_resume);

View File

@ -43,7 +43,7 @@
#if ENABLED(PARK_HEAD_ON_PAUSE)
enqueue_and_echo_commands_P(PSTR("M125"));
#endif
lcd_reset_status();
ui.reset_status();
}
void lcd_sdcard_resume() {
@ -53,14 +53,14 @@
card.startFileprint();
print_job_timer.start();
#endif
lcd_reset_status();
ui.reset_status();
}
void lcd_sdcard_stop() {
wait_for_heatup = wait_for_user = false;
card.abort_sd_printing = true;
lcd_setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
lcd_return_to_status();
ui.setstatusPGM(PSTR(MSG_PRINT_ABORTED), -1);
ui.return_to_status();
}
#if ENABLED(MENU_ADDAUTOSTART)

View File

@ -46,9 +46,6 @@
extern millis_t manual_move_start_time;
extern int8_t manual_move_axis;
#if ENABLED(DUAL_X_CARRIAGE) || E_MANUAL > 1
extern int8_t manual_move_e_index;
#endif
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
float manual_move_e_origin = 0;
#endif
@ -57,18 +54,15 @@ extern int8_t manual_move_axis;
#endif
//
// Tell lcd_update() to start a move to current_position" after a short delay.
// Tell ui.update() to start a move to current_position" after a short delay.
//
inline void manual_move_to_current(AxisEnum axis
#if E_MANUAL > 1
, const int8_t eindex=-1
#endif
) {
#if ENABLED(DUAL_X_CARRIAGE) || E_MANUAL > 1
#if E_MANUAL > 1
if (axis == E_AXIS)
#endif
manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
#if E_MANUAL > 1
if (axis == E_AXIS) ui.manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
#endif
manual_move_start_time = millis() + (move_menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
manual_move_axis = (int8_t)axis;
@ -79,9 +73,9 @@ inline void manual_move_to_current(AxisEnum axis
//
static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition && !processing_manual_move) {
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
ui.encoder_direction_normal();
if (ui.encoderPosition && !ui.processing_manual_move) {
// Start with no limits to movement
float min = current_position[axis] - 1000,
@ -127,32 +121,32 @@ static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
#endif
// Get the new position
const float diff = float((int32_t)encoderPosition) * move_menu_scale;
const float diff = float((int32_t)ui.encoderPosition) * move_menu_scale;
#if IS_KINEMATIC
manual_move_offset += diff;
if ((int32_t)encoderPosition < 0)
if ((int32_t)ui.encoderPosition < 0)
NOLESS(manual_move_offset, min - current_position[axis]);
else
NOMORE(manual_move_offset, max - current_position[axis]);
#else
current_position[axis] += diff;
if ((int32_t)encoderPosition < 0)
if ((int32_t)ui.encoderPosition < 0)
NOLESS(current_position[axis], min);
else
NOMORE(current_position[axis], max);
#endif
manual_move_to_current(axis);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
ui.refresh(LCDVIEW_REDRAW_NOW);
}
encoderPosition = 0;
if (lcdDrawUpdate) {
const float pos = NATIVE_TO_LOGICAL(processing_manual_move ? destination[axis] : current_position[axis]
ui.encoderPosition = 0;
if (ui.should_draw()) {
const float pos = NATIVE_TO_LOGICAL(ui.processing_manual_move ? destination[axis] : current_position[axis]
#if IS_KINEMATIC
+ manual_move_offset
#endif
, axis);
lcd_implementation_drawedit(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
draw_edit_screen(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
}
}
void lcd_move_x() { _lcd_move_xyz(PSTR(MSG_MOVE_X), X_AXIS); }
@ -163,11 +157,11 @@ static void _lcd_move_e(
const int8_t eindex=-1
#endif
) {
if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
if (!processing_manual_move) {
const float diff = float((int32_t)encoderPosition) * move_menu_scale;
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
ui.encoder_direction_normal();
if (ui.encoderPosition) {
if (!ui.processing_manual_move) {
const float diff = float((int32_t)ui.encoderPosition) * move_menu_scale;
#if IS_KINEMATIC
manual_move_offset += diff;
#else
@ -178,11 +172,11 @@ static void _lcd_move_e(
, eindex
#endif
);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
ui.refresh(LCDVIEW_REDRAW_NOW);
}
encoderPosition = 0;
ui.encoderPosition = 0;
}
if (lcdDrawUpdate) {
if (ui.should_draw()) {
PGM_P pos_label;
#if E_MANUAL == 1
pos_label = PSTR(MSG_MOVE_E);
@ -205,7 +199,7 @@ static void _lcd_move_e(
}
#endif // E_MANUAL > 1
lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]
draw_edit_screen(pos_label, ftostr41sign(current_position[E_AXIS]
#if IS_KINEMATIC
+ manual_move_offset
#endif
@ -241,9 +235,9 @@ inline void lcd_move_e() { _lcd_move_e(); }
screenFunc_t _manual_move_func_ptr;
void _goto_manual_move(const float scale) {
set_defer_return_to_status(true);
ui.defer_status_screen(true);
move_menu_scale = scale;
lcd_goto_screen(_manual_move_func_ptr);
ui.goto_screen(_manual_move_func_ptr);
}
void menu_move_10mm() { _goto_manual_move(10); }
void menu_move_1mm() { _goto_manual_move( 1); }
@ -305,7 +299,7 @@ void lcd_move_get_e_amount() { _menu_move_distance(E_AXIS, lcd_move_e, -1); }
#if ENABLED(DELTA)
void lcd_lower_z_to_clip_height() {
line_to_z(delta_clip_start_height);
lcd_synchronize();
ui.synchronize();
}
#endif

View File

@ -39,35 +39,36 @@
#endif
void lcd_sd_updir() {
encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
ui.encoderPosition = card.updir() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
encoderTopLine = 0;
screen_changed = true;
lcd_refresh();
ui.refresh();
}
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
uint32_t last_sdfile_encoderPosition = 0xFFFF;
void lcd_reselect_last_file() {
void MarlinUI::reselect_last_file() {
if (last_sdfile_encoderPosition == 0xFFFF) return;
#if HAS_GRAPHICAL_LCD
// Some of this is a hack to force the screen update to work.
// TODO: Fix the real issue that causes this!
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
lcd_synchronize();
safe_delay(50);
lcd_synchronize();
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
drawing_screen = screen_changed = true;
#endif
//#if HAS_GRAPHICAL_LCD
// // This is a hack to force a screen update.
// ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
// ui.synchronize();
// safe_delay(50);
// ui.synchronize();
// ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
// ui.drawing_screen = screen_changed = true;
//#endif
lcd_goto_screen(menu_sdcard, last_sdfile_encoderPosition);
set_defer_return_to_status(true);
goto_screen(menu_sdcard, last_sdfile_encoderPosition);
last_sdfile_encoderPosition = 0xFFFF;
#if HAS_GRAPHICAL_LCD
lcd_update();
#endif
defer_status_screen(true);
//#if HAS_GRAPHICAL_LCD
// update();
//#endif
}
#endif
@ -75,30 +76,30 @@ class menu_item_sdfile {
public:
static void action(CardReader &theCard) {
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
last_sdfile_encoderPosition = encoderPosition; // Save which file was selected for later use
last_sdfile_encoderPosition = ui.encoderPosition; // Save which file was selected for later use
#endif
card.openAndPrintFile(theCard.filename);
lcd_return_to_status();
lcd_reset_status();
ui.return_to_status();
ui.reset_status();
}
};
class menu_item_sddirectory {
class menu_item_sdfolder {
public:
static void action(CardReader &theCard) {
card.chdir(theCard.filename);
encoderTopLine = 0;
encoderPosition = 2 * ENCODER_STEPS_PER_MENU_ITEM;
ui.encoderPosition = 2 * ENCODER_STEPS_PER_MENU_ITEM;
screen_changed = true;
#if HAS_GRAPHICAL_LCD
drawing_screen = false;
ui.drawing_screen = false;
#endif
lcd_refresh();
ui.refresh();
}
};
void menu_sdcard() {
ENCODER_DIRECTION_MENUS();
ui.encoder_direction_menus();
const uint16_t fileCnt = card.get_num_Files();
@ -125,7 +126,7 @@ void menu_sdcard() {
card.getfilename_sorted(nr);
if (card.filenameIsDir)
MENU_ITEM(sddirectory, MSG_CARD_MENU, card);
MENU_ITEM(sdfolder, MSG_CARD_MENU, card);
else
MENU_ITEM(sdfile, MSG_CARD_MENU, card);
}

View File

@ -36,8 +36,8 @@
#endif
// Initialized by settings.load()
int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
uint8_t lcd_preheat_fan_speed[2];
int16_t MarlinUI::preheat_hotend_temp[2], MarlinUI::preheat_bed_temp[2];
uint8_t MarlinUI::preheat_fan_speed[2];
//
// "Temperature" submenu items
@ -59,44 +59,44 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
#else
UNUSED(fan);
#endif
lcd_return_to_status();
ui.return_to_status();
}
#if HOTENDS > 1
void lcd_preheat_m1_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e1_only() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e1() { _lcd_preheat(1, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 2
void lcd_preheat_m1_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e2_only() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e2() { _lcd_preheat(2, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 3
void lcd_preheat_m1_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e3_only() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e3() { _lcd_preheat(3, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 4
void lcd_preheat_m1_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e4_only() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e4() { _lcd_preheat(4, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 5
void lcd_preheat_m1_e5_only() { _lcd_preheat(5, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e5_only() { _lcd_preheat(5, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e5() { _lcd_preheat(5, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e5() { _lcd_preheat(5, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#endif // HOTENDS > 5
#endif // HOTENDS > 4
@ -113,15 +113,15 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
void lcd_preheat_m1_all() {
#if HOTENDS > 1
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 1);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 1);
#if HOTENDS > 2
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 2);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 2);
#if HOTENDS > 3
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 3);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 3);
#if HOTENDS > 4
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 4);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 4);
#if HOTENDS > 5
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[0], 5);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
@ -136,15 +136,15 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
void lcd_preheat_m2_all() {
#if HOTENDS > 1
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 1);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 1);
#if HOTENDS > 2
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 2);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 2);
#if HOTENDS > 3
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 3);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 3);
#if HOTENDS > 4
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 4);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 4);
#if HOTENDS > 5
thermalManager.setTargetHotend(lcd_preheat_hotend_temp[1], 5);
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
@ -161,14 +161,14 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
void lcd_preheat_m1_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], -1, lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e0_only() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], -1, lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[0], lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_e0() { _lcd_preheat(0, lcd_preheat_hotend_temp[1], lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[0], lcd_preheat_fan_speed[0]); }
void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, lcd_preheat_bed_temp[1], lcd_preheat_fan_speed[1]); }
void lcd_preheat_m1_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
void menu_preheat_m1() {
@ -294,7 +294,7 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
void lcd_cooldown() {
zero_fan_speeds();
thermalManager.disable_all_heaters();
lcd_return_to_status();
ui.return_to_status();
}
#endif // HAS_TEMP_HOTEND || HAS_HEATED_BED

View File

@ -62,29 +62,29 @@ void _lcd_refresh_e_factor_0() { planner.refresh_e_factor(0); }
long babysteps_done = 0;
void _lcd_babystep(const AxisEnum axis, PGM_P msg) {
if (use_click()) { return lcd_goto_previous_menu_no_defer(); }
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
const int16_t babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
ui.encoder_direction_normal();
if (ui.encoderPosition) {
const int16_t babystep_increment = (int32_t)ui.encoderPosition * (BABYSTEP_MULTIPLICATOR);
ui.encoderPosition = 0;
ui.refresh(LCDVIEW_REDRAW_NOW);
thermalManager.babystep_axis(axis, babystep_increment);
babysteps_done += babystep_increment;
}
if (lcdDrawUpdate)
lcd_implementation_drawedit(msg, ftostr43sign(planner.steps_to_mm[axis] * babysteps_done));
if (ui.should_draw())
draw_edit_screen(msg, ftostr43sign(planner.steps_to_mm[axis] * babysteps_done));
}
#if ENABLED(BABYSTEP_XY)
void _lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEP_X)); }
void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEP_Y)); }
void lcd_babystep_x() { lcd_goto_screen(_lcd_babystep_x); babysteps_done = 0; set_defer_return_to_status(true); }
void lcd_babystep_y() { lcd_goto_screen(_lcd_babystep_y); babysteps_done = 0; set_defer_return_to_status(true); }
void lcd_babystep_x() { ui.goto_screen(_lcd_babystep_x); babysteps_done = 0; ui.defer_status_screen(true); }
void lcd_babystep_y() { ui.goto_screen(_lcd_babystep_y); babysteps_done = 0; ui.defer_status_screen(true); }
#endif
#if DISABLED(BABYSTEP_ZPROBE_OFFSET)
void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEP_Z)); }
void lcd_babystep_z() { lcd_goto_screen(_lcd_babystep_z); babysteps_done = 0; set_defer_return_to_status(true); }
void lcd_babystep_z() { ui.goto_screen(_lcd_babystep_z); babysteps_done = 0; ui.defer_status_screen(true); }
#endif
#endif // BABYSTEPPING

View File

@ -51,22 +51,22 @@ float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5
static int16_t ubl_encoderPosition = 0;
static void _lcd_mesh_fine_tune(PGM_P msg) {
set_defer_return_to_status(true);
ui.defer_status_screen(true);
if (ubl.encoder_diff) {
ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
ubl.encoder_diff = 0;
mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f * 0.5f;
mesh_edit_value = mesh_edit_accumulator;
encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
ui.encoderPosition = 0;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
}
if (lcdDrawUpdate) {
lcd_implementation_drawedit(msg, ftostr43sign(mesh_edit_value));
if (ui.should_draw()) {
draw_edit_screen(msg, ftostr43sign(mesh_edit_value));
#if ENABLED(MESH_EDIT_GFX_OVERLAY)
_lcd_zoffset_overlay_gfx(mesh_edit_value);
#endif
@ -74,19 +74,19 @@ static void _lcd_mesh_fine_tune(PGM_P msg) {
}
void _lcd_mesh_edit_NOP() {
set_defer_return_to_status(true);
ui.defer_status_screen(true);
}
float lcd_mesh_edit() {
lcd_goto_screen(_lcd_mesh_edit_NOP);
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
ui.goto_screen(_lcd_mesh_edit_NOP);
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
_lcd_mesh_fine_tune(PSTR("Mesh Editor"));
return mesh_edit_value;
}
void lcd_mesh_edit_setup(const float &initial) {
mesh_edit_value = mesh_edit_accumulator = initial;
lcd_goto_screen(_lcd_mesh_edit_NOP);
ui.goto_screen(_lcd_mesh_edit_NOP);
}
void _lcd_z_offset_edit() {
@ -94,13 +94,13 @@ void _lcd_z_offset_edit() {
}
float lcd_z_offset_edit() {
lcd_goto_screen(_lcd_z_offset_edit);
ui.goto_screen(_lcd_z_offset_edit);
return mesh_edit_value;
}
void lcd_z_offset_edit_setup(const float &initial) {
mesh_edit_value = mesh_edit_accumulator = initial;
lcd_goto_screen(_lcd_z_offset_edit);
ui.goto_screen(_lcd_z_offset_edit);
}
/**
@ -160,7 +160,7 @@ void _menu_ubl_height_adjust() {
START_MENU();
MENU_BACK(MSG_EDIT_MESH);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9, _lcd_ubl_adjust_height_cmd);
MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
END_MENU();
}
@ -179,7 +179,7 @@ void _lcd_ubl_edit_mesh() {
MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
MENU_ITEM(gcode, MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
MENU_ITEM(submenu, MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
END_MENU();
}
@ -220,7 +220,7 @@ void _lcd_ubl_validate_mesh() {
MENU_ITEM(gcode, MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
#endif
MENU_ITEM(function, MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
END_MENU();
}
@ -261,7 +261,7 @@ void _lcd_ubl_mesh_leveling() {
MENU_BACK(MSG_UBL_TOOLS);
MENU_ITEM(gcode, MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
MENU_ITEM(submenu, MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
END_MENU();
}
@ -290,7 +290,7 @@ void _menu_ubl_fillin() {
MENU_ITEM_EDIT_CALLBACK(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
MENU_ITEM(gcode, MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
MENU_ITEM(gcode, MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
END_MENU();
}
@ -353,7 +353,7 @@ void _lcd_ubl_build_mesh() {
MENU_ITEM(gcode, MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
MENU_ITEM(function, MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
MENU_ITEM(gcode, MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
MENU_ITEM(function, MSG_WATCH, lcd_return_to_status);
MENU_ITEM(function, MSG_WATCH, ui.return_to_status);
END_MENU();
}
@ -408,11 +408,11 @@ void _lcd_ubl_storage_mesh() {
void _lcd_ubl_output_map_lcd();
void _lcd_ubl_map_homing() {
set_defer_return_to_status(true);
ui.defer_status_screen(true);
_lcd_draw_homing();
if (all_axes_homed()) {
ubl.lcd_map_control = true; // Return to the map screen
lcd_goto_screen(_lcd_ubl_output_map_lcd);
ui.goto_screen(_lcd_ubl_output_map_lcd);
}
}
@ -444,10 +444,10 @@ void sync_plan_position();
void _lcd_do_nothing() {}
void _lcd_hard_stop() {
const screenFunc_t old_screen = currentScreen;
currentScreen = _lcd_do_nothing;
const screenFunc_t old_screen = ui.currentScreen;
ui.currentScreen = _lcd_do_nothing;
planner.quick_stop();
currentScreen = old_screen;
ui.currentScreen = old_screen;
set_current_from_steppers_for_axis(ALL_AXES);
sync_plan_position();
}
@ -455,15 +455,15 @@ void _lcd_hard_stop() {
void _lcd_ubl_output_map_lcd() {
static int16_t step_scaler = 0;
if (use_click()) return _lcd_ubl_map_lcd_edit_cmd();
ENCODER_DIRECTION_NORMAL();
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
ui.encoder_direction_normal();
if (encoderPosition) {
step_scaler += (int32_t)encoderPosition;
if (ui.encoderPosition) {
step_scaler += (int32_t)ui.encoderPosition;
x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
ui.encoderPosition = 0;
ui.refresh(LCDVIEW_REDRAW_NOW);
}
// Encoder to the right (++)
@ -487,8 +487,8 @@ void _lcd_ubl_output_map_lcd() {
n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
#endif
if (lcdDrawUpdate) {
lcd_implementation_ubl_plot(x_plot, y_plot);
if (ui.should_draw()) {
ui.ubl_plot(x_plot, y_plot);
if (planner.movesplanned()) // If the nozzle is already moving, cancel the move.
_lcd_hard_stop();
@ -505,7 +505,7 @@ void _lcd_ubl_output_map_lcd_cmd() {
set_all_unhomed();
enqueue_and_echo_commands_P(PSTR("G28"));
}
lcd_goto_screen(_lcd_ubl_map_homing);
ui.goto_screen(_lcd_ubl_map_homing);
}
/**