Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New "Leveling" menu in Touch UI; Assorted Fixes #19349

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@
uint8_t count = GRID_MAX_POINTS;

mesh_index_pair best;
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_START));
do {
if (do_ubl_mesh_map) display_map(g29_map_type);

Expand Down Expand Up @@ -775,6 +776,8 @@

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

TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::MESH_FINISH));

// Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
TERN_(HAS_LCD_MENU, ui.release());
probe.stow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* GNU General Public License for more details. *
* *
* To view a copy of the GNU General Public License, go to the following *
* location: <https://www.gnu.org/licenses/>. *
* location: <https://www.gnu.org/licenses/>. *
****************************************************************************/

#pragma once
Expand All @@ -36,7 +36,7 @@
*
* PolyReader r(data, N_ELEMENTS(data));
*
* for(r.start();r.has_more(); r.next()) {
* for (r.start();r.has_more(); r.next()) {
* uint16_t x = r.x;
* uint16_t y = r.y;
*
Expand Down Expand Up @@ -107,8 +107,8 @@ class PolyReader {
}
}

bool has_more() {return p != NULL;}
bool end_of_loop() {return start_x == eol;}
bool has_more() { return p != NULL; }
bool end_of_loop() { return start_x == eol; }
};

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

// First two rows of 3x3 transformation matrix
fix_t a, b, c;
Expand Down Expand Up @@ -254,6 +254,13 @@ class GenericPolyUI {
draw_mode_t mode;

public:
enum ButtonStyle : uint8_t {
FILL = 1,
STROKE = 2,
SHADOW = 4,
REGULAR = 7
};

typedef POLY_READER poly_reader_t;

GenericPolyUI(CommandProcessor &c, draw_mode_t what = BOTH) : cmd(c), mode(what) {}
Expand All @@ -276,7 +283,7 @@ class GenericPolyUI {
Polygon p(cmd);
p.begin_fill();
p.begin_loop();
for(r.start();r.has_more();r.next()) {
for (r.start();r.has_more();r.next()) {
p(r.x * 16, r.y * 16);
if (r.end_of_loop()) {
p.end_loop();
Expand Down Expand Up @@ -306,7 +313,7 @@ class GenericPolyUI {
Polygon p(cmd);
p.begin_stroke();
p.begin_loop();
for(r.start();r.has_more(); r.next()) {
for (r.start();r.has_more(); r.next()) {
p(r.x * 16, r.y * 16);
if (r.end_of_loop()) {
p.end_loop();
Expand All @@ -323,7 +330,7 @@ class GenericPolyUI {
int16_t y_min = INT16_MAX;
int16_t x_max = INT16_MIN;
int16_t y_max = INT16_MIN;
for(r.start(); r.has_more(); r.next()) {
for (r.start(); r.has_more(); r.next()) {
x_min = min(x_min, int16_t(r.x));
x_max = max(x_max, int16_t(r.x));
y_min = min(y_min, int16_t(r.y));
Expand Down Expand Up @@ -355,11 +362,11 @@ class GenericPolyUI {
btn_shadow_depth = depth;
}

void button(const uint8_t tag, poly_reader_t r) {
void button(const uint8_t tag, poly_reader_t r, uint8_t style = REGULAR) {
using namespace FTDI;
// Draw the shadow
#if FTDI_API_LEVEL >= 810
if (mode & BACKGROUND) {
if (mode & BACKGROUND && style & SHADOW) {
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(TAG(tag));
cmd.cmd(VERTEX_TRANSLATE_X(btn_shadow_depth * 16));
Expand All @@ -381,11 +388,15 @@ class GenericPolyUI {
#endif
// Draw the fill and stroke
cmd.cmd(TAG(tag));
cmd.cmd(COLOR_RGB(btn_fill_color));
fill(r, false);
cmd.cmd(COLOR_RGB(btn_stroke_color));
cmd.cmd(LINE_WIDTH(btn_stroke_width));
stroke(r);
if (style & FILL) {
cmd.cmd(COLOR_RGB(btn_fill_color));
fill(r, false);
}
if (style & STROKE) {
cmd.cmd(COLOR_RGB(btn_stroke_color));
cmd.cmd(LINE_WIDTH(btn_stroke_width));
stroke(r);
}
cmd.cmd(RESTORE_CONTEXT());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ namespace Language_en {
PROGMEM Language_Str MSG_TOUCH_CALIBRATION_PROMPT = u8"Touch the dots to calibrate";
PROGMEM Language_Str MSG_AUTOLEVEL_X_AXIS = u8"Level X Axis";
PROGMEM Language_Str MSG_BED_MAPPING_DONE = u8"Bed mapping finished";
PROGMEM Language_Str MSG_RESET_BLTOUCH = u8"Reset BLTouch";
PROGMEM Language_Str MSG_LEVELING = u8"Leveling";
PROGMEM Language_Str MSG_SHOW_MESH = u8"Show Bed Mesh";

#ifdef TOUCH_UI_LULZBOT_BIO
PROGMEM Language_Str MSG_MOVE_TO_HOME = u8"Move to Home";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
#define ACCELERATION_POS BTN_POS(2,5), BTN_SIZE(1,1)
#define ENDSTOPS_POS BTN_POS(1,6), BTN_SIZE(1,1)
#define JERK_POS BTN_POS(2,6), BTN_SIZE(1,1)
#define OFFSETS_POS BTN_POS(1,7), BTN_SIZE(1,1)
#define CASE_LIGHT_POS BTN_POS(1,7), BTN_SIZE(1,1)
#define BACKLASH_POS BTN_POS(2,7), BTN_SIZE(1,1)
#define CASE_LIGHT_POS BTN_POS(1,8), BTN_SIZE(1,1)
#define OFFSETS_POS BTN_POS(1,8), BTN_SIZE(1,1)
#define TMC_HOMING_THRS_POS BTN_POS(2,8), BTN_SIZE(1,1)
#if EITHER(CASE_LIGHT_ENABLE, SENSORLESS_HOMING)
#if EITHER(HAS_MULTI_HOTEND, SENSORLESS_HOMING)
#define BACK_POS BTN_POS(1,9), BTN_SIZE(2,1)
#else
#define BACK_POS BTN_POS(1,8), BTN_SIZE(2,1)
Expand Down Expand Up @@ -98,8 +98,8 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
.tag(13).button( TMC_CURRENT_POS, GET_TEXT_F(MSG_TMC_CURRENT))
.enabled(ENABLED(SENSORLESS_HOMING))
.tag(14).button( TMC_HOMING_THRS_POS, GET_TEXT_F(MSG_TMC_HOMING_THRS))
.enabled(EITHER(HAS_MULTI_HOTEND, BLTOUCH))
.tag(4) .button( OFFSETS_POS, GET_TEXT_F(TERN(HAS_MULTI_HOTEND, MSG_OFFSETS_MENU, MSG_RESET_BLTOUCH)))
.enabled(ENABLED(HAS_MULTI_HOTEND))
.tag(4) .button( OFFSETS_POS, GET_TEXT_F(MSG_OFFSETS_MENU))
.enabled(EITHER(LIN_ADVANCE, FILAMENT_RUNOUT_SENSOR))
.tag(11).button( FILAMENT_POS, GET_TEXT_F(MSG_FILAMENT))
.tag(12).button( ENDSTOPS_POS, GET_TEXT_F(MSG_LCD_ENDSTOPS))
Expand All @@ -123,13 +123,9 @@ bool AdvancedSettingsMenu::onTouchEnd(uint8_t tag) {
case 2: GOTO_SCREEN(ZOffsetScreen); break;
#endif
case 3: GOTO_SCREEN(StepsScreen); break;
case 4:
#if HAS_MULTI_HOTEND
GOTO_SCREEN(NozzleOffsetScreen);
#elif ENABLED(BLTOUCH)
injectCommands_P(PSTR("M280 P0 S60"));
#endif
break;
#if ENABLED(HAS_MULTI_HOTEND)
case 4: GOTO_SCREEN(NozzleOffsetScreen); break;
#endif
case 5: GOTO_SCREEN(MaxVelocityScreen); break;
case 6: GOTO_SCREEN(DefaultAccelerationScreen); break;
case 7: GOTO_SCREEN(TERN(HAS_JUNCTION_DEVIATION, JunctionDeviationScreen, JerkScreen)); break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ bool BedMeshScreen::tagToPoint(uint8_t tag, uint8_t &x, uint8_t &y) {

void BedMeshScreen::onEntry() {
screen_data.BedMeshScreen.highlightedTag = 0;
screen_data.BedMeshScreen.count = 0;
screen_data.BedMeshScreen.count = GRID_MAX_POINTS;
screen_data.BedMeshScreen.showMappingDone = false;
BaseScreen::onEntry();
}

Expand Down Expand Up @@ -251,6 +252,10 @@ void BedMeshScreen::drawHighlightedPointValue() {
.colors(action_btn)
.tag(1).button( OKAY_POS, GET_TEXT_F(MSG_BUTTON_OKAY))
.tag(0);

if (screen_data.BedMeshScreen.showMappingDone) {
cmd.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE));
}
}

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

if (what & FOREGROUND) {
constexpr float autoscale_max_amplitude = 0.03;
const bool levelingFinished = screen_data.BedMeshScreen.count >= GRID_MAX_POINTS;
const float levelingProgress = sq(float(screen_data.BedMeshScreen.count) / GRID_MAX_POINTS);
if (levelingFinished) {
const bool gotAllPoints = screen_data.BedMeshScreen.count >= GRID_MAX_POINTS;
if (gotAllPoints) {
drawHighlightedPointValue();
CommandProcessor cmd;
cmd.font(Theme::font_medium)
.text(MESSAGE_POS, GET_TEXT_F(MSG_BED_MAPPING_DONE));
}

const float levelingProgress = sq(float(screen_data.BedMeshScreen.count) / GRID_MAX_POINTS);
BedMeshScreen::drawMesh(INSET_POS(MESH_POS), ExtUI::getMeshArray(),
USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (levelingFinished ? USE_COLORS : 0),
USE_POINTS | USE_HIGHLIGHT | USE_AUTOSCALE | (gotAllPoints ? USE_COLORS : 0),
autoscale_max_amplitude * levelingProgress
);
}
Expand All @@ -307,11 +308,29 @@ void BedMeshScreen::onMeshUpdate(const int8_t, const int8_t, const float) {
}

void BedMeshScreen::onMeshUpdate(const int8_t x, const int8_t y, const ExtUI::probe_state_t state) {
if (state == ExtUI::PROBE_FINISH) {
screen_data.BedMeshScreen.highlightedTag = pointToTag(x, y);
screen_data.BedMeshScreen.count++;
switch(state) {
case ExtUI::MESH_START:
screen_data.BedMeshScreen.count = 0;
screen_data.BedMeshScreen.showMappingDone = false;
break;
case ExtUI::MESH_FINISH:
screen_data.BedMeshScreen.count = GRID_MAX_POINTS;
screen_data.BedMeshScreen.showMappingDone = true;
break;
case ExtUI::PROBE_START:
screen_data.BedMeshScreen.highlightedTag = pointToTag(x, y);
break;
case ExtUI::PROBE_FINISH:
screen_data.BedMeshScreen.count++;
break;
}
BedMeshScreen::onMeshUpdate(x, y, 0);
}

void BedMeshScreen::startMeshProbe() {
GOTO_SCREEN(BedMeshScreen);
screen_data.BedMeshScreen.count = 0;
injectCommands_P(PSTR(BED_LEVELING_COMMANDS));
}

#endif // TOUCH_UI_FTDI_EVE && HAS_MESH
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

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

#ifdef TOUCH_UI_PORTRAIT
#if ENABLED(TOUCH_UI_COCOA_PRESS)
#include "cocoa_press_ui.h"
#elif ENABLED(TOUCH_UI_PORTRAIT)
#include "bio_printer_ui_portrait.h"
#else
#include "bio_printer_ui_landscape.h"
Expand Down Expand Up @@ -100,7 +102,7 @@ void StatusScreen::draw_temperature(draw_mode_t what) {
// heating zones, but has no bed temperature

cmd.cmd(COLOR_RGB(bg_text_enabled));
cmd.font(font_medium);
cmd.font(font_xsmall);

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

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

constexpr uint8_t style = TERN(TOUCH_UI_COCOA_PRESS, PolyUI::FILL | PolyUI::SHADOW, PolyUI::REGULAR);

if ((what & BACKGROUND) || jog_xy) {
ui.button(1, POLY(x_neg));
ui.button(2, POLY(x_pos));
ui.button(3, POLY(y_neg));
ui.button(4, POLY(y_pos));
ui.button(1, POLY(x_neg), style);
ui.button(2, POLY(x_pos), style);
ui.button(3, POLY(y_neg), style);
ui.button(4, POLY(y_pos), style);
}

if ((what & BACKGROUND) || z_homed) {
ui.button(5, POLY(z_neg));
ui.button(6, POLY(z_pos));
ui.button(5, POLY(z_neg), style);
ui.button(6, POLY(z_pos), style);
}

if ((what & BACKGROUND) || e_homed) {
#if DISABLED(TOUCH_UI_COCOA_PRESS)
ui.button(7, POLY(e_neg));
ui.button(7, POLY(e_neg), style);
#endif
ui.button(8, POLY(e_pos));
ui.button(8, POLY(e_pos), style);
}
}

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

if (what & FOREGROUND) {
ui.button_fill (fill_rgb);
ui.button_fill (TERN(TOUCH_UI_COCOA_PRESS, stroke_rgb, fill_rgb);
ui.button_stroke(stroke_rgb, 28);
ui.button_shadow(shadow_rgb, shadow_depth);

if (!jog_xy) ui.button(12, POLY(padlock));
if (!e_homed) ui.button(13, POLY(home_e));
if (!z_homed) ui.button(14, POLY(home_z));
constexpr uint8_t style = TERN(TOUCH_UI_COCOA_PRESS, PolyUI::FILL | PolyUI::SHADOW, PolyUI::REGULAR);
if (!jog_xy) ui.button(12, POLY(padlock), style);
if (!e_homed) ui.button(13, POLY(home_e), style);
if (!z_homed) ui.button(14, POLY(home_z), style);
}
}

Expand Down
Loading