Skip to content

Commit 1ba694c

Browse files
marciotthinkyhead
authored andcommitted
🎨 Fix and enhance FTDI Eve Touch UI (MarlinFirmware#22189)
1 parent 906fa05 commit 1ba694c

File tree

11 files changed

+182
-17
lines changed

11 files changed

+182
-17
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*********************************
2+
* cocoa_press/leveling_menu.cpp *
3+
*********************************/
4+
5+
/****************************************************************************
6+
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
7+
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
8+
* *
9+
* This program is free software: you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation, either version 3 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
* This program is distributed in the hope that it will be useful, *
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17+
* GNU General Public License for more details. *
18+
* *
19+
* To view a copy of the GNU General Public License, go to the following *
20+
* location: <https://www.gnu.org/licenses/>. *
21+
****************************************************************************/
22+
23+
#include "../config.h"
24+
#include "../screens.h"
25+
26+
#ifdef COCOA_LEVELING_MENU
27+
28+
#if BOTH(HAS_BED_PROBE,BLTOUCH)
29+
#include "../../../../feature/bltouch.h"
30+
#endif
31+
32+
using namespace FTDI;
33+
using namespace ExtUI;
34+
using namespace Theme;
35+
36+
#define GRID_ROWS 5
37+
#define GRID_COLS 3
38+
#define BED_MESH_TITLE_POS BTN_POS(1,1), BTN_SIZE(3,1)
39+
#define PROBE_BED_POS BTN_POS(1,2), BTN_SIZE(1,1)
40+
#define SHOW_MESH_POS BTN_POS(2,2), BTN_SIZE(1,1)
41+
#define EDIT_MESH_POS BTN_POS(3,2), BTN_SIZE(1,1)
42+
#define BLTOUCH_TITLE_POS BTN_POS(1,3), BTN_SIZE(3,1)
43+
#define BLTOUCH_RESET_POS BTN_POS(1,4), BTN_SIZE(1,1)
44+
#define BLTOUCH_TEST_POS BTN_POS(2,4), BTN_SIZE(1,1)
45+
#define BACK_POS BTN_POS(1,5), BTN_SIZE(3,1)
46+
47+
void LevelingMenu::onRedraw(draw_mode_t what) {
48+
if (what & BACKGROUND) {
49+
CommandProcessor cmd;
50+
cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
51+
.cmd(CLEAR(true,true,true))
52+
.tag(0);
53+
}
54+
55+
if (what & FOREGROUND) {
56+
CommandProcessor cmd;
57+
cmd.font(font_large)
58+
.cmd(COLOR_RGB(bg_text_enabled))
59+
.text(BED_MESH_TITLE_POS, GET_TEXT_F(MSG_BED_LEVELING))
60+
.text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH))
61+
.font(font_medium).colors(normal_btn)
62+
.tag(2).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED))
63+
.enabled(ENABLED(HAS_MESH))
64+
.tag(3).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH))
65+
.enabled(ENABLED(HAS_MESH))
66+
.tag(4).button(EDIT_MESH_POS, GET_TEXT_F(MSG_EDIT_MESH))
67+
#undef GRID_COLS
68+
#define GRID_COLS 2
69+
.tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET))
70+
.tag(6).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST))
71+
#undef GRID_COLS
72+
#define GRID_COLS 3
73+
.colors(action_btn)
74+
.tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
75+
}
76+
}
77+
78+
bool LevelingMenu::onTouchEnd(uint8_t tag) {
79+
switch (tag) {
80+
case 1: GOTO_PREVIOUS(); break;
81+
case 2: BedMeshViewScreen::doProbe(); break;
82+
case 3: BedMeshViewScreen::show(); break;
83+
case 4: BedMeshEditScreen::show(); break;
84+
case 5: injectCommands_P(PSTR("M280 P0 S60")); break;
85+
case 6: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
86+
default: return false;
87+
}
88+
return true;
89+
}
90+
91+
#endif // COCOA_LEVELING_MENU
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*******************************
2+
* cocoa_press/leveling_menu.h *
3+
******************************/
4+
5+
/****************************************************************************
6+
* Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
7+
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
8+
* *
9+
* This program is free software: you can redistribute it and/or modify *
10+
* it under the terms of the GNU General Public License as published by *
11+
* the Free Software Foundation, either version 3 of the License, or *
12+
* (at your option) any later version. *
13+
* *
14+
* This program is distributed in the hope that it will be useful, *
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17+
* GNU General Public License for more details. *
18+
* *
19+
* To view a copy of the GNU General Public License, go to the following *
20+
* location: <https://www.gnu.org/licenses/>. *
21+
****************************************************************************/
22+
23+
#pragma once
24+
25+
#define COCOA_LEVELING_MENU
26+
#define COCOA_LEVELING_MENU_CLASS LevelingMenu
27+
28+
class LevelingMenu : public BaseScreen, public CachedScreen<LEVELING_SCREEN_CACHE> {
29+
public:
30+
static void onRedraw(draw_mode_t);
31+
static bool onTouchEnd(uint8_t tag);
32+
};

Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) {
8888
case 8: GOTO_SCREEN(AdvancedSettingsMenu); break;
8989
case 9: injectCommands_P(PSTR("M84")); break;
9090
#if HAS_LEVELING
91-
case 10: GOTO_SCREEN(LevelingMenu); break;
91+
case 10: GOTO_SCREEN(LevelingMenu); break;
9292
#endif
9393
case 11: GOTO_SCREEN(AboutScreen); break;
9494
default:

Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,3 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
132132
}
133133

