🚸 ProUI APRIL2022 updates (#24084)
This commit is contained in:
committed by
Scott Lahteine
parent
310ff23676
commit
a65e4edb1c
@@ -23,8 +23,8 @@
|
||||
/**
|
||||
* Mesh Viewer for PRO UI
|
||||
* Author: Miguel A. Risco-Castillo (MRISCOC)
|
||||
* version: 3.12.1
|
||||
* Date: 2022/02/24
|
||||
* version: 3.14.1
|
||||
* Date: 2022/04/11
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
@@ -41,6 +41,10 @@
|
||||
#include "dwin_popup.h"
|
||||
#include "../../../feature/bedlevel/bedlevel.h"
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
#include "ubl_tools.h"
|
||||
#endif
|
||||
|
||||
MeshViewerClass MeshViewer;
|
||||
|
||||
void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8_t sizey) {
|
||||
@@ -56,17 +60,15 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8
|
||||
#define DrawMeshValue(xp, yp, zv) DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(xp) - 18, py(yp) - 6, zv)
|
||||
#define DrawMeshHLine(yp) DWIN_Draw_HLine(HMI_data.SplitLine_Color, px(0), py(yp), DWIN_WIDTH - 2 * mx)
|
||||
#define DrawMeshVLine(xp) DWIN_Draw_VLine(HMI_data.SplitLine_Color, px(xp), py(sizey - 1), DWIN_WIDTH - 2 * my)
|
||||
int16_t maxz =-32000; int16_t minz = 32000; avg = 0;
|
||||
int16_t maxz =-32000; int16_t minz = 32000;
|
||||
LOOP_L_N(y, sizey) LOOP_L_N(x, sizex) {
|
||||
const float v = isnan(zval[x][y]) ? 0 : round(zval[x][y] * 100);
|
||||
zmesh[x][y] = v;
|
||||
avg += v;
|
||||
NOLESS(maxz, v);
|
||||
NOMORE(minz, v);
|
||||
}
|
||||
max = (float)maxz / 100;
|
||||
min = (float)minz / 100;
|
||||
avg = avg / (100 * sizex * sizey);
|
||||
DWINUI::ClearMainArea();
|
||||
DWIN_Draw_Rectangle(0, HMI_data.SplitLine_Color, px(0), py(0), px(sizex - 1), py(sizey - 1));
|
||||
LOOP_S_L_N(x, 1, sizex - 1) DrawMeshVLine(x);
|
||||
@@ -77,8 +79,10 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8
|
||||
uint16_t color = DWINUI::RainbowInt(zmesh[x][y], _MIN(-5, minz), _MAX(5, maxz));
|
||||
uint8_t radius = rm(zmesh[x][y]);
|
||||
DWINUI::Draw_FillCircle(color, px(x), py(y), radius);
|
||||
if (sizex < 9)
|
||||
DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 18, py(y) - 6, zval[x][y]);
|
||||
if (sizex < 9) {
|
||||
if (zmesh[x][y] == 0) DWINUI::Draw_Float(font6x12, 1, 2, px(x) - 12, py(y) - 6, 0);
|
||||
else DWINUI::Draw_Signed_Float(font6x12, 1, 2, px(x) - 18, py(y) - 6, zval[x][y]);
|
||||
}
|
||||
else {
|
||||
char str_1[9];
|
||||
str_1[0] = 0;
|
||||
@@ -108,7 +112,13 @@ void MeshViewerClass::DrawMesh(bed_mesh_t zval, const uint8_t sizex, const uint8
|
||||
|
||||
void MeshViewerClass::Draw(bool withsave /*= false*/) {
|
||||
Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER));
|
||||
DrawMesh(Z_VALUES_ARR, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
|
||||
#if ENABLED(USE_UBL_VIEWER)
|
||||
DWINUI::ClearMainArea();
|
||||
ubl_tools.viewer_print_value = true;
|
||||
ubl_tools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT);
|
||||
#else
|
||||
DrawMesh(Z_VALUES_ARR, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
|
||||
#endif
|
||||
if (withsave) {
|
||||
DWINUI::Draw_Button(BTN_Save, 26, 305);
|
||||
DWINUI::Draw_Button(BTN_Continue, 146, 305);
|
||||
@@ -117,15 +127,19 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) {
|
||||
else
|
||||
DWINUI::Draw_Button(BTN_Continue, 86, 305);
|
||||
|
||||
char str_1[6], str_2[6] = "";
|
||||
ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"),
|
||||
dtostrf(min, 1, 2, str_1),
|
||||
dtostrf(max, 1, 2, str_2)
|
||||
);
|
||||
#if ENABLED(USE_UBL_VIEWER)
|
||||
ubl_tools.Set_Mesh_Viewer_Status();
|
||||
#else
|
||||
char str_1[6], str_2[6] = "";
|
||||
ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"),
|
||||
dtostrf(min, 1, 2, str_1),
|
||||
dtostrf(max, 1, 2, str_2)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Draw_MeshViewer() { MeshViewer.Draw(true); }
|
||||
void onClick_MeshViewer() { if (HMI_flag.select_flag) WriteEeprom(); HMI_ReturnScreen(); }
|
||||
void Goto_MeshViewer() { if (leveling_is_valid()) Goto_Popup(Draw_MeshViewer, onClick_MeshViewer); else HMI_ReturnScreen(); }
|
||||
void onClick_MeshViewer() { if (HMI_flag.select_flag) SaveMesh(); HMI_ReturnScreen(); }
|
||||
void Goto_MeshViewer() { if (leveling_is_valid()) Goto_Popup(Draw_MeshViewer, onClick_MeshViewer); else HMI_ReturnScreen(); }
|
||||
|
||||
#endif // DWIN_LCD_PROUI && HAS_MESH
|
||||
|
||||
Reference in New Issue
Block a user