Skip to content

Commit 8bd8581

Browse files
marciotvgadreau
authored andcommitted
Touch UI "Leveling" menu, misc. fixes (MarlinFirmware#19349)
1 parent 49c7e9e commit 8bd8581

File tree

15 files changed

+258
-218
lines changed

15 files changed

+258
-218
lines changed

Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@
736736
uint8_t count = GRID_MAX_POINTS;
737737

738738
mesh_index_pair best;
739+
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_START));
739740
do {
740741
if (do_ubl_mesh_map) display_map(g29_map_type);
741742

@@ -775,6 +776,8 @@
775776

776777
} while (best.pos.x >= 0 && --count);
777778

779+
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_FINISH));
780+
778781
// Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
779782
TERN_(HAS_LCD_MENU, ui.release());
780783
probe.stow();

Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/ftdi_eve_lib/extras/poly_ui.h

+26-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* GNU General Public License for more details. *
1717
* *
1818
* To view a copy of the GNU General Public License, go to the following *
19-
* location: <https://www.gnu.org/licenses/>. *
19+
* location: <https://www.gnu.org/licenses/>. *
2020
****************************************************************************/
2121

2222
#pragma once
@@ -36,7 +36,7 @@
3636
*
3737
* PolyReader r(data, N_ELEMENTS(data));
3838
*
39-
* for(r.start();r.has_more(); r.next()) {
39+
* for (r.start();r.has_more(); r.next()) {
4040
* uint16_t x = r.x;
4141
* uint16_t y = r.y;
4242
*
@@ -107,8 +107,8 @@ class PolyReader {
107107
}
108108
}
109109

110-
bool has_more() {return p != NULL;}
111-
bool end_of_loop() {return start_x == eol;}
110+
bool has_more() { return p != NULL; }
111+
bool end_of_loop() { return start_x == eol; }
112112
};
113113

114114
/**
@@ -129,7 +129,7 @@ class TransformedPolyReader : public PolyReader {
129129
*/
130130
static constexpr uint8_t fract_bits = 5;
131131
typedef int16_t fix_t;
132-
fix_t makefix(float f) {return f * (1 << fract_bits);}
132+
fix_t makefix(float f) { return f * (1 << fract_bits); }
133133

134134
// First two rows of 3x3 transformation matrix
135135
fix_t a, b, c;
@@ -254,6 +254,13 @@ class GenericPolyUI {
254254
draw_mode_t mode;
255255

256256
public:
257+
enum ButtonStyle : uint8_t {
258+
FILL = 1,
259+
STROKE = 2,
260+
SHADOW = 4,
261+
REGULAR = 7
262+
};
263+
257264
typedef POLY_READER poly_reader_t;
258265

259266
GenericPolyUI(CommandProcessor &c, draw_mode_t what = BOTH) : cmd(c), mode(what) {}
@@ -276,7 +283,7 @@ class GenericPolyUI {
276283
Polygon p(cmd);
277284
p.begin_fill();
278285
p.begin_loop();
279-
for(r.start();r.has_more();r.next()) {
286+
for (r.start();r.has_more();r.next()) {
280287
p(r.x * 16, r.y * 16);
281288
if (r.end_of_loop()) {
282289
p.end_loop();
@@ -306,7 +313,7 @@ class GenericPolyUI {
306313
Polygon p(cmd);
307314
p.begin_stroke();
308315
p.begin_loop();
309-
for(r.start();r.has_more(); r.next()) {
316+
for (r.start();r.has_more(); r.next()) {
310317
p(r.x * 16, r.y * 16);
311318
if (r.end_of_loop()) {
312319
p.end_loop();
@@ -323,7 +330,7 @@ class GenericPolyUI {
323330
int16_t y_min = INT16_MAX;
324331
int16_t x_max = INT16_MIN;
325332
int16_t y_max = INT16_MIN;
326-
for(r.start(); r.has_more(); r.next()) {
333+
for (r.start(); r.has_more(); r.next()) {
327334
x_min = min(x_min, int16_t(r.x));
328335
x_max = max(x_max, int16_t(r.x));
329336
y_min = min(y_min, int16_t(r.y));
@@ -355,11 +362,11 @@ class GenericPolyUI {
355362
btn_shadow_depth = depth;
356363
}
357364

358-
void button(const uint8_t tag, poly_reader_t r) {
365+
void button(const uint8_t tag, poly_reader_t r, uint8_t style = REGULAR) {
359366
using namespace FTDI;
360367
// Draw the shadow
361368
#if FTDI_API_LEVEL >= 810
362-
if (mode & BACKGROUND) {
369+
if (mode & BACKGROUND && style & SHADOW) {
363370
cmd.cmd(SAVE_CONTEXT());
364371
cmd.cmd(TAG(tag));
365372
cmd.cmd(VERTEX_TRANSLATE_X(btn_shadow_depth * 16));
@@ -381,11 +388,15 @@ class GenericPolyUI {
381388
#endif
382389
// Draw the fill and stroke
383390
cmd.cmd(TAG(tag));
384-
cmd.cmd(COLOR_RGB(btn_fill_color));
385-
fill(r, false);
386-
cmd.cmd(COLOR_RGB(btn_stroke_color));
387-
cmd.cmd(LINE_WIDTH(btn_stroke_width));
388-
stroke(r);
391+
if (style & FILL) {
392+
cmd.cmd(COLOR_RGB(btn_fill_color));
393+
fill(r, false);
394+
}
395+
if (style & STROKE) {
396+
cmd.cmd(COLOR_RGB(btn_stroke_color));
397+
cmd.cmd(LINE_WIDTH(btn_stroke_width));
398+
stroke(r);
399+
}
389400
cmd.cmd(RESTORE_CONTEXT());
390401
}
391402
}

Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/language/language_en.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ namespace Language_en {
145145
PROGMEM Language_Str MSG_TOUCH_CALIBRATION_PROMPT = u8"Touch the dots to calibrate";
146146
PROGMEM Language_Str MSG_AUTOLEVEL_X_AXIS = u8"Level X Axis";
147147
PROGMEM Language_Str MSG_BED_MAPPING_DONE = u8"Bed mapping finished";
148-
PROGMEM Language_Str MSG_RESET_BLTOUCH = u8"Reset BLTouch";
148+
PROGMEM Language_Str MSG_LEVELING = u8"Leveling";
149+
PROGMEM Language_Str MSG_SHOW_MESH = u8"Show Bed Mesh";
149150

150151
#ifdef TOUCH_UI_LULZBOT_BIO
151152
PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home";

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

+8-12
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
5555
#define ACCELERATION_POS BTN_POS(2,5), BTN_SIZE(1,1)
5656
#define ENDSTOPS_POS BTN_POS(1,6), BTN_SIZE(1,1)
5757
#define JERK_POS BTN_POS(2,6), BTN_SIZE(1,1)
58-
#define OFFSETS_POS BTN_POS(1,7), BTN_SIZE(1,1)
58+
#define CASE_LIGHT_POS BTN_POS(1,7), BTN_SIZE(1,1)
5959
#define BACKLASH_POS BTN_POS(2,7), BTN_SIZE(1,1)
60-
#define CASE_LIGHT_POS BTN_POS(1,8), BTN_SIZE(1,1)
60+
#define OFFSETS_POS BTN_POS(1,8), BTN_SIZE(1,1)
6161
#define TMC_HOMING_THRS_POS BTN_POS(2,8), BTN_SIZE(1,1)
62-
#if EITHER(CASE_LIGHT_ENABLE, SENSORLESS_HOMING)
62+
#if EITHER(HAS_MULTI_HOTEND, SENSORLESS_HOMING)
6363
#define BACK_POS BTN_POS(1,9), BTN_SIZE(2,1)
6464
#else
6565
#define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1)
@@ -98,8 +98,8 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
9898
.tag(13).button( TMC_CURRENT_POS, GET_TEXT_F(MSG_TMC_CURRENT))
9999
.enabled(ENABLED(SENSORLESS_HOMING))
100100
.tag(14).button( TMC_HOMING_THRS_POS, GET_TEXT_F(MSG_TMC_HOMING_THRS))
101-
.enabled(EITHER(HAS_MULTI_HOTEND, BLTOUCH))
102-
.tag(4) .button( OFFSETS_POS, GET_TEXT_F(TERN(HAS_MULTI_HOTEND, MSG_OFFSETS_MENU, MSG_RESET_BLTOUCH)))
101+
.enabled(ENABLED(HAS_MULTI_HOTEND))
102+
.tag(4) .button( OFFSETS_POS, GET_TEXT_F(MSG_OFFSETS_MENU))
103103
.enabled(EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR))
104104
.tag(11).button( FILAMENT_POS, GET_TEXT_F(MSG_FILAMENT))
105105
.tag(12).button( ENDSTOPS_POS, GET_TEXT_F(MSG_LCD_ENDSTOPS))
@@ -123,13 +123,9 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
123123
case 2: GOTO_SCREEN(ZOffsetScreen); break;
124124
#endif
125125
case 3: GOTO_SCREEN(StepsScreen); break;
126-
case 4:
127-
#if HAS_MULTI_HOTEND
128-
GOTO_SCREEN(NozzleOffsetScreen);
129-
#elif ENABLED(BLTOUCH)
130-
injectCommands_P(PSTR("M280 P0 S60"));
131-
#endif
132-
break;
126+
#if ENABLED(HAS_MULTI_HOTEND)
127+
case 4: GOTO_SCREEN(NozzleOffsetScreen); break;
128+
#endif
133129
case 5: GOTO_SCREEN(MaxVelocityScreen); break;
134130
case 6: GOTO_SCREEN(DefaultAccelerationScreen); break;
135131
case 7: GOTO_SCREEN(TERN(HAS_JUNCTION_DEVIATION, JunctionDeviationScreen, JerkScreen)); break;

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

+31-12
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ bool BedMeshScreen::tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y) {
222222

223223
void BedMeshScreen::onEntry() {
224224
screen_data.BedMeshScreen.highlightedTag = 0;
225-
screen_data.BedMeshScreen.count = 0;
225+
screen_data.BedMeshScreen.count = GRID_MAX_POINTS;
226+
screen_data.BedMeshScreen.showMappingDone = false;
226227
BaseScreen::onEntry();
227228
}
228229

@@ -251,6 +252,10 @@ void BedMeshScreen::drawHighlightedPointValue() {
251252
.colors(action_btn)
252253
.tag(1).button( OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY))
253254
.tag(0);
255+
256+
if (screen_data.BedMeshScreen.showMappingDone) {
257+
cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE));
258+
}
254259
}
255260

256261
void BedMeshScreen::onRedraw(draw_mode_t what) {
@@ -270,17 +275,13 @@ void BedMeshScreen::onRedraw(draw_mode_t what) {
270275

271276
if (what & FOREGROUND) {
272277
constexpr float autoscale_max_amplitude = 0.03;
273-
const bool levelingFinished = screen_data.BedMeshScreen.count >= GRID_MAX_POINTS;
274-
const float levelingProgress = sq(float(screen_data.BedMeshScreen.count) / GRID_MAX_POINTS);
275-
if (levelingFinished) {
278+
const bool gotAllPoints = screen_data.BedMeshScreen.count >= GRID_MAX_POINTS;
279+
if (gotAllPoints) {
276280
drawHighlightedPointValue();
277-
CommandProcessor cmd;
278-
cmd.font(Theme::font_medium)
279-
.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE));
280281
}
281-
282+
const float levelingProgress = sq(float(screen_data.BedMeshScreen.count) / GRID_MAX_POINTS);
282283
BedMeshScreen::drawMesh(INSET_POS(MESH_POS), ExtUI::getMeshArray(),
283-
USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (levelingFinished ? USE_COLORS : 0),
284+
USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (gotAllPoints ? USE_COLORS : 0),
284285
autoscale_max_amplitude * levelingProgress
285286
);
286287
}
@@ -307,11 +308,29 @@ void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) {
307308
}
308309

309310
void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) {
310-
if (state == ExtUI::PROBE_FINISH) {
311-
screen_data.BedMeshScreen.highlightedTag = pointToTag(x, y);
312-
screen_data.BedMeshScreen.count++;
311+
switch(state) {
312+
case ExtUI::MESH_START:
313+
screen_data.BedMeshScreen.count = 0;
314+
screen_data.BedMeshScreen.showMappingDone = false;
315+
break;
316+
case ExtUI::MESH_FINISH:
317+
screen_data.BedMeshScreen.count = GRID_MAX_POINTS;
318+
screen_data.BedMeshScreen.showMappingDone = true;
319+
break;
320+
case ExtUI::PROBE_START:
321+
screen_data.BedMeshScreen.highlightedTag = pointToTag(x, y);
322+
break;
323+
case ExtUI::PROBE_FINISH:
324+
screen_data.BedMeshScreen.count++;
325+
break;
313326
}
314327
BedMeshScreen::onMeshUpdate(x, y, 0);
315328
}
316329

330+
void BedMeshScreen::startMeshProbe() {
331+
GOTO_SCREEN(BedMeshScreen);
332+
screen_data.BedMeshScreen.count = 0;
333+
injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
334+
}
335+
317336
#endif // TOUCH_UI_FTDI_EVE && HAS_MESH

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

+20-15
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030
#include "../ftdi_eve_lib/extras/poly_ui.h"
3131

32-
#ifdef TOUCH_UI_PORTRAIT
32+
#if ENABLED(TOUCH_UI_COCOA_PRESS)
33+
#include "cocoa_press_ui.h"
34+
#elif ENABLED(TOUCH_UI_PORTRAIT)
3335
#include "bio_printer_ui_portrait.h"
3436
#else
3537
#include "bio_printer_ui_landscape.h"
@@ -100,7 +102,7 @@ void StatusScreen::draw_temperature(draw_mode_t what) {
100102
// heating zones, but has no bed temperature
101103

102104
cmd.cmd(COLOR_RGB(bg_text_enabled));
103-
cmd.font(font_medium);
105+
cmd.font(font_xsmall);
104106

105107
ui.bounds(POLY(h0_label), x, y, h, v);
106108
cmd.text(x, y, h, v, GET_TEXT_F(MSG_ZONE_1));
@@ -221,7 +223,7 @@ void StatusScreen::draw_syringe(draw_mode_t what) {
221223
ui.color(syringe_rgb);
222224
ui.fill(POLY(syringe_outline));
223225

224-
ui.color(fill_rgb);
226+
ui.color(fluid_rgb);
225227
ui.bounds(POLY(syringe_fluid), x, y, h, v);
226228
cmd.cmd(SAVE_CONTEXT());
227229
cmd.cmd(SCISSOR_XY(x,y + v * (1.0 - fill_level)));
@@ -245,23 +247,25 @@ void StatusScreen::draw_arrows(draw_mode_t what) {
245247
ui.button_stroke(stroke_rgb, 28);
246248
ui.button_shadow(shadow_rgb, shadow_depth);
247249

250+
constexpr uint8_t style = TERN(TOUCH_UI_COCOA_PRESS, PolyUI::FILL | PolyUI::SHADOW, PolyUI::REGULAR);
251+
248252
if ((what & BACKGROUND) || jog_xy) {
249-
ui.button(1, POLY(x_neg));
250-
ui.button(2, POLY(x_pos));
251-
ui.button(3, POLY(y_neg));
252-
ui.button(4, POLY(y_pos));
253+
ui.button(1, POLY(x_neg), style);
254+
ui.button(2, POLY(x_pos), style);
255+
ui.button(3, POLY(y_neg), style);
256+
ui.button(4, POLY(y_pos), style);
253257
}
254258

255259
if ((what & BACKGROUND) || z_homed) {
256-
ui.button(5, POLY(z_neg));
257-
ui.button(6, POLY(z_pos));
260+
ui.button(5, POLY(z_neg), style);
261+
ui.button(6, POLY(z_pos), style);
258262
}
259263

260264
if ((what & BACKGROUND) || e_homed) {
261265
#if DISABLED(TOUCH_UI_COCOA_PRESS)
262-
ui.button(7, POLY(e_neg));
266+
ui.button(7, POLY(e_neg), style);
263267
#endif
264-
ui.button(8, POLY(e_pos));
268+
ui.button(8, POLY(e_pos), style);
265269
}
266270
}
267271

@@ -300,13 +304,14 @@ void StatusScreen::draw_overlay_icons(draw_mode_t what) {
300304
PolyUI ui(cmd, what);
301305

302306
if (what & FOREGROUND) {
303-
ui.button_fill (fill_rgb);
307+
ui.button_fill (TERN(TOUCH_UI_COCOA_PRESS, stroke_rgb, fill_rgb);
304308
ui.button_stroke(stroke_rgb, 28);
305309
ui.button_shadow(shadow_rgb, shadow_depth);
306310

307-
if (!jog_xy) ui.button(12, POLY(padlock));
308-
if (!e_homed) ui.button(13, POLY(home_e));
309-
if (!z_homed) ui.button(14, POLY(home_z));
311+
constexpr uint8_t style = TERN(TOUCH_UI_COCOA_PRESS, PolyUI::FILL | PolyUI::SHADOW, PolyUI::REGULAR);
312+
if (!jog_xy) ui.button(12, POLY(padlock), style);
313+
if (!e_homed) ui.button(13, POLY(home_e), style);
314+
if (!z_homed) ui.button(14, POLY(home_z), style);
310315
}
311316
}
312317

0 commit comments

Comments
 (0)