134134
#endif // FTDI_LEVELING_MENU
135-

Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/string_format.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,53 @@
3434
* Formats a temperature string (e.g. "100°C")
3535
*/
3636
void format_temp(char *str, const_celsius_float_t t1) {
37-
sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
37+
#ifdef TOUCH_UI_LCD_TEMP_PRECISION
38+
char num1[7];
39+
dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
40+
sprintf_P(str, PSTR("%s" S_FMT), num1, GET_TEXT(MSG_UNITS_C));
41+
#else
42+
sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
43+
#endif
3844
}
3945

4046
/**
4147
* Formats a temperature string for an idle heater (e.g. "100 °C / idle")
4248
*/
4349
void format_temp_and_idle(char *str, const_celsius_float_t t1) {
44-
sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
50+
#ifdef TOUCH_UI_LCD_TEMP_PRECISION
51+
char num1[7];
52+
dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
53+
sprintf_P(str, PSTR("%s" S_FMT " / " S_FMT), num1, GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
54+
#else
55+
sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
56+
#endif
4557
}
4658

4759
/**
4860
* Formats a temperature string for an active heater (e.g. "100 / 200°C")
4961
*/
5062
void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2) {
51-
sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
63+
#ifdef TOUCH_UI_LCD_TEMP_PRECISION
64+
char num1[7], num2[7];
65+
dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
66+
dtostrf(t2, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num2);
67+
sprintf_P(str, PSTR("%s / %s" S_FMT), num1, num2, GET_TEXT(MSG_UNITS_C));
68+
#else
69+
sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
70+
#endif
5271
}
5372

5473
/**
5574
* Formats a temperature string for a material (e.g. "100°C (PLA)")
5675
*/
5776
void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material) {
58-
sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
77+
#ifdef TOUCH_UI_LCD_TEMP_PRECISION
78+
char num1[7];
79+
dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
80+
sprintf_P(str, PSTR("%s" S_FMT " (" S_FMT ")"), num1, GET_TEXT(MSG_UNITS_C), material);
81+
#else
82+
sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
83+
#endif
5984
}
6085

