diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp
new file mode 100644
index 0000000000..ec3cc10a8e
--- /dev/null
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp
@@ -0,0 +1,91 @@
+/*********************************
+ * cocoa_press/leveling_menu.cpp *
+ *********************************/
+
+/****************************************************************************
+ * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
+ * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * To view a copy of the GNU General Public License, go to the following *
+ * location: . *
+ ****************************************************************************/
+
+#include "../config.h"
+#include "../screens.h"
+
+#if ENABLED(COCOA_LEVELING_MENU)
+
+#if ENABLED(BLTOUCH)
+ #include "../../../../feature/bltouch.h"
+#endif
+
+using namespace FTDI;
+using namespace ExtUI;
+using namespace Theme;
+
+#define GRID_ROWS 5
+#define GRID_COLS 3
+#define BED_MESH_TITLE_POS BTN_POS(1,1), BTN_SIZE(3,1)
+#define PROBE_BED_POS BTN_POS(1,2), BTN_SIZE(1,1)
+#define SHOW_MESH_POS BTN_POS(2,2), BTN_SIZE(1,1)
+#define EDIT_MESH_POS BTN_POS(3,2), BTN_SIZE(1,1)
+#define BLTOUCH_TITLE_POS BTN_POS(1,3), BTN_SIZE(3,1)
+#define BLTOUCH_RESET_POS BTN_POS(1,4), BTN_SIZE(1,1)
+#define BLTOUCH_TEST_POS BTN_POS(2,4), BTN_SIZE(1,1)
+#define BACK_POS BTN_POS(1,5), BTN_SIZE(3,1)
+
+void LevelingMenu::onRedraw(draw_mode_t what) {
+ if (what & BACKGROUND) {
+ CommandProcessor cmd;
+ cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
+ .cmd(CLEAR(true,true,true))
+ .tag(0);
+ }
+
+ if (what & FOREGROUND) {
+ CommandProcessor cmd;
+ cmd.font(font_large)
+ .cmd(COLOR_RGB(bg_text_enabled))
+ .text(BED_MESH_TITLE_POS, GET_TEXT_F(MSG_BED_LEVELING))
+ .text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH))
+ .font(font_medium).colors(normal_btn)
+ .tag(2).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED))
+ .enabled(ENABLED(HAS_MESH))
+ .tag(3).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH))
+ .enabled(ENABLED(HAS_MESH))
+ .tag(4).button(EDIT_MESH_POS, GET_TEXT_F(MSG_EDIT_MESH))
+ #undef GRID_COLS
+ #define GRID_COLS 2
+ .tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET))
+ .tag(6).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST))
+ #undef GRID_COLS
+ #define GRID_COLS 3
+ .colors(action_btn)
+ .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
+ }
+}
+
+bool LevelingMenu::onTouchEnd(uint8_t tag) {
+ switch (tag) {
+ case 1: GOTO_PREVIOUS(); break;
+ case 2: BedMeshViewScreen::doProbe(); break;
+ case 3: BedMeshViewScreen::show(); break;
+ case 4: BedMeshEditScreen::show(); break;
+ case 5: injectCommands_P(PSTR("M280 P0 S60")); break;
+ case 6: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
+ default: return false;
+ }
+ return true;
+}
+
+#endif // COCOA_LEVELING_MENU
diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.h
new file mode 100644
index 0000000000..8275380249
--- /dev/null
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.h
@@ -0,0 +1,32 @@
+/*******************************
+ * cocoa_press/leveling_menu.h *
+ ******************************/
+
+/****************************************************************************
+ * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
+ * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * To view a copy of the GNU General Public License, go to the following *
+ * location: . *
+ ****************************************************************************/
+
+#pragma once
+
+#define COCOA_LEVELING_MENU
+#define COCOA_LEVELING_MENU_CLASS LevelingMenu
+
+class LevelingMenu : public BaseScreen, public CachedScreen {
+ public:
+ static void onRedraw(draw_mode_t);
+ static bool onTouchEnd(uint8_t tag);
+};
diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.cpp
index 14f2196453..4163c072ac 100644
--- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.cpp
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_base.cpp
@@ -148,11 +148,13 @@ void BedMeshBase::_drawMesh(CommandProcessor &cmd, int16_t x, int16_t y, int16_t
else
b = val_dev / sq_max;
}
- #ifdef BED_MESH_POINTS_GRAY
- cmd.cmd(COLOR_RGB((1.0f - b + r) * 0x7F, (1.0f - b - r) * 0x7F, (1.0f - r + b) * 0x7F));
- #else
- cmd.cmd(COLOR_RGB((1.0f - b) * 0xFF, (1.0f - b - r) * 0xFF, (1.0f - r) * 0xFF));
- #endif
+ cmd.cmd(COLOR_RGB(
+ #ifdef BED_MESH_POINTS_GRAY
+ 0x7F * (1.0f - b + r), 0x7F * (1.0f - b - r), 0x7F * (1.0f - r + b)
+ #else
+ 0xFF * (1.0f - b), 0xFF * (1.0f - b - r), 0xFF * (1.0f - r)
+ #endif
+ ));
}
cmd.cmd(VERTEX2F(TRANSFORM(x, y, HEIGHT(x, y))));
}
diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp
index e06fb52773..5a6c6134e8 100644
--- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/bed_mesh_edit_screen.cpp
@@ -60,45 +60,45 @@ 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 != NONE && mydata.highlight == pos ? mydata.zAdjustment : 0);
+ return getMeshPoint(pos) + (mydata.highlight.x != NONE && mydata.highlight == pos ? mydata.zAdjustment : 0);
}
void BedMeshEditScreen::onEntry() {
mydata.needSave = false;
mydata.highlight.x = NONE;
mydata.zAdjustment = 0;
- mydata.savedMeshLevelingState = ExtUI::getLevelingActive();
- mydata.savedEndstopState = ExtUI::getSoftEndstopState();
+ mydata.savedMeshLevelingState = getLevelingActive();
+ mydata.savedEndstopState = getSoftEndstopState();
makeMeshValid();
BaseScreen::onEntry();
}
void BedMeshEditScreen::makeMeshValid() {
- bed_mesh_t &mesh = ExtUI::getMeshArray();
+ bed_mesh_t &mesh = getMeshArray();
GRID_LOOP(x, y) {
if (isnan(mesh[x][y])) mesh[x][y] = 0;
}
}
void BedMeshEditScreen::onExit() {
- ExtUI::setLevelingActive(mydata.savedMeshLevelingState);
- ExtUI::setSoftEndstopState(mydata.savedEndstopState);
+ setLevelingActive(mydata.savedMeshLevelingState);
+ setSoftEndstopState(mydata.savedEndstopState);
}
float BedMeshEditScreen::getHighlightedValue() {
- const float val = ExtUI::getMeshPoint(mydata.highlight);
+ const float val = getMeshPoint(mydata.highlight);
return (isnan(val) ? 0 : val) + mydata.zAdjustment;
}
void BedMeshEditScreen::setHighlightedValue(float value) {
- ExtUI::setMeshPoint(mydata.highlight, value);
+ setMeshPoint(mydata.highlight, value);
}
void BedMeshEditScreen::moveToHighlightedValue() {
- if (ExtUI::getMeshValid()) {
- ExtUI::setLevelingActive(true);
- ExtUI::setSoftEndstopState(false);
- ExtUI::moveToMeshPoint(mydata.highlight, gaugeThickness + mydata.zAdjustment);
+ if (getMeshValid()) {
+ setLevelingActive(true);
+ setSoftEndstopState(false);
+ moveToMeshPoint(mydata.highlight, gaugeThickness + mydata.zAdjustment);
}
}
@@ -191,7 +191,7 @@ bool BedMeshEditScreen::onTouchEnd(uint8_t tag) {
void BedMeshEditScreen::show() {
// On entry, home if needed and save current mesh
- if (!ExtUI::isMachineHomed()) {
+ if (!isMachineHomed()) {
SpinnerDialogBox::enqueueAndWait_P(F("G28\nG29 S1"));
// After the spinner, go to this screen.
current_screen.forget();
diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp
index 93f9c4c228..69003dca9d 100644
--- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp
@@ -25,7 +25,7 @@
#ifdef FTDI_LEVELING_MENU
-#if BOTH(HAS_BED_PROBE,BLTOUCH)
+#if ENABLED(BLTOUCH)
#include "../../../../feature/bltouch.h"
#endif
@@ -132,4 +132,3 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
}
#endif // FTDI_LEVELING_MENU
-
diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/string_format.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/string_format.cpp
index 09f0bb6089..1f3640e3a1 100644
--- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/string_format.cpp
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/string_format.cpp
@@ -34,28 +34,53 @@
* Formats a temperature string (e.g. "100°C")
*/
void format_temp(char *str, const_celsius_float_t t1) {
- sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
+ #ifdef TOUCH_UI_LCD_TEMP_PRECISION
+ char num1[7];
+ dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
+ sprintf_P(str, PSTR("%s" S_FMT), num1, GET_TEXT(MSG_UNITS_C));
+ #else
+ sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
+ #endif
}
/**
* Formats a temperature string for an idle heater (e.g. "100 °C / idle")
*/
void format_temp_and_idle(char *str, const_celsius_float_t t1) {
- sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
+ #ifdef TOUCH_UI_LCD_TEMP_PRECISION
+ char num1[7];
+ dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
+ sprintf_P(str, PSTR("%s" S_FMT " / " S_FMT), num1, GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
+ #else
+ sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
+ #endif
}
/**
* Formats a temperature string for an active heater (e.g. "100 / 200°C")
*/
void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2) {
- sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
+ #ifdef TOUCH_UI_LCD_TEMP_PRECISION
+ char num1[7], num2[7];
+ dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
+ dtostrf(t2, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num2);
+ sprintf_P(str, PSTR("%s / %s" S_FMT), num1, num2, GET_TEXT(MSG_UNITS_C));
+ #else
+ sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
+ #endif
}
/**
* Formats a temperature string for a material (e.g. "100°C (PLA)")
*/
void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material) {
- sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
+ #ifdef TOUCH_UI_LCD_TEMP_PRECISION
+ char num1[7];
+ dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
+ sprintf_P(str, PSTR("%s" S_FMT " (" S_FMT ")"), num1, GET_TEXT(MSG_UNITS_C), material);
+ #else
+ sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
+ #endif
}
/**
diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp
index 8d886c704a..4ef2aa3d64 100644
--- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp
@@ -36,9 +36,14 @@ constexpr static ZOffsetScreenData &mydata = screen_data.ZOffsetScreen;
void ZOffsetScreen::onEntry() {
mydata.z = SHEET_THICKNESS;
+ mydata.softEndstopState = getSoftEndstopState();
BaseNumericAdjustmentScreen::onEntry();
}
+void ZOffsetScreen::onExit() {
+ setSoftEndstopState(mydata.softEndstopState);
+}
+
void ZOffsetScreen::onRedraw(draw_mode_t what) {
widgets_t w(what);
w.precision(2, BaseNumericAdjustmentScreen::DEFAULT_MIDRANGE).units(GET_TEXT_F(MSG_UNITS_MM));
@@ -59,12 +64,13 @@ void ZOffsetScreen::move(float mm, int16_t steps) {
setAxisPosition_mm(mydata.z, Z);
}
else {
- // Otherwise doing a manual adjustment, possibly during a print.
- babystepAxis_steps(steps, Z);
+ // Otherwise doing a manual adjustment, possibly during a print
+ TERN_(BABYSTEPPING, babystepAxis_steps(steps, Z));
}
}
void ZOffsetScreen::runWizard() {
+ setSoftEndstopState(false);
// Restore the default Z offset
constexpr float offset[] = NOZZLE_TO_PROBE_OFFSET;
setZOffset_mm(offset[Z_AXIS]);
@@ -85,8 +91,8 @@ void ZOffsetScreen::runWizard() {
}
bool ZOffsetScreen::onTouchHeld(uint8_t tag) {
- const int16_t steps = mmToWholeSteps(getIncrement(), Z);
- const float increment = mmFromWholeSteps(steps, Z);
+ const int16_t steps = TERN(BABYSTEPPING, mmToWholeSteps(getIncrement(), Z), 0);
+ const float increment = TERN(BABYSTEPPING, mmFromWholeSteps(steps, Z), getIncrement());
switch (tag) {
case 2: runWizard(); break;
case 4: UI_DECREMENT(ZOffset_mm); move(-increment, -steps); break;
diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h
index 067687f315..5505abf09b 100644
--- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h
+++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h
@@ -27,6 +27,7 @@
struct ZOffsetScreenData : public BaseNumericAdjustmentScreenData {
float z;
+ bool softEndstopState;
};
class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen {
@@ -35,6 +36,7 @@ class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen