🎨 ExtUI "user click" and other tweaks (#22122)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
InsanityAutomation 2021-06-13 23:08:46 -04:00 committed by Scott Lahteine
parent 56355159c6
commit d84e2d6e29
8 changed files with 125 additions and 103 deletions

View File

@ -70,7 +70,7 @@ void GcodeSuite::G29() {
return; return;
} }
int8_t ix, iy; int8_t ix, iy = 0;
switch (state) { switch (state) {
case MeshReport: case MeshReport:
@ -88,6 +88,7 @@ void GcodeSuite::G29() {
mbl_probe_index = 0; mbl_probe_index = 0;
if (!ui.wait_for_move) { if (!ui.wait_for_move) {
queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2")); queue.inject_P(parser.seen_test('N') ? PSTR("G28" TERN(CAN_SET_LEVELING_AFTER_G28, "L0", "") "\nG29S2") : PSTR("G29S2"));
TERN_(EXTENSIBLE_UI, ExtUI::onMeshLevelingStart());
return; return;
} }
state = MeshNext; state = MeshNext;
@ -109,6 +110,7 @@ void GcodeSuite::G29() {
else { else {
// Save Z for the previous mesh position // Save Z for the previous mesh position
mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z); mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z);
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, current_position.z));
SET_SOFT_ENDSTOP_LOOSE(false); SET_SOFT_ENDSTOP_LOOSE(false);
} }
// If there's another point to sample, move there with optional lift. // If there's another point to sample, move there with optional lift.

View File

@ -47,6 +47,7 @@
#include "../marlinui.h" #include "../marlinui.h"
#include "../../gcode/queue.h" #include "../../gcode/queue.h"
#include "../../gcode/gcode.h"
#include "../../module/motion.h" #include "../../module/motion.h"
#include "../../module/planner.h" #include "../../module/planner.h"
#include "../../module/probe.h" #include "../../module/probe.h"
@ -353,14 +354,9 @@ namespace ExtUI {
extruder_t getTool(const uint8_t extruder) { extruder_t getTool(const uint8_t extruder) {
switch (extruder) { switch (extruder) {
case 7: return E7; default:
case 6: return E6; case 0: return E0; case 1: return E1; case 2: return E2; case 3: return E3;
case 5: return E5; case 4: return E4; case 5: return E5; case 6: return E6; case 7: return E7;
case 4: return E4;
case 3: return E3;
case 2: return E2;
case 1: return E1;
default: return E0;
} }
} }
@ -372,8 +368,8 @@ namespace ExtUI {
switch (axis) { switch (axis) {
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING) #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
case X: return axis_should_home(X_AXIS); case X: return axis_should_home(X_AXIS);
case Y: return axis_should_home(Y_AXIS); OPTCODE(HAS_Y_AXIS, case Y: return axis_should_home(Y_AXIS))
case Z: return axis_should_home(Z_AXIS); OPTCODE(HAS_Z_AXIS, case Z: return axis_should_home(Z_AXIS))
#else #else
case X: case Y: case Z: return true; case X: case Y: case Z: return true;
#endif #endif
@ -385,6 +381,8 @@ namespace ExtUI {
return !thermalManager.tooColdToExtrude(extruder - E0); return !thermalManager.tooColdToExtrude(extruder - E0);
} }
GcodeSuite::MarlinBusyState getMachineBusyState() { return TERN0(HOST_KEEPALIVE_FEATURE, GcodeSuite::busy_state); }
#if HAS_SOFTWARE_ENDSTOPS #if HAS_SOFTWARE_ENDSTOPS
bool getSoftEndstopState() { return soft_endstop._enabled; } bool getSoftEndstopState() { return soft_endstop._enabled; }
void setSoftEndstopState(const bool value) { soft_endstop._enabled = value; } void setSoftEndstopState(const bool value) { soft_endstop._enabled = value; }
@ -396,18 +394,27 @@ namespace ExtUI {
#if AXIS_IS_TMC(X) #if AXIS_IS_TMC(X)
case X: return stepperX.getMilliamps(); case X: return stepperX.getMilliamps();
#endif #endif
#if AXIS_IS_TMC(X2)
case X2: return stepperX2.getMilliamps();
#endif
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
case Y: return stepperY.getMilliamps(); case Y: return stepperY.getMilliamps();
#endif #endif
#if AXIS_IS_TMC(Y2)
case Y2: return stepperY2.getMilliamps();
#endif
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
case Z: return stepperZ.getMilliamps(); case Z: return stepperZ.getMilliamps();
#endif #endif
#if AXIS_IS_TMC(I)
case I: return stepperI.getMilliamps();
#endif
#if AXIS_IS_TMC(J)
case J: return stepperJ.getMilliamps();
#endif
#if AXIS_IS_TMC(K)
case K: return stepperK.getMilliamps();
#endif
#if AXIS_IS_TMC(X2)
case X2: return stepperX2.getMilliamps();
#endif
#if AXIS_IS_TMC(Y2)
case Y2: return stepperY2.getMilliamps();
#endif
#if AXIS_IS_TMC(Z2) #if AXIS_IS_TMC(Z2)
case Z2: return stepperZ2.getMilliamps(); case Z2: return stepperZ2.getMilliamps();
#endif #endif
@ -450,18 +457,27 @@ namespace ExtUI {
#if AXIS_IS_TMC(X) #if AXIS_IS_TMC(X)
case X: stepperX.rms_current(constrain(mA, 400, 1500)); break; case X: stepperX.rms_current(constrain(mA, 400, 1500)); break;
#endif #endif
#if AXIS_IS_TMC(X2)
case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break;
#endif
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
case Y: stepperY.rms_current(constrain(mA, 400, 1500)); break; case Y: stepperY.rms_current(constrain(mA, 400, 1500)); break;
#endif #endif
#if AXIS_IS_TMC(Y2)
case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break;
#endif
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
case Z: stepperZ.rms_current(constrain(mA, 400, 1500)); break; case Z: stepperZ.rms_current(constrain(mA, 400, 1500)); break;
#endif #endif
#if AXIS_IS_TMC(I)
case I: stepperI.rms_current(constrain(mA, 400, 1500)); break;
#endif
#if AXIS_IS_TMC(J)
case J: stepperJ.rms_current(constrain(mA, 400, 1500)); break;
#endif
#if AXIS_IS_TMC(K)
case K: stepperK.rms_current(constrain(mA, 400, 1500)); break;
#endif
#if AXIS_IS_TMC(X2)
case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break;
#endif
#if AXIS_IS_TMC(Y2)
case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break;
#endif
#if AXIS_IS_TMC(Z2) #if AXIS_IS_TMC(Z2)
case Z2: stepperZ2.rms_current(constrain(mA, 400, 1500)); break; case Z2: stepperZ2.rms_current(constrain(mA, 400, 1500)); break;
#endif #endif
@ -501,66 +517,59 @@ namespace ExtUI {
int getTMCBumpSensitivity(const axis_t axis) { int getTMCBumpSensitivity(const axis_t axis) {
switch (axis) { switch (axis) {
#if ENABLED(X_SENSORLESS) OPTCODE(X_SENSORLESS, case X: return stepperX.homing_threshold())
case X: return stepperX.homing_threshold(); OPTCODE(Y_SENSORLESS, case Y: return stepperY.homing_threshold())
#endif OPTCODE(Z_SENSORLESS, case Z: return stepperZ.homing_threshold())
#if ENABLED(X2_SENSORLESS) OPTCODE(I_SENSORLESS, case I: return stepperI.homing_threshold())
case X2: return stepperX2.homing_threshold(); OPTCODE(J_SENSORLESS, case J: return stepperJ.homing_threshold())
#endif OPTCODE(K_SENSORLESS, case K: return stepperK.homing_threshold())
#if ENABLED(Y_SENSORLESS) OPTCODE(X2_SENSORLESS, case X2: return stepperX2.homing_threshold())
case Y: return stepperY.homing_threshold(); OPTCODE(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold())
#endif OPTCODE(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold())
#if ENABLED(Y2_SENSORLESS) OPTCODE(Z3_SENSORLESS, case Z3: return stepperZ3.homing_threshold())
case Y2: return stepperY2.homing_threshold(); OPTCODE(Z4_SENSORLESS, case Z4: return stepperZ4.homing_threshold())
#endif
#if ENABLED(Z_SENSORLESS)
case Z: return stepperZ.homing_threshold();
#endif
#if ENABLED(Z2_SENSORLESS)
case Z2: return stepperZ2.homing_threshold();
#endif
#if ENABLED(Z3_SENSORLESS)
case Z3: return stepperZ3.homing_threshold();
#endif
#if ENABLED(Z4_SENSORLESS)
case Z4: return stepperZ4.homing_threshold();
#endif
default: return 0; default: return 0;
} }
} }
void setTMCBumpSensitivity(const_float_t value, const axis_t axis) { void setTMCBumpSensitivity(const_float_t value, const axis_t axis) {
switch (axis) { switch (axis) {
#if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS #if X_SENSORLESS
#if X_SENSORLESS case X: stepperX.homing_threshold(value); break;
case X: stepperX.homing_threshold(value); break; #endif
#endif #if Y_SENSORLESS
#if X2_SENSORLESS case Y: stepperY.homing_threshold(value); break;
case X2: stepperX2.homing_threshold(value); break; #endif
#endif #if Z_SENSORLESS
#if Y_SENSORLESS case Z: stepperZ.homing_threshold(value); break;
case Y: stepperY.homing_threshold(value); break; #endif
#endif #if I_SENSORLESS
#if Y2_SENSORLESS case I: stepperI.homing_threshold(value); break;
case Y2: stepperY2.homing_threshold(value); break; #endif
#endif #if J_SENSORLESS
#if Z_SENSORLESS case J: stepperJ.homing_threshold(value); break;
case Z: stepperZ.homing_threshold(value); break; #endif
#endif #if K_SENSORLESS
#if Z2_SENSORLESS case K: stepperK.homing_threshold(value); break;
case Z2: stepperZ2.homing_threshold(value); break; #endif
#endif #if X2_SENSORLESS
#if Z3_SENSORLESS case X2: stepperX2.homing_threshold(value); break;
case Z3: stepperZ3.homing_threshold(value); break; #endif
#endif #if Y2_SENSORLESS
#if Z4_SENSORLESS case Y2: stepperY2.homing_threshold(value); break;
case Z4: stepperZ4.homing_threshold(value); break; #endif
#endif #if Z2_SENSORLESS
#else case Z2: stepperZ2.homing_threshold(value); break;
UNUSED(value); #endif
#if Z3_SENSORLESS
case Z3: stepperZ3.homing_threshold(value); break;
#endif
#if Z4_SENSORLESS
case Z4: stepperZ4.homing_threshold(value); break;
#endif #endif
default: break; default: break;
} }
UNUSED(value);
} }
#endif #endif
@ -661,9 +670,7 @@ namespace ExtUI {
#if HAS_JUNCTION_DEVIATION #if HAS_JUNCTION_DEVIATION
float getJunctionDeviation_mm() { float getJunctionDeviation_mm() { return planner.junction_deviation_mm; }
return planner.junction_deviation_mm;
}
void setJunctionDeviation_mm(const_float_t value) { void setJunctionDeviation_mm(const_float_t value) {
planner.junction_deviation_mm = constrain(value, 0.001, 0.3); planner.junction_deviation_mm = constrain(value, 0.001, 0.3);
@ -682,7 +689,7 @@ namespace ExtUI {
#endif #endif
#if PREHEAT_COUNT #if PREHEAT_COUNT
uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; } uint16_t getMaterial_preset_E(const uint16_t index) { return ui.material_preset[index].hotend_temp; }
#if HAS_HEATED_BED #if HAS_HEATED_BED
uint16_t getMaterial_preset_B(const uint16_t index) { return ui.material_preset[index].bed_temp; } uint16_t getMaterial_preset_B(const uint16_t index) { return ui.material_preset[index].bed_temp; }
#endif #endif
@ -709,9 +716,13 @@ namespace ExtUI {
switch (axis) { switch (axis) {
#if ENABLED(BABYSTEP_XY) #if ENABLED(BABYSTEP_XY)
case X: babystep.add_steps(X_AXIS, steps); break; case X: babystep.add_steps(X_AXIS, steps); break;
case Y: babystep.add_steps(Y_AXIS, steps); break; #if HAS_Y_AXIS
case Y: babystep.add_steps(Y_AXIS, steps); break;
#endif
#endif
#if HAS_Z_AXIS
case Z: babystep.add_steps(Z_AXIS, steps); break;
#endif #endif
case Z: babystep.add_steps(Z_AXIS, steps); break;
default: return false; default: return false;
}; };
return true; return true;
@ -750,8 +761,8 @@ namespace ExtUI {
hotend_offset[e][axis] += mm; hotend_offset[e][axis] += mm;
normalizeNozzleOffset(X); normalizeNozzleOffset(X);
normalizeNozzleOffset(Y); TERN_(HAS_Y_AXIS, normalizeNozzleOffset(Y));
normalizeNozzleOffset(Z); TERN_(HAS_Z_AXIS, normalizeNozzleOffset(Z));
} }
#else #else
UNUSED(linked_nozzles); UNUSED(linked_nozzles);
@ -1014,8 +1025,7 @@ namespace ExtUI {
TERN_(HAS_FAN, thermalManager.zero_fan_speeds()); TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
} }
bool awaitingUserConfirm() { return wait_for_user; } bool awaitingUserConfirm() { return TERN0(HAS_RESUME_CONTINUE, wait_for_user); }
void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); } void setUserConfirmed() { TERN_(HAS_RESUME_CONTINUE, wait_for_user = false); }
void printFile(const char *filename) { void printFile(const char *filename) {
@ -1038,9 +1048,9 @@ namespace ExtUI {
bool isMediaInserted() { return TERN0(SDSUPPORT, IS_SD_INSERTED() && card.isMounted()); } bool isMediaInserted() { return TERN0(SDSUPPORT, IS_SD_INSERTED() && card.isMounted()); }
void pausePrint() { ui.pause_print(); } void pausePrint() { ui.pause_print(); }
void resumePrint() { ui.resume_print(); } void resumePrint() { ui.resume_print(); }
void stopPrint() { ui.abort_print(); } void stopPrint() { ui.abort_print(); }
void onUserConfirmRequired_P(PGM_P const pstr) { void onUserConfirmRequired_P(PGM_P const pstr) {
char msg[strlen_P(pstr) + 1]; char msg[strlen_P(pstr) + 1];

View File

@ -44,6 +44,7 @@
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#include "../marlinui.h" #include "../marlinui.h"
#include "../../gcode/gcode.h"
namespace ExtUI { namespace ExtUI {
@ -53,7 +54,7 @@ namespace ExtUI {
static constexpr size_t eeprom_data_size = 48; static constexpr size_t eeprom_data_size = 48;
enum axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4 }; enum axis_t : uint8_t { X, Y, Z, I, J, K, X2, Y2, Z2, Z3, Z4 };
enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 }; enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5, E6, E7 };
enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER }; enum heater_t : uint8_t { H0, H1, H2, H3, H4, H5, BED, CHAMBER, COOLER };
enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 }; enum fan_t : uint8_t { FAN0, FAN1, FAN2, FAN3, FAN4, FAN5, FAN6, FAN7 };
@ -78,6 +79,8 @@ namespace ExtUI {
void injectCommands(char * const); void injectCommands(char * const);
bool commandsInQueue(); bool commandsInQueue();
GcodeSuite::MarlinBusyState getMachineBusyState();
bool isHeaterIdle(const heater_t); bool isHeaterIdle(const heater_t);
bool isHeaterIdle(const extruder_t); bool isHeaterIdle(const extruder_t);
void enableHeater(const heater_t); void enableHeater(const heater_t);
@ -125,6 +128,7 @@ namespace ExtUI {
float getAxisMaxAcceleration_mm_s2(const extruder_t); float getAxisMaxAcceleration_mm_s2(const extruder_t);
feedRate_t getMinFeedrate_mm_s(); feedRate_t getMinFeedrate_mm_s();
feedRate_t getMinTravelFeedrate_mm_s(); feedRate_t getMinTravelFeedrate_mm_s();
feedRate_t getFeedrate_mm_s();
float getPrintingAcceleration_mm_s2(); float getPrintingAcceleration_mm_s2();
float getRetractAcceleration_mm_s2(); float getRetractAcceleration_mm_s2();
float getTravelAcceleration_mm_s2(); float getTravelAcceleration_mm_s2();
@ -186,6 +190,8 @@ namespace ExtUI {
void setHostResponse(const uint8_t); void setHostResponse(const uint8_t);
#endif #endif
inline void simulateUserClick() { ui.lcd_clicked = true; }
#if ENABLED(PRINTCOUNTER) #if ENABLED(PRINTCOUNTER)
char* getFailedPrints_str(char buffer[21]); char* getFailedPrints_str(char buffer[21]);
char* getTotalPrints_str(char buffer[21]); char* getTotalPrints_str(char buffer[21]);

View File

@ -223,6 +223,10 @@ millis_t MarlinUI::next_button_update_ms; // = 0
#endif #endif
#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)
bool MarlinUI::lcd_clicked;
#endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
#include "menu/menu.h" #include "menu/menu.h"
@ -247,14 +251,6 @@ millis_t MarlinUI::next_button_update_ms; // = 0
uint8_t MarlinUI::repeat_delay; uint8_t MarlinUI::repeat_delay;
#endif #endif
bool MarlinUI::lcd_clicked;
bool MarlinUI::use_click() {
const bool click = lcd_clicked;
lcd_clicked = false;
return click;
}
#if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION) #if EITHER(AUTO_BED_LEVELING_UBL, G26_MESH_VALIDATION)
bool MarlinUI::external_control; // = false bool MarlinUI::external_control; // = false

View File

@ -474,9 +474,6 @@ public:
static void set_selection(const bool sel) { selection = sel; } static void set_selection(const bool sel) { selection = sel; }
static bool update_selection(); static bool update_selection();
static bool lcd_clicked;
static bool use_click();
static void synchronize(PGM_P const msg=nullptr); static void synchronize(PGM_P const msg=nullptr);
static screenFunc_t currentScreen; static screenFunc_t currentScreen;
@ -527,12 +524,23 @@ public:
#elif HAS_WIRED_LCD #elif HAS_WIRED_LCD
static constexpr bool lcd_clicked = false;
static constexpr bool on_status_screen() { return true; } static constexpr bool on_status_screen() { return true; }
FORCE_INLINE static void run_current_screen() { status_screen(); } FORCE_INLINE static void run_current_screen() { status_screen(); }
#endif #endif
#if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)
static bool lcd_clicked;
static inline bool use_click() {
const bool click = lcd_clicked;
lcd_clicked = false;
return click;
}
#else
static constexpr bool lcd_clicked = false;
static inline bool use_click() { return false; }
#endif
#if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE) #if BOTH(HAS_LCD_MENU, ADVANCED_PAUSE_FEATURE)
static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder); static void pause_show_message(const PauseMessage message, const PauseMode mode=PAUSE_MODE_SAME, const uint8_t extruder=active_extruder);
#else #else

View File

@ -384,7 +384,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
DEBUG_EOL(); DEBUG_EOL();
TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0)); TERN_(WAIT_FOR_NOZZLE_HEAT, if (hotend_temp > thermalManager.wholeDegHotend(0) + (TEMP_WINDOW)) thermalManager.wait_for_hotend(0));
TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating()); TERN_(WAIT_FOR_BED_HEAT, if (bed_temp > thermalManager.wholeDegBed() + (TEMP_BED_WINDOW)) thermalManager.wait_for_bed_heating());
} }
#endif #endif

View File

@ -3621,7 +3621,7 @@ void Temperature::isr() {
#if G26_CLICK_CAN_CANCEL #if G26_CLICK_CAN_CANCEL
if (click_to_cancel && ui.use_click()) { if (click_to_cancel && ui.use_click()) {
wait_for_heatup = false; wait_for_heatup = false;
ui.quick_feedback(); TERN_(HAS_LCD_MENU, ui.quick_feedback());
} }
#endif #endif
@ -3755,7 +3755,7 @@ void Temperature::isr() {
#if G26_CLICK_CAN_CANCEL #if G26_CLICK_CAN_CANCEL
if (click_to_cancel && ui.use_click()) { if (click_to_cancel && ui.use_click()) {
wait_for_heatup = false; wait_for_heatup = false;
ui.quick_feedback(); TERN_(HAS_LCD_MENU, ui.quick_feedback());
} }
#endif #endif

View File

@ -174,7 +174,7 @@ enum ADCSensorState : char {
#define unscalePID_d(d) ( float(d) * PID_dT ) #define unscalePID_d(d) ( float(d) * PID_dT )
#endif #endif
#if BOTH(HAS_LCD_MENU, G26_MESH_VALIDATION) #if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)
#define G26_CLICK_CAN_CANCEL 1 #define G26_CLICK_CAN_CANCEL 1
#endif #endif