6186
/**

Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ constexpr static ZOffsetScreenData &mydata = screen_data.ZOffsetScreen;
3636

3737
void ZOffsetScreen::onEntry() {
3838
mydata.z = SHEET_THICKNESS;
39+
mydata.softEndstopState = getSoftEndstopState();
3940
BaseNumericAdjustmentScreen::onEntry();
41+
if (wizardRunning())
42+
setSoftEndstopState(false);
43+
}
44+
45+
void ZOffsetScreen::onExit() {
46+
setSoftEndstopState(mydata.softEndstopState);
4047
}
4148

4249
void ZOffsetScreen::onRedraw(draw_mode_t what) {
@@ -50,17 +57,13 @@ void ZOffsetScreen::onRedraw(draw_mode_t what) {
5057
}
5158

5259
void ZOffsetScreen::move(float mm, int16_t steps) {
53-
// We can't store state after the call to the AlertBox, so
54-
// check whether the current position equal mydata.z in order
55-
// to know whether the user started the wizard.
56-
if (getAxisPosition_mm(Z) == mydata.z) {
57-
// In the wizard
60+
if (wizardRunning()) {
5861
mydata.z += mm;
5962
setAxisPosition_mm(mydata.z, Z);
6063
}
6164
else {
6265
// Otherwise doing a manual adjustment, possibly during a print.
63-
babystepAxis_steps(steps, Z);
66+
TERN(BABYSTEPPING, babystepAxis_steps(steps, Z), UNUSED(steps));
6467
}
6568
}
6669

@@ -84,9 +87,16 @@ void ZOffsetScreen::runWizard() {
8487
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."));
8588
}
8689

90+
bool ZOffsetScreen::wizardRunning() {
91+
// We can't store state after the call to the AlertBox, so
92+
// check whether the current Z position equals mydata.z in order
93+
// to know whether the user started the wizard.
94+
return getAxisPosition_mm(Z) == mydata.z;
95+
}
96+
8797
bool ZOffsetScreen::onTouchHeld(uint8_t tag) {
88-
const int16_t steps = mmToWholeSteps(getIncrement(), Z);
89-
const float increment = mmFromWholeSteps(steps, Z);
98+
const int16_t steps = TERN(BABYSTEPPING, mmToWholeSteps(getIncrement(), Z), 0);
99+
const float increment = TERN(BABYSTEPPING, mmFromWholeSteps(steps, Z), getIncrement());
90100
switch (tag) {
91101
case 2: runWizard(); break;
92102
case 4: UI_DECREMENT(ZOffset_mm); move(-increment, -steps); break;

Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727

2828
struct ZOffsetScreenData : public BaseNumericAdjustmentScreenData {
2929
float z;
30+
bool softEndstopState;
3031
};
3132

3233
class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen<ZOFFSET_SCREEN_CACHE> {
3334
private:
3435
static void move(float mm, int16_t steps);
3536
static void runWizard();
37+
static bool wizardRunning();
3638
public:
3739
static void onEntry();
40+
static void onExit();
3841
static void onRedraw(draw_mode_t);
3942
static bool onTouchHeld(uint8_t tag);
4043
};

Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ SCREEN_TABLE {
113113
DECL_SCREEN_IF_INCLUDED(COCOA_PREHEAT_MENU)
114114
DECL_SCREEN_IF_INCLUDED(COCOA_PREHEAT_SCREEN)
115115
DECL_SCREEN_IF_INCLUDED(COCOA_LOAD_CHOCOLATE_SCREEN)
116+
DECL_SCREEN_IF_INCLUDED(COCOA_LEVELING_MENU)
116117
DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_XYZ_SCREEN)
117118
DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_E_SCREEN)
118119
};

Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ enum {
157157
#include "cocoa_press/load_chocolate.h"
158158
#include "cocoa_press/move_xyz_screen.h"
159159
#include "cocoa_press/move_e_screen.h"
160+
#include "cocoa_press/leveling_menu.h"
160161

161162
#else
162163
#include "generic/status_screen.h"
@@ -206,7 +207,9 @@ enum {
206207
#endif
207208

208209
#if HAS_LEVELING
209-
#include "generic/leveling_menu.h"
210+
#if DISABLED(TOUCH_UI_COCOA_PRESS)
211+
#include "generic/leveling_menu.h"
212+
#endif
210213
#if HAS_BED_PROBE
211214
#include "generic/z_offset_screen.h"
212215
#endif

Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ namespace Theme {
108108

109109
constexpr uint32_t bed_mesh_lines_rgb = accent_color_6;
110110
constexpr uint32_t bed_mesh_shadow_rgb = 0x444444;
111+
#define BED_MESH_POINTS_GRAY
111112
#else
112113
constexpr uint32_t theme_darkest = gray_color_1;
113114
constexpr uint32_t theme_dark = gray_color_2;

0 commit comments

Comments
 (0)