Skip to content

Commit

Permalink
update gcode_preview_nopro, meshviewer, various
Browse files Browse the repository at this point in the history
  • Loading branch information
classicrocker883 committed Sep 3, 2023
1 parent 4d9ee18 commit 01f266e
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 49 deletions.
3 changes: 1 addition & 2 deletions Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ void GcodeSuite::M48() {

#if HAS_STATUS_MESSAGE
// Display M48 results in the status bar
char sigma_str[8];
ui.status_printf(0, F(S_FMT ": %s"), GET_TEXT(MSG_M48_DEVIATION), dtostrf(sigma, 2, 6, sigma_str));
ui.set_status_and_level(MString<30>(GET_TEXT_F(MSG_M48_DEVIATION), F(": "), w_float_t(sigma, 2, 6)));
#endif
}

Expand Down
6 changes: 2 additions & 4 deletions Marlin/src/gcode/host/M114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,17 @@
#if ENABLED(M114_DETAIL)

void report_all_axis_pos(const xyze_pos_t &pos, const uint8_t n=LOGICAL_AXES, const uint8_t precision=3) {
char str[12];
for (uint8_t a = 0; a < n; ++a) {
SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[a]));
if (pos[a] >= 0) SERIAL_CHAR(' ');
SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
SERIAL_ECHO(p_float_t(pos[a], precision));
}
SERIAL_EOL();
}
inline void report_linear_axis_pos(const xyze_pos_t &pos) { report_all_axis_pos(pos, XYZ); }

void report_linear_axis_pos(const xyz_pos_t &pos, const uint8_t precision=3) {
char str[12];
LOOP_NUM_AXES(a) SERIAL_ECHOPGM_P((PGM_P)pgm_read_ptr(&SP_AXIS_LBL[a]), dtostrf(pos[a], 1, precision, str));
LOOP_NUM_AXES(a) SERIAL_ECHO(FPSTR(pgm_read_ptr(&SP_AXIS_LBL[a])), p_float_t(pos[a], precision));
SERIAL_EOL();
}

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/lcd/e3v2/proui/custom_gcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void C108() {
}

