mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-27 13:56:24 +00:00
Enhance and fix FTDI Eve Touch UI (#21607)
This commit is contained in:
parent
107dd313bd
commit
e26eebfb2f
@ -147,6 +147,7 @@ namespace Language_en {
|
||||
PROGMEM Language_Str MSG_PROBE_BED = u8"Probe Mesh";
|
||||
PROGMEM Language_Str MSG_SHOW_MESH = u8"View Mesh";
|
||||
PROGMEM Language_Str MSG_PRINT_TEST = u8"Print Test";
|
||||
PROGMEM Language_Str MSG_MOVE_Z_TO_TOP = u8"Raise Z to Top";
|
||||
|
||||
#if ENABLED(TOUCH_UI_LULZBOT_BIO)
|
||||
PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home";
|
||||
|
@ -30,7 +30,7 @@ using namespace Theme;
|
||||
using namespace ExtUI;
|
||||
|
||||
constexpr static BedMeshEditScreenData &mydata = screen_data.BedMeshEditScreen;
|
||||
constexpr static float gaugeThickness = 0.25;
|
||||
constexpr static float gaugeThickness = 0.1;
|
||||
|
||||
#if ENABLED(TOUCH_UI_PORTRAIT)
|
||||
#define GRID_COLS 3
|
||||
@ -54,20 +54,29 @@ constexpr static float gaugeThickness = 0.25;
|
||||
#define SAVE_POS BTN_POS(5,5), BTN_SIZE(1,1)
|
||||
#endif
|
||||
|
||||
constexpr uint8_t NONE = 255;
|
||||
|
||||
static float meshGetter(uint8_t x, uint8_t y, void*) {
|
||||
xy_uint8_t pos;
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != -1 && mydata.highlight == pos ? mydata.zAdjustment : 0);
|
||||
return ExtUI::getMeshPoint(pos) + (mydata.highlight.x != NONE && mydata.highlight == pos ? mydata.zAdjustment : 0);
|
||||
}
|
||||
|
||||
void BedMeshEditScreen::onEntry() {
|
||||
mydata.needSave = false;
|
||||
mydata.highlight.x = -1;
|
||||
mydata.highlight.x = NONE;
|
||||
mydata.zAdjustment = 0;
|
||||
mydata.savedMeshLevelingState = ExtUI::getLevelingActive();
|
||||
mydata.savedEndstopState = ExtUI::getSoftEndstopState();
|
||||
BaseScreen::onEntry();
|
||||
}
|
||||
|
||||
void BedMeshEditScreen::onExit() {
|
||||
ExtUI::setLevelingActive(mydata.savedMeshLevelingState);
|
||||
ExtUI::setSoftEndstopState(mydata.savedEndstopState);
|
||||
}
|
||||
|
||||
float BedMeshEditScreen::getHighlightedValue() {
|
||||
const float val = ExtUI::getMeshPoint(mydata.highlight);
|
||||
return (ISNAN(val) ? 0 : val) + mydata.zAdjustment;
|
||||
@ -80,12 +89,13 @@ void BedMeshEditScreen::setHighlightedValue(float value) {
|
||||
void BedMeshEditScreen::moveToHighlightedValue() {
|
||||
if (ExtUI::getMeshValid()) {
|
||||
ExtUI::setLevelingActive(true);
|
||||
ExtUI::setSoftEndstopState(false);
|
||||
ExtUI::moveToMeshPoint(mydata.highlight, gaugeThickness + mydata.zAdjustment);
|
||||
}
|
||||
}
|
||||
|
||||
void BedMeshEditScreen::adjustHighlightedValue(float increment) {
|
||||
if(mydata.highlight.x != -1) {
|
||||
if (mydata.highlight.x != NONE) {
|
||||
mydata.zAdjustment += increment;
|
||||
moveToHighlightedValue();
|
||||
mydata.needSave = true;
|
||||
@ -114,7 +124,7 @@ void BedMeshEditScreen::drawHighlightedPointValue() {
|
||||
.colors(normal_btn)
|
||||
.text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z))
|
||||
.font(font_small);
|
||||
if(mydata.highlight.x != -1)
|
||||
if (mydata.highlight.x != NONE)
|
||||
draw_adjuster(cmd, Z_VALUE_POS, 3, getHighlightedValue(), GET_TEXT_F(MSG_UNITS_MM), 4, 3);
|
||||
cmd.colors(mydata.needSave ? normal_btn : action_btn)
|
||||
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BUTTON_BACK))
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define FTDI_BED_MESH_EDIT_SCREEN_CLASS BedMeshEditScreen
|
||||
|
||||
struct BedMeshEditScreenData {
|
||||
bool needSave;
|
||||
bool needSave, savedMeshLevelingState, savedEndstopState;
|
||||
xy_uint8_t highlight;
|
||||
float zAdjustment;
|
||||
};
|
||||
@ -41,6 +41,7 @@ class BedMeshEditScreen : public BedMeshBase, public CachedScreen<BED_MESH_EDIT_
|
||||
static void drawHighlightedPointValue();
|
||||
public:
|
||||
static void onEntry();
|
||||
static void onExit();
|
||||
static void onRedraw(draw_mode_t);
|
||||
static bool onTouchHeld(uint8_t tag);
|
||||
static bool onTouchEnd(uint8_t tag);
|
||||
|
@ -73,14 +73,14 @@ void BedMeshViewScreen::drawHighlightedPointValue() {
|
||||
.text(Z_LABEL_POS, GET_TEXT_F(MSG_MESH_EDIT_Z))
|
||||
.font(font_small);
|
||||
|
||||
if(mydata.highlight.x != -1)
|
||||
if (mydata.highlight.x != -1)
|
||||
draw_adjuster_value(cmd, Z_VALUE_POS, ExtUI::getMeshPoint(mydata.highlight), GET_TEXT_F(MSG_UNITS_MM), 4, 3);
|
||||
|
||||
cmd.colors(action_btn)
|
||||
.tag(1).button(OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY))
|
||||
.tag(0);
|
||||
|
||||
if(mydata.message) cmd.text(MESSAGE_POS, mydata.message);
|
||||
if (mydata.message) cmd.text(MESSAGE_POS, mydata.message);
|
||||
}
|
||||
|
||||
void BedMeshViewScreen::onRedraw(draw_mode_t what) {
|
||||
|
@ -66,6 +66,9 @@ void MoveAxisScreen::onRedraw(draw_mode_t what) {
|
||||
w.adjuster( 14, GET_TEXT_F(MSG_AXIS_E4), mydata.e_rel[3], canMove(E3));
|
||||
#endif
|
||||
#endif
|
||||
#if Z_HOME_DIR < 0
|
||||
w.button(24, GET_TEXT_F(MSG_MOVE_Z_TO_TOP), !axis_should_home(Z_AXIS));
|
||||
#endif
|
||||
w.increments();
|
||||
}
|
||||
|
||||
@ -98,7 +101,8 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) {
|
||||
case 20: SpinnerDialogBox::enqueueAndWait_P(F("G28X")); break;
|
||||
case 21: SpinnerDialogBox::enqueueAndWait_P(F("G28Y")); break;
|
||||
case 22: SpinnerDialogBox::enqueueAndWait_P(F("G28Z")); break;
|
||||
case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break;
|
||||
case 23: SpinnerDialogBox::enqueueAndWait_P(F("G28")); break;
|
||||
case 24: raiseZtoTop(); break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -107,6 +111,11 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseMoveAxisScreen::raiseZtoTop() {
|
||||
constexpr xyze_feedrate_t homing_feedrate = HOMING_FEEDRATE_MM_M;
|
||||
setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate[Z_AXIS]);
|
||||
}
|
||||
|
||||
float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) {
|
||||
// Compute feedrate so that the tool lags the adjuster when it is
|
||||
// being held down, this allows enough margin for the planner to
|
||||
|
@ -34,6 +34,7 @@ class BaseMoveAxisScreen : public BaseNumericAdjustmentScreen {
|
||||
private:
|
||||
static float getManualFeedrate(uint8_t axis, float increment_mm);
|
||||
public:
|
||||
static void raiseZtoTop();
|
||||
static void setManualFeedrate(ExtUI::axis_t, float increment_mm);
|
||||
static void setManualFeedrate(ExtUI::extruder_t, float increment_mm);
|
||||
|
||||
|
@ -61,6 +61,7 @@ union screen_data_t {
|
||||
DECL_DATA_IF_INCLUDED(FTDI_COCOA_PREHEAT_SCREEN)
|
||||
DECL_DATA_IF_INCLUDED(FTDI_COCOA_LOAD_CHOCOLATE_SCREEN)
|
||||
DECL_DATA_IF_INCLUDED(FTDI_NUDGE_NOZZLE_SCREEN)
|
||||
DECL_DATA_IF_INCLUDED(FTDI_Z_OFFSET_SCREEN)
|
||||
DECL_DATA_IF_INCLUDED(FTDI_BASE_NUMERIC_ADJ_SCREEN)
|
||||
DECL_DATA_IF_INCLUDED(FTDI_ALERT_DIALOG_BOX)
|
||||
};
|
||||
|
@ -316,8 +316,8 @@ void StatusScreen::draw_interaction_buttons(draw_mode_t what) {
|
||||
cmd.colors(normal_btn)
|
||||
.font(Theme::font_medium)
|
||||
.colors(has_media ? action_btn : normal_btn)
|
||||
.enabled(has_media)
|
||||
.tag(3).button(MEDIA_BTN_POS, isPrintingFromMedia() ? GET_TEXT_F(MSG_PRINTING) : GET_TEXT_F(MSG_BUTTON_MEDIA))
|
||||
.enabled(has_media && !isPrinting())
|
||||
.tag(3).button(MEDIA_BTN_POS, isPrinting() ? GET_TEXT_F(MSG_PRINTING) : GET_TEXT_F(MSG_BUTTON_MEDIA))
|
||||
.colors(!has_media ? action_btn : normal_btn)
|
||||
.tag(4).button(MENU_BTN_POS, GET_TEXT_F(MSG_BUTTON_MENU));
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "../config.h"
|
||||
#include "screens.h"
|
||||
#include "screen_data.h"
|
||||
|
||||
#ifdef FTDI_Z_OFFSET_SCREEN
|
||||
|
||||
@ -29,6 +30,15 @@ using namespace FTDI;
|
||||
using namespace ExtUI;
|
||||
using namespace Theme;
|
||||
|
||||
#define SHEET_THICKNESS 0.1
|
||||
|
||||
constexpr static ZOffsetScreenData &mydata = screen_data.ZOffsetScreen;
|
||||
|
||||
void ZOffsetScreen::onEntry() {
|
||||
mydata.z = SHEET_THICKNESS;
|
||||
BaseNumericAdjustmentScreen::onEntry();
|
||||
}
|
||||
|
||||
void ZOffsetScreen::onRedraw(draw_mode_t what) {
|
||||
widgets_t w(what);
|
||||
w.precision(2, BaseNumericAdjustmentScreen::DEFAULT_MIDRANGE).units(GET_TEXT_F(MSG_UNITS_MM));
|
||||
@ -36,13 +46,45 @@ void ZOffsetScreen::onRedraw(draw_mode_t what) {
|
||||
w.heading( GET_TEXT_F(MSG_ZPROBE_ZOFFSET));
|
||||
w.color(z_axis).adjuster(4, GET_TEXT_F(MSG_ZPROBE_ZOFFSET), getZOffset_mm());
|
||||
w.increments();
|
||||
w.button( 2, GET_TEXT_F(MSG_PROBE_WIZARD));
|
||||
}
|
||||
|
||||
void ZOffsetScreen::move(float inc) {
|
||||
// We can't store state after the call to the AlertBox, so
|
||||
// check whether the current position equal mydata.z in order
|
||||
// to know whether the user started the wizard.
|
||||
if (getAxisPosition_mm(Z) == mydata.z) {
|
||||
mydata.z += inc;
|
||||
setAxisPosition_mm(mydata.z, Z);
|
||||
}
|
||||
}
|
||||
|
||||
void ZOffsetScreen::runWizard() {
|
||||
// Restore the default Z offset
|
||||
constexpr float offset[] = NOZZLE_TO_PROBE_OFFSET;
|
||||
setZOffset_mm(offset[Z_AXIS]);
|
||||
// Move above probe point
|
||||
char cmd[64], str[10];
|
||||
strcpy_P(cmd, PSTR("G28 Z\nG0 F1000 X"));
|
||||
dtostrf(TERN(Z_SAFE_HOMING,Z_SAFE_HOMING_X_POINT,X_CENTER), 3, 1, str);
|
||||
strcat(cmd, str);
|
||||
strcat_P(cmd, PSTR("Y"));
|
||||
dtostrf(TERN(Z_SAFE_HOMING,Z_SAFE_HOMING_Y_POINT,Y_CENTER), 3, 1, str);
|
||||
strcat(cmd, str);
|
||||
strcat_P(cmd, PSTR("Z"));
|
||||
dtostrf(SHEET_THICKNESS, 3, 1, str);
|
||||
strcat(cmd, str);
|
||||
injectCommands(cmd);
|
||||
// Show instructions for user.
|
||||
AlertDialogBox::show(PSTR("After the printer finishes homing, adjust the Z Offset so that a sheet of paper can pass between the nozzle and bed with slight resistance."));
|
||||
}
|
||||
|
||||
bool ZOffsetScreen::onTouchHeld(uint8_t tag) {
|
||||
const float increment = getIncrement();
|
||||
switch (tag) {
|
||||
case 4: UI_DECREMENT(ZOffset_mm); break;
|
||||
case 5: UI_INCREMENT(ZOffset_mm); break;
|
||||
case 2: runWizard(); break;
|
||||
case 4: UI_DECREMENT(ZOffset_mm); move(-increment); break;
|
||||
case 5: UI_INCREMENT(ZOffset_mm); move( increment); break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -25,8 +25,16 @@
|
||||
#define FTDI_Z_OFFSET_SCREEN
|
||||
#define FTDI_Z_OFFSET_SCREEN_CLASS ZOffsetScreen
|
||||
|
||||
struct ZOffsetScreenData : public BaseNumericAdjustmentScreenData {
|
||||
float z;
|
||||
};
|
||||
|
||||
class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen<ZOFFSET_SCREEN_CACHE> {
|
||||
private:
|
||||
static void move(float inc);
|
||||
static void runWizard();
|
||||
public:
|
||||
static void onEntry();
|
||||
static void onRedraw(draw_mode_t);
|
||||
static bool onTouchHeld(uint8_t tag);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user