// Enable or disable preview screen
#if ENABLED(HAS_GCODE_PREVIEW) || ENABLED(HAS_GCODE_PREVIEW_NOPRO)
#if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO
void C250() {
if (parser.seenval('P')) {
HMI_data.EnablePreview = !!parser.value_byte();
Expand Down Expand Up @@ -120,7 +120,7 @@ void custom_gcode(const int16_t codenum) {
case 35: C35(); break; // Launch bed tramming wizard
#endif
case 108: C108(); break; // Cancel a Wait for User without an Emergecy Parser
#if ENABLED(HAS_GCODE_PREVIEW) || ENABLED(HAS_GCODE_PREVIEW_NOPRO)
#if HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO
case 250: C250(); break; // Enable or disable preview screen
#endif
#if HAS_LOCKSCREEN
Expand Down
14 changes: 8 additions & 6 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

#if HAS_MEDIA
#include "../../../sd/cardreader.h"
#include "file_header.h"
#endif

#if NEED_HEX_PRINT
Expand Down Expand Up @@ -98,6 +97,7 @@
#endif

#if HAS_GCODE_PREVIEW
#include "file_header.h"
#include "gcode_preview.h"
#elif HAS_GCODE_PREVIEW_NOPRO
#include "gcode_preview_nopro.h"
Expand Down Expand Up @@ -949,6 +949,7 @@ void onClickSDItem() {
if (card.fileIsBinary())
return DWIN_Popup_Confirm(ICON_Error, F("Please check filenames"), F("Only G-code can be printed"));
else
DWIN_Print_Header(card.longest_filename()); // Save filename
return Goto_ConfirmToPrint();
}
}
Expand Down Expand Up @@ -2010,7 +2011,8 @@ void DWIN_SetDataDefaults() {
#endif
#endif
TERN_(ADAPTIVE_STEP_SMOOTHING, HMI_data.AdaptiveStepSmoothing = true;)
TERN_(HAS_GCODE_PREVIEW || HAS_GCODE_PREVIEW_NOPRO, HMI_data.EnablePreview = true;)
TERN_(HAS_GCODE_PREVIEW, HMI_data.EnablePreview = true;)
TERN_(HAS_GCODE_PREVIEW_NOPRO, HMI_data.EnablePreview = true;)
#if PROUI_EX
PRO_data.x_bed_size = DEF_X_BED_SIZE;
PRO_data.y_bed_size = DEF_Y_BED_SIZE;
Expand Down Expand Up @@ -2264,7 +2266,7 @@ void DWIN_RedrawScreen() {
return card.openAndPrintFile(card.filename);
}
else {
return HMI_ReturnScreen();
HMI_ReturnScreen();
}
}

Expand Down Expand Up @@ -4391,7 +4393,7 @@ void Draw_AdvancedSettings_Menu() {
#endif
#if ENABLED(USE_GRID_MESHVIEWER)
MENU_ITEM(ICON_Level, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer);
EDIT_ITEM(ICON_PrintSize, MSG_CHANGE_MESH_VIEWER, onDrawChkbMenu, SetViewMesh, &bedLevelTools.view_mesh);
EDIT_ITEM(ICON_PrintSize, MSG_CHANGE_MESH, onDrawChkbMenu, SetViewMesh, &bedLevelTools.view_mesh);
#endif
EDIT_ITEM(ICON_UBLSlot, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot);
MENU_ITEM(ICON_UBLSaveMesh, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLMeshSave);
Expand Down Expand Up @@ -4420,7 +4422,7 @@ void Draw_AdvancedSettings_Menu() {
MENU_ITEM(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLevStart);
#if ENABLED(USE_GRID_MESHVIEWER)
MENU_ITEM(ICON_Level, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer);
EDIT_ITEM(ICON_PrintSize, MSG_CHANGE_MESH_VIEWER, onDrawChkbMenu, SetViewMesh, &bedLevelTools.view_mesh);
EDIT_ITEM(ICON_PrintSize, MSG_CHANGE_MESH, onDrawChkbMenu, SetViewMesh, &bedLevelTools.view_mesh);
#endif
#if ENABLED(MESH_EDIT_MENU)
MENU_ITEM(ICON_UBLActive, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu);
Expand All @@ -4443,7 +4445,7 @@ void Draw_AdvancedSettings_Menu() {
MENU_ITEM(ICON_PrintSize, MSG_MESH_LEVELING, onDrawSubMenu, Draw_MeshSet_Menu);
#if ENABLED(USE_GRID_MESHVIEWER)
MENU_ITEM(ICON_Level, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer);
EDIT_ITEM(ICON_PrintSize, MSG_CHANGE_MESH_VIEWER, onDrawChkbMenu, SetViewMesh, &bedLevelTools.view_mesh);
EDIT_ITEM(ICON_PrintSize, MSG_CHANGE_MESH, onDrawChkbMenu, SetViewMesh, &bedLevelTools.view_mesh);
#endif
#if ENABLED(MESH_EDIT_MENU)
MENU_ITEM(ICON_UBLActive, MSG_EDIT_MESH, onDrawSubMenu, Draw_EditMesh_Menu);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/proui/gcode_preview_nopro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ typedef struct {

} fileprop_t;

fileprop_t fileprop;
extern fileprop_t fileprop;

void getValue(const char * const buf, PGM_P const key, float &value) {
if (value != 0.0f) return;
Expand Down
47 changes: 19 additions & 28 deletions Marlin/src/lcd/e3v2/proui/meshviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void MeshViewerClass::DrawMeshPoint(const uint8_t x, const uint8_t y, const floa
ui.refresh_backlight_timeout();
#endif
const uint8_t fs = DWINUI::fontWidth(meshfont);
int16_t v = round(z * 100);
const int16_t v = round(z * 100);
NOLESS(max, z); NOMORE(min, z);
const uint16_t color = DWINUI::RainbowInt(v, zmin, zmax);
DWINUI::Draw_FillCircle(color, px(x), py(y), r(_MAX(_MIN(v, zmax), zmin)));
Expand All @@ -100,30 +100,30 @@ void MeshViewerClass::DrawMeshPoint(const uint8_t x, const uint8_t y, const floa
SERIAL_FLUSH();
}

void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey) {
void MeshViewerClass::DrawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey) {
DrawMeshGrid(csizex, csizey);
for (uint8_t y = 0; y < csizey; ++y) {
hal.watchdog_refresh();
for (uint8_t x = 0; x < csizex; ++x) DrawMeshPoint(x, y, zval[x][y]);
}
}

void MeshViewerClass::Draw(bool withsave/*=false*/, bool redraw/*=true*/) {
void MeshViewerClass::Draw(const bool withsave/*=false*/, const bool redraw/*=true*/) {
Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER));
#if ENABLED(USE_GRID_MESHVIEWER)
if(bedLevelTools.view_mesh) {

const bool see_mesh = TERN0(USE_GRID_MESHVIEWER, bedLevelTools.view_mesh);
if (see_mesh) {
#if USE_GRID_MESHVIEWER
DWINUI::ClearMainArea();
bedLevelTools.viewer_print_value = true;
bedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT);
}
else {
if (redraw) DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
else DWINUI::Draw_Box(1, HMI_data.Background_Color, {89,305,99,38});
}
#else
#endif
}
else {
if (redraw) DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
else DWINUI::Draw_Box(1, HMI_data.Background_Color, {89,305,99,38});
#endif
}

if (withsave) {
DWIN_Draw_Box(1, HMI_data.Background_Color, 120, 300, 31, 42); // draw black box to fill previous button select_box
DWINUI::Draw_Button(BTN_Continue, 146, 305);
Expand All @@ -133,24 +133,15 @@ void MeshViewerClass::Draw(bool withsave/*=false*/, bool redraw/*=true*/) {
else {
DWINUI::Draw_Button(BTN_Continue, 86, 305, true);
}
#if ENABLED(USE_GRID_MESHVIEWER)
if(bedLevelTools.view_mesh) {
bedLevelTools.Set_Mesh_Viewer_Status();

if (see_mesh) {
TERN_(USE_GRID_MESHVIEWER, bedLevelTools.Set_Mesh_Viewer_Status();)
}
else {
char str_1[6], str_2[6] = "";
ui.status_printf(0, F("minZ: %s | maxZ: +%s"),
dtostrf(min, 1, 3, str_1),
dtostrf(max, 1, 3, str_2)
);
}
#else
char str_1[6], str_2[6] = "";
ui.status_printf(0, F("minZ: %s | maxZ: +%s"),
dtostrf(min, 1, 3, str_1),
dtostrf(max, 1, 3, str_2)
else {
ui.set_status_and_level(MString<32>(
F("Zmin: "), p_float_t(min, 3), F(" | "), p_float_t(max, 3), F("+"), F(" :Zmax"))
);
#endif
}
}

void Draw_MeshViewer() { MeshViewer.Draw(true, meshredraw); }
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/e3v2/proui/meshviewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class MeshViewerClass {
static float max, min;
static void DrawMeshGrid(const uint8_t csizex, const uint8_t csizey);
static void DrawMeshPoint(const uint8_t x, const uint8_t y, const float z);
static void Draw(bool withsave = false, bool redraw = true);
static void DrawMesh(bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey);
static void Draw(const bool withsave=false, const bool redraw=true);
static void DrawMesh(const bed_mesh_t zval, const uint8_t csizex, const uint8_t csizey);
};

extern MeshViewerClass MeshViewer;

void Goto_MeshViewer(bool redraw);
void Goto_MeshViewer(const bool redraw);
2 changes: 2 additions & 0 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,8 @@ void MarlinUI::host_notify(const char * const cstr) {
pgm ? host_notify_P(ustr) : host_notify(ustr);
}
void MarlinUI::status_printf_P(int8_t level, PGM_P const fmt, ...) {
if (set_alert_level(level)) return;

MString<30> msg;

va_list args;
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,23 +474,23 @@ class MarlinUI {
* @param fstr A constant F-string to set as the status.
* @param level Alert level. Negative to ignore and reset the level. Non-zero never expires.
*/
static void set_status_and_level(const char * const cstr, const int8_t level) { _set_status_and_level(cstr, level, false); }
static void set_status_and_level(const char * const cstr, const int8_t level=0) { _set_status_and_level(cstr, level, false); }

/**
* @brief Set Status with a P-string and alert level.
*
* @param ustr A C- or P-string, according to pgm.
* @param level Alert level. Negative to ignore and reset the level. Non-zero never expires.
*/
static void set_status_and_level_P(PGM_P const pstr, const int8_t level) { _set_status_and_level(pstr, level, true); }
static void set_status_and_level_P(PGM_P const pstr, const int8_t level=0) { _set_status_and_level(pstr, level, true); }

/**
* @brief Set Status with a fixed string and alert level.
*
* @param fstr A constant F-string to set as the status.
* @param level Alert level. Negative to ignore and reset the level. Non-zero never expires.
*/
static void set_status_and_level(FSTR_P const fstr, const int8_t level) { set_status_and_level_P(FTOP(fstr), level); }
static void set_status_and_level(FSTR_P const fstr, const int8_t level=0) { set_status_and_level_P(FTOP(fstr), level); }

static void set_max_status(FSTR_P const fstr) { set_status_and_level(fstr, 127); }
static void set_min_status(FSTR_P const fstr) { set_status_and_level(fstr, -1); }
Expand Down

0 comments on commit 01f266e

Please sign in to comment.