♻️ Common Bed Leveling object name, accessors (#24214)
This commit is contained in:
committed by
Scott Lahteine
parent
06c4a9acdb
commit
b72f9277e9
@ -1281,9 +1281,9 @@ void MarlinUI::draw_status_screen() {
|
||||
* Show X and Y positions
|
||||
*/
|
||||
_XLABEL(_PLOT_X, 0);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(bedlevel.get_mesh_x(x_plot))));
|
||||
_YLABEL(_LCD_W_POS, 0);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(bedlevel.get_mesh_y(y_plot))));
|
||||
|
||||
lcd_moveto(_PLOT_X, 0);
|
||||
|
||||
@ -1475,8 +1475,8 @@ void MarlinUI::draw_status_screen() {
|
||||
* Print Z values
|
||||
*/
|
||||
_ZLABEL(_LCD_W_POS, 1);
|
||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
else
|
||||
lcd_put_u8str(F(" -----"));
|
||||
|
||||
@ -1486,16 +1486,16 @@ void MarlinUI::draw_status_screen() {
|
||||
* Show all values at right of screen
|
||||
*/
|
||||
_XLABEL(_LCD_W_POS, 1);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(ubl.mesh_index_to_xpos(x_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(bedlevel.get_mesh_x(x_plot))));
|
||||
_YLABEL(_LCD_W_POS, 2);
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(ubl.mesh_index_to_ypos(y_plot))));
|
||||
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(bedlevel.get_mesh_y(y_plot))));
|
||||
|
||||
/**
|
||||
* Show the location value
|
||||
*/
|
||||
_ZLABEL(_LCD_W_POS, 3);
|
||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
else
|
||||
lcd_put_u8str(F(" -----"));
|
||||
|
||||
|
@ -1069,15 +1069,15 @@ void MarlinUI::draw_status_screen() {
|
||||
|
||||
// Show all values
|
||||
lcd.setCursor(_LCD_W_POS, 1); lcd_put_u8str(F("X:"));
|
||||
lcd.print(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
|
||||
lcd.print(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&bedlevel._mesh_index_to_xpos[x_plot]))));
|
||||
lcd.setCursor(_LCD_W_POS, 2); lcd_put_u8str(F("Y:"));
|
||||
lcd.print(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
|
||||
lcd.print(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&bedlevel._mesh_index_to_ypos[y_plot]))));
|
||||
|
||||
// Show the location value
|
||||
lcd.setCursor(_LCD_W_POS, 3); lcd_put_u8str(F("Z:"));
|
||||
|
||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
||||
lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
|
||||
lcd.print(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
else
|
||||
lcd_put_u8str(F(" -----"));
|
||||
|
||||
|
@ -574,9 +574,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
u8g.setColorIndex(1);
|
||||
const u8g_uint_t sx = x_offset + pixels_per_x_mesh_pnt / 2;
|
||||
u8g_uint_t y = y_offset + pixels_per_y_mesh_pnt / 2;
|
||||
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt)
|
||||
for (uint8_t j = 0; j < (GRID_MAX_POINTS_Y); j++, y += pixels_per_y_mesh_pnt)
|
||||
if (PAGE_CONTAINS(y, y))
|
||||
for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt)
|
||||
for (uint8_t i = 0, x = sx; i < (GRID_MAX_POINTS_X); i++, x += pixels_per_x_mesh_pnt)
|
||||
u8g.drawBox(x, y, 1, 1);
|
||||
|
||||
// Fill in the Specified Mesh Point
|
||||
@ -596,7 +596,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
// Show X and Y positions at top of screen
|
||||
u8g.setColorIndex(1);
|
||||
if (PAGE_UNDER(7)) {
|
||||
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
|
||||
const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) },
|
||||
lpos = pos.asLogical();
|
||||
lcd_put_u8str_P(5, 7, X_LBL);
|
||||
lcd_put_u8str(ftostr52(lpos.x));
|
||||
@ -614,8 +614,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
|
||||
|
||||
// Show the location value
|
||||
lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL);
|
||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
|
||||
lcd_put_u8str(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
else
|
||||
lcd_put_u8str(F(" -----"));
|
||||
}
|
||||
|
@ -207,11 +207,9 @@ CrealityDWINClass CrealityDWIN;
|
||||
struct linear_fit_data lsf_results;
|
||||
incremental_LSF_reset(&lsf_results);
|
||||
GRID_LOOP(x, y) {
|
||||
if (!isnan(Z_VALUES_ARR[x][y])) {
|
||||
xy_pos_t rpos;
|
||||
rpos.x = ubl.mesh_index_to_xpos(x);
|
||||
rpos.y = ubl.mesh_index_to_ypos(y);
|
||||
incremental_LSF(&lsf_results, rpos, Z_VALUES_ARR[x][y]);
|
||||
if (!isnan(bedlevel.z_values[x][y])) {
|
||||
xy_pos_t rpos = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) };
|
||||
incremental_LSF(&lsf_results, rpos, bedlevel.z_values[x][y]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,13 +218,13 @@ CrealityDWINClass CrealityDWIN;
|
||||
return true;
|
||||
}
|
||||
|
||||
ubl.set_all_mesh_points_to_value(0);
|
||||
bedlevel.set_all_mesh_points_to_value(0);
|
||||
|
||||
matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1));
|
||||
GRID_LOOP(i, j) {
|
||||
float mx = ubl.mesh_index_to_xpos(i),
|
||||
my = ubl.mesh_index_to_ypos(j),
|
||||
mz = Z_VALUES_ARR[i][j];
|
||||
float mx = bedlevel.get_mesh_x(i),
|
||||
my = bedlevel.get_mesh_y(j),
|
||||
mz = bedlevel.z_values[i][j];
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
||||
@ -250,7 +248,7 @@ CrealityDWINClass CrealityDWIN;
|
||||
DEBUG_DELAY(20);
|
||||
}
|
||||
|
||||
Z_VALUES_ARR[i][j] = mz - lsf_results.D;
|
||||
bedlevel.z_values[i][j] = mz - lsf_results.D;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -268,7 +266,7 @@ CrealityDWINClass CrealityDWIN;
|
||||
void manual_move(bool zmove=false) {
|
||||
if (zmove) {
|
||||
planner.synchronize();
|
||||
current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
||||
planner.synchronize();
|
||||
}
|
||||
@ -279,7 +277,7 @@ CrealityDWINClass CrealityDWIN;
|
||||
sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y);
|
||||
gcode.process_subcommands_now(cmd);
|
||||
planner.synchronize();
|
||||
current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
||||
planner.synchronize();
|
||||
CrealityDWIN.Redraw_Menu();
|
||||
@ -289,8 +287,8 @@ CrealityDWINClass CrealityDWIN;
|
||||
float get_max_value() {
|
||||
float max = __FLT_MIN__;
|
||||
GRID_LOOP(x, y) {
|
||||
if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] > max)
|
||||
max = Z_VALUES_ARR[x][y];
|
||||
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max)
|
||||
max = bedlevel.z_values[x][y];
|
||||
}
|
||||
return max;
|
||||
}
|
||||
@ -298,24 +296,24 @@ CrealityDWINClass CrealityDWIN;
|
||||
float get_min_value() {
|
||||
float min = __FLT_MAX__;
|
||||
GRID_LOOP(x, y) {
|
||||
if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] < min)
|
||||
min = Z_VALUES_ARR[x][y];
|
||||
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min)
|
||||
min = bedlevel.z_values[x][y];
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
void Draw_Bed_Mesh(int16_t selected = -1, uint8_t gridline_width = 1, uint16_t padding_x = 8, uint16_t padding_y_top = 40 + 53 - 7) {
|
||||
drawing_mesh = true;
|
||||
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x;
|
||||
const uint16_t cell_width_px = total_width_px / GRID_MAX_POINTS_X;
|
||||
const uint16_t cell_height_px = total_width_px / GRID_MAX_POINTS_Y;
|
||||
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x,
|
||||
cell_width_px = total_width_px / (GRID_MAX_POINTS_X),
|
||||
cell_height_px = total_width_px / (GRID_MAX_POINTS_Y);
|
||||
const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max);
|
||||
|
||||
// Clear background from previous selection and select new square
|
||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px);
|
||||
if (selected >= 0) {
|
||||
const auto selected_y = selected / GRID_MAX_POINTS_X;
|
||||
const auto selected_x = selected - (GRID_MAX_POINTS_X * selected_y);
|
||||
const auto selected_y = selected / (GRID_MAX_POINTS_X);
|
||||
const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y;
|
||||
const auto start_y_px = padding_y_top + selected_y * cell_height_px;
|
||||
const auto start_x_px = padding_x + selected_x * cell_width_px;
|
||||
DWIN_Draw_Rectangle(1, Color_White, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px);
|
||||
@ -329,11 +327,11 @@ CrealityDWINClass CrealityDWIN;
|
||||
const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px;
|
||||
const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width;
|
||||
DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
|
||||
isnan(Z_VALUES_ARR[x][y]) ? Color_Grey : ( // gray if undefined
|
||||
(Z_VALUES_ARR[x][y] < 0 ?
|
||||
(uint16_t)round(0x1F * -Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
|
||||
(uint16_t)round(0x3F * Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
|
||||
_MIN(0x1F, (((uint8_t)abs(Z_VALUES_ARR[x][y]) / 10) * 4))), // + blue stepping for every mm
|
||||
isnan(bedlevel.z_values[x][y]) ? Color_Grey : ( // gray if undefined
|
||||
(bedlevel.z_values[x][y] < 0 ?
|
||||
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
|
||||
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
|
||||
_MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm
|
||||
start_x_px, start_y_px, end_x_px, end_y_px
|
||||
);
|
||||
|
||||
@ -343,14 +341,14 @@ CrealityDWINClass CrealityDWIN;
|
||||
// Draw value text on
|
||||
if (viewer_print_value) {
|
||||
int8_t offset_x, offset_y = cell_height_px / 2 - 6;
|
||||
if (isnan(Z_VALUES_ARR[x][y])) { // undefined
|
||||
if (isnan(bedlevel.z_values[x][y])) { // undefined
|
||||
DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
|
||||
}
|
||||
else { // has value
|
||||
if (GRID_MAX_POINTS_X < 10)
|
||||
sprintf_P(buf, PSTR("%s"), dtostrf(abs(Z_VALUES_ARR[x][y]), 1, 2, str_1));
|
||||
sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1));
|
||||
else
|
||||
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(Z_VALUES_ARR[x][y] - (int16_t)Z_VALUES_ARR[x][y]) * 100));
|
||||
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100));
|
||||
offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
|
||||
if (!(GRID_MAX_POINTS_X < 10))
|
||||
DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
|
||||
@ -417,14 +415,14 @@ void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=fal
|
||||
}
|
||||
|
||||
void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options, uint8_t row, bool selected/*=false*/, bool color/*=false*/) {
|
||||
uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
|
||||
uint16_t tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
|
||||
uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black,
|
||||
tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
|
||||
DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2);
|
||||
DWIN_Draw_String(false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]);
|
||||
}
|
||||
|
||||
uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) {
|
||||
switch (color){
|
||||
switch (color) {
|
||||
case Default:
|
||||
return original;
|
||||
break;
|
||||
@ -2842,7 +2840,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_Tilt, F("Autotilt Current Mesh"));
|
||||
else {
|
||||
if (ubl.storage_slot < 0) {
|
||||
if (bedlevel.storage_slot < 0) {
|
||||
Popup_Handler(MeshSlot);
|
||||
break;
|
||||
}
|
||||
@ -2914,7 +2912,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
if (ubl.storage_slot < 0) {
|
||||
if (bedlevel.storage_slot < 0) {
|
||||
Popup_Handler(MeshSlot);
|
||||
break;
|
||||
}
|
||||
@ -2949,7 +2947,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
Draw_Menu_Item(row, ICON_Mesh, GET_TEXT(MSG_MESH_VIEW), nullptr, true);
|
||||
else {
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
if (ubl.storage_slot < 0) {
|
||||
if (bedlevel.storage_slot < 0) {
|
||||
Popup_Handler(MeshSlot);
|
||||
break;
|
||||
}
|
||||
@ -2967,16 +2965,16 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
case LEVELING_SLOT:
|
||||
if (draw) {
|
||||
Draw_Menu_Item(row, ICON_PrintSize, F("Mesh Slot"));
|
||||
Draw_Float(ubl.storage_slot, row, false, 1);
|
||||
Draw_Float(bedlevel.storage_slot, row, false, 1);
|
||||
}
|
||||
else
|
||||
Modify_Value(ubl.storage_slot, 0, settings.calc_num_meshes() - 1, 1);
|
||||
Modify_Value(bedlevel.storage_slot, 0, settings.calc_num_meshes() - 1, 1);
|
||||
break;
|
||||
case LEVELING_LOAD:
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_ReadEEPROM, F("Load Mesh"));
|
||||
else {
|
||||
if (ubl.storage_slot < 0) {
|
||||
if (bedlevel.storage_slot < 0) {
|
||||
Popup_Handler(MeshSlot);
|
||||
break;
|
||||
}
|
||||
@ -2989,7 +2987,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_WriteEEPROM, F("Save Mesh"));
|
||||
else {
|
||||
if (ubl.storage_slot < 0) {
|
||||
if (bedlevel.storage_slot < 0) {
|
||||
Popup_Handler(MeshSlot);
|
||||
break;
|
||||
}
|
||||
@ -3098,13 +3096,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_Mesh, F("Zero Current Mesh"));
|
||||
else
|
||||
ZERO(Z_VALUES_ARR);
|
||||
ZERO(bedlevel.z_values);
|
||||
break;
|
||||
case LEVELING_SETTINGS_UNDEF:
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_Mesh, F("Clear Current Mesh"));
|
||||
else
|
||||
ubl.invalidate();
|
||||
bedlevel.invalidate();
|
||||
break;
|
||||
#endif // AUTO_BED_LEVELING_UBL
|
||||
}
|
||||
@ -3146,7 +3144,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
Draw_Menu_Item(row, ICON_Back, F("Back"));
|
||||
else {
|
||||
set_bed_leveling_enabled(level_state);
|
||||
TERN_(AUTO_BED_LEVELING_BILINEAR, bbl.refresh_bed_level());
|
||||
TERN_(AUTO_BED_LEVELING_BILINEAR, bedlevel.refresh_bed_level());
|
||||
Draw_Menu(Leveling, LEVELING_MANUAL);
|
||||
}
|
||||
break;
|
||||
@ -3184,36 +3182,36 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
case LEVELING_M_OFFSET:
|
||||
if (draw) {
|
||||
Draw_Menu_Item(row, ICON_SetZOffset, F("Point Z Offset"));
|
||||
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
||||
Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
||||
}
|
||||
else {
|
||||
if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
||||
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
||||
Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
||||
if (isnan(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
||||
bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
||||
Modify_Value(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
||||
}
|
||||
break;
|
||||
case LEVELING_M_UP:
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_Axis, F("Microstep Up"));
|
||||
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
||||
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
||||
else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
||||
bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
||||
gcode.process_subcommands_now(F("M290 Z0.01"));
|
||||
planner.synchronize();
|
||||
current_position.z += 0.01f;
|
||||
sync_plan_position();
|
||||
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
||||
Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
||||
}
|
||||
break;
|
||||
case LEVELING_M_DOWN:
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_AxisD, F("Microstep Down"));
|
||||
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
||||
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
||||
else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
||||
bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
||||
gcode.process_subcommands_now(F("M290 Z-0.01"));
|
||||
planner.synchronize();
|
||||
current_position.z -= 0.01f;
|
||||
sync_plan_position();
|
||||
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
||||
Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
||||
}
|
||||
break;
|
||||
case LEVELING_M_GOTO_VALUE:
|
||||
@ -3305,36 +3303,36 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
case UBL_M_OFFSET:
|
||||
if (draw) {
|
||||
Draw_Menu_Item(row, ICON_SetZOffset, F("Point Z Offset"));
|
||||
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
||||
Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
||||
}
|
||||
else {
|
||||
if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
||||
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
||||
Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
||||
if (isnan(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
||||
bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
||||
Modify_Value(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
||||
}
|
||||
break;
|
||||
case UBL_M_UP:
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_Axis, F("Microstep Up"));
|
||||
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
||||
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
||||
else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
||||
bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
||||
gcode.process_subcommands_now(F("M290 Z0.01"));
|
||||
planner.synchronize();
|
||||
current_position.z += 0.01f;
|
||||
sync_plan_position();
|
||||
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
||||
Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
||||
}
|
||||
break;
|
||||
case UBL_M_DOWN:
|
||||
if (draw)
|
||||
Draw_Menu_Item(row, ICON_Axis, F("Microstep Down"));
|
||||
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
||||
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
||||
else if (bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
||||
bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
||||
gcode.process_subcommands_now(F("M290 Z-0.01"));
|
||||
planner.synchronize();
|
||||
current_position.z -= 0.01f;
|
||||
sync_plan_position();
|
||||
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
||||
Draw_Float(bedlevel.z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3418,13 +3416,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
case MMESH_OLD:
|
||||
uint8_t mesh_x, mesh_y;
|
||||
// 0,0 -> 1,0 -> 2,0 -> 2,1 -> 1,1 -> 0,1 -> 0,2 -> 1,2 -> 2,2
|
||||
mesh_y = (gridpoint - 1) / GRID_MAX_POINTS_Y;
|
||||
mesh_x = (gridpoint - 1) % GRID_MAX_POINTS_X;
|
||||
mesh_y = (gridpoint - 1) / (GRID_MAX_POINTS_Y);
|
||||
mesh_x = (gridpoint - 1) % (GRID_MAX_POINTS_X);
|
||||
|
||||
if (mesh_y % 2 == 1)
|
||||
mesh_x = GRID_MAX_POINTS_X - mesh_x - 1;
|
||||
mesh_x = (GRID_MAX_POINTS_X) - mesh_x - 1;
|
||||
|
||||
const float currval = Z_VALUES_ARR[mesh_x][mesh_y];
|
||||
const float currval = bedlevel.z_values[mesh_x][mesh_y];
|
||||
|
||||
if (draw) {
|
||||
Draw_Menu_Item(row, ICON_Zoffset, F("Goto Mesh Value"));
|
||||
@ -4283,7 +4281,7 @@ void CrealityDWINClass::Popup_Control() {
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
case MeshSlot:
|
||||
if (selection == 0) ubl.storage_slot = 0;
|
||||
if (selection == 0) bedlevel.storage_slot = 0;
|
||||
Redraw_Menu(true, true);
|
||||
break;
|
||||
#endif
|
||||
|
@ -516,8 +516,8 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
// Display Mesh Point Locations
|
||||
const dwin_coord_t sx = x_offset + pixels_per_x_mesh_pnt / 2;
|
||||
dwin_coord_t y = y_offset + pixels_per_y_mesh_pnt / 2;
|
||||
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++, y += pixels_per_y_mesh_pnt)
|
||||
for (uint8_t i = 0, x = sx; i < GRID_MAX_POINTS_X; i++, x += pixels_per_x_mesh_pnt)
|
||||
for (uint8_t j = 0; j < (GRID_MAX_POINTS_Y); j++, y += pixels_per_y_mesh_pnt)
|
||||
for (uint8_t i = 0, x = sx; i < (GRID_MAX_POINTS_X); i++, x += pixels_per_x_mesh_pnt)
|
||||
DWIN_Draw_Point(Color_White, 1, 1, x, y);
|
||||
|
||||
// Put Relevant Text on Display
|
||||
@ -525,7 +525,7 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
// Show X and Y positions at top of screen
|
||||
dwin_font.fg = Color_White;
|
||||
dwin_font.solid = true;
|
||||
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
|
||||
const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) },
|
||||
lpos = pos.asLogical();
|
||||
|
||||
lcd_moveto(
|
||||
@ -555,8 +555,8 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
|
||||
// Show the location value
|
||||
dwin_string.set(Z_LBL);
|
||||
if (!isnan(Z_VALUES_ARR[x_plot][y_plot]))
|
||||
dwin_string.add(ftostr43sign(Z_VALUES_ARR[x_plot][y_plot]));
|
||||
if (!isnan(bedlevel.z_values[x_plot][y_plot]))
|
||||
dwin_string.add(ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
else
|
||||
dwin_string.add(PSTR(" -----"));
|
||||
lcd_moveto(
|
||||
|
@ -3611,7 +3611,7 @@ void Draw_Steps_Menu() {
|
||||
#define Z_OFFSET_MIN -3
|
||||
#define Z_OFFSET_MAX 3
|
||||
|
||||
void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &Z_VALUES_ARR[HMI_value.Select ? mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : mesh_y]; EditZValueItem->redraw(); }
|
||||
void LiveEditMesh() { ((MenuItemPtrClass*)EditZValueItem)->value = &bedlevel.z_values[HMI_value.Select ? mesh_x : MenuData.Value][HMI_value.Select ? MenuData.Value : mesh_y]; EditZValueItem->redraw(); }
|
||||
void ApplyEditMeshX() { mesh_x = MenuData.Value; }
|
||||
void SetEditMeshX() { HMI_value.Select = 0; SetIntOnClick(0, GRID_MAX_POINTS_X - 1, mesh_x, ApplyEditMeshX, LiveEditMesh); }
|
||||
void ApplyEditMeshY() { mesh_y = MenuData.Value; }
|
||||
@ -3622,18 +3622,18 @@ void Draw_Steps_Menu() {
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
void ApplyUBLSlot() { ubl.storage_slot = MenuData.Value; }
|
||||
void SetUBLSlot() { SetIntOnClick(0, settings.calc_num_meshes() - 1, ubl.storage_slot, ApplyUBLSlot); }
|
||||
void ApplyUBLSlot() { bedlevel.storage_slot = MenuData.Value; }
|
||||
void SetUBLSlot() { SetIntOnClick(0, settings.calc_num_meshes() - 1, bedlevel.storage_slot, ApplyUBLSlot); }
|
||||
void onDrawUBLSlot(MenuItemClass* menuitem, int8_t line) {
|
||||
if (ubl.storage_slot < 0) ubl.storage_slot = 0;
|
||||
onDrawIntMenu(menuitem, line, ubl.storage_slot);
|
||||
if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0;
|
||||
onDrawIntMenu(menuitem, line, bedlevel.storage_slot);
|
||||
}
|
||||
|
||||
void ApplyUBLTiltGrid() { ubl_tools.tilt_grid = MenuData.Value; }
|
||||
void SetUBLTiltGrid() { SetIntOnClick(1, 3, ubl_tools.tilt_grid, ApplyUBLTiltGrid); }
|
||||
|
||||
void UBLTiltMesh() {
|
||||
if (ubl.storage_slot < 0) ubl.storage_slot = 0;
|
||||
if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0;
|
||||
char buf[15];
|
||||
if (ubl_tools.tilt_grid > 1) {
|
||||
sprintf_P(buf, PSTR("G28O\nG29 J%i"), ubl_tools.tilt_grid);
|
||||
@ -3645,28 +3645,28 @@ void Draw_Steps_Menu() {
|
||||
}
|
||||
|
||||
void UBLSmartFillMesh() {
|
||||
ubl.smart_fill_mesh();
|
||||
bedlevel.smart_fill_mesh();
|
||||
LCD_MESSAGE(MSG_UBL_MESH_FILLED);
|
||||
}
|
||||
|
||||
bool UBLValidMesh() {
|
||||
const bool valid = ubl_tools.validate();
|
||||
if (!valid) ubl.invalidate();
|
||||
if (!valid) bedlevel.invalidate();
|
||||
return valid;
|
||||
}
|
||||
|
||||
void UBLSaveMesh() {
|
||||
if (ubl.storage_slot < 0) ubl.storage_slot = 0;
|
||||
settings.store_mesh(ubl.storage_slot);
|
||||
ui.status_printf(0, GET_TEXT_F(MSG_MESH_SAVED), ubl.storage_slot);
|
||||
if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0;
|
||||
settings.store_mesh(bedlevel.storage_slot);
|
||||
ui.status_printf(0, GET_TEXT_F(MSG_MESH_SAVED), bedlevel.storage_slot);
|
||||
DONE_BUZZ(true);
|
||||
}
|
||||
|
||||
void UBLLoadMesh() {
|
||||
if (ubl.storage_slot < 0) ubl.storage_slot = 0;
|
||||
settings.load_mesh(ubl.storage_slot);
|
||||
if (bedlevel.storage_slot < 0) bedlevel.storage_slot = 0;
|
||||
settings.load_mesh(bedlevel.storage_slot);
|
||||
if (UBLValidMesh()) {
|
||||
ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), ubl.storage_slot);
|
||||
ui.status_printf(0, GET_TEXT_F(MSG_MESH_LOADED), bedlevel.storage_slot);
|
||||
DONE_BUZZ(true);
|
||||
}
|
||||
else {
|
||||
@ -3691,7 +3691,7 @@ void Draw_Steps_Menu() {
|
||||
MENU_ITEM_F(ICON_Level, MSG_AUTO_MESH, onDrawMenuItem, AutoLev);
|
||||
#endif
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &ubl.storage_slot);
|
||||
EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_STORAGE_SLOT, onDrawUBLSlot, SetUBLSlot, &bedlevel.storage_slot);
|
||||
MENU_ITEM_F(ICON_UBLActive, MSG_UBL_SAVE_MESH, onDrawMenuItem, UBLSaveMesh);
|
||||
MENU_ITEM_F(ICON_UBLActive, MSG_UBL_LOAD_MESH, onDrawMenuItem, UBLLoadMesh);
|
||||
EDIT_ITEM_F(ICON_UBLActive, MSG_UBL_TILTING_GRID, onDrawPInt8Menu, SetUBLTiltGrid, &ubl_tools.tilt_grid);
|
||||
@ -3714,7 +3714,7 @@ void Draw_Steps_Menu() {
|
||||
BACK_ITEM(Draw_MeshSet_Menu);
|
||||
EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_X, onDrawPInt8Menu, SetEditMeshX, &mesh_x);
|
||||
EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_Y, onDrawPInt8Menu, SetEditMeshY, &mesh_y);
|
||||
EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &Z_VALUES_ARR[mesh_x][mesh_y]);
|
||||
EditZValueItem = EDIT_ITEM_F(ICON_UBLActive, MSG_MESH_EDIT_Z, onDrawPFloat3Menu, SetEditZValue, &bedlevel.z_values[mesh_x][mesh_y]);
|
||||
}
|
||||
UpdateMenu(EditMeshMenu);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void MeshViewerClass::Draw(bool withsave /*= false*/) {
|
||||
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);
|
||||
DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
|
||||
#endif
|
||||
if (withsave) {
|
||||
DWINUI::Draw_Button(BTN_Save, 26, 305);
|
||||
|
@ -63,11 +63,9 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16];
|
||||
struct linear_fit_data lsf_results;
|
||||
incremental_LSF_reset(&lsf_results);
|
||||
GRID_LOOP(x, y) {
|
||||
if (!isnan(Z_VALUES_ARR[x][y])) {
|
||||
xy_pos_t rpos;
|
||||
rpos.x = ubl.mesh_index_to_xpos(x);
|
||||
rpos.y = ubl.mesh_index_to_ypos(y);
|
||||
incremental_LSF(&lsf_results, rpos, Z_VALUES_ARR[x][y]);
|
||||
if (!isnan(bedlevel.z_values[x][y])) {
|
||||
xy_pos_t rpos = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) };
|
||||
incremental_LSF(&lsf_results, rpos, bedlevel.z_values[x][y]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,13 +74,13 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16];
|
||||
return true;
|
||||
}
|
||||
|
||||
ubl.set_all_mesh_points_to_value(0);
|
||||
bedlevel.set_all_mesh_points_to_value(0);
|
||||
|
||||
matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1));
|
||||
GRID_LOOP(i, j) {
|
||||
float mx = ubl.mesh_index_to_xpos(i),
|
||||
my = ubl.mesh_index_to_ypos(j),
|
||||
mz = Z_VALUES_ARR[i][j];
|
||||
float mx = bedlevel.get_mesh_x(i),
|
||||
my = bedlevel.get_mesh_y(j),
|
||||
mz = bedlevel.z_values[i][j];
|
||||
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
||||
@ -106,7 +104,7 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16];
|
||||
DEBUG_DELAY(20);
|
||||
}
|
||||
|
||||
Z_VALUES_ARR[i][j] = mz - lsf_results.D;
|
||||
bedlevel.z_values[i][j] = mz - lsf_results.D;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -124,7 +122,7 @@ char cmd[MAX_CMD_SIZE+16], str_1[16], str_2[16], str_3[16];
|
||||
void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y, bool zmove/*=false*/) {
|
||||
if (zmove) {
|
||||
planner.synchronize();
|
||||
current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
||||
planner.synchronize();
|
||||
}
|
||||
@ -136,7 +134,7 @@ void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y,
|
||||
sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y);
|
||||
gcode.process_subcommands_now(cmd);
|
||||
planner.synchronize();
|
||||
current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
current_position.z = goto_mesh_value ? bedlevel.z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
||||
planner.synchronize();
|
||||
HMI_ReturnScreen();
|
||||
@ -146,8 +144,8 @@ void UBLMeshToolsClass::manual_move(const uint8_t mesh_x, const uint8_t mesh_y,
|
||||
float UBLMeshToolsClass::get_max_value() {
|
||||
float max = __FLT_MIN__;
|
||||
GRID_LOOP(x, y) {
|
||||
if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] > max)
|
||||
max = Z_VALUES_ARR[x][y];
|
||||
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max)
|
||||
max = bedlevel.z_values[x][y];
|
||||
}
|
||||
return max;
|
||||
}
|
||||
@ -155,20 +153,19 @@ float UBLMeshToolsClass::get_max_value() {
|
||||
float UBLMeshToolsClass::get_min_value() {
|
||||
float min = __FLT_MAX__;
|
||||
GRID_LOOP(x, y) {
|
||||
if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] < min)
|
||||
min = Z_VALUES_ARR[x][y];
|
||||
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min)
|
||||
min = bedlevel.z_values[x][y];
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
bool UBLMeshToolsClass::validate() {
|
||||
float min = __FLT_MAX__;
|
||||
float max = __FLT_MIN__;
|
||||
float min = __FLT_MAX__, max = __FLT_MIN__;
|
||||
|
||||
GRID_LOOP(x, y) {
|
||||
if (isnan(Z_VALUES_ARR[x][y])) return false;
|
||||
if (Z_VALUES_ARR[x][y] < min) min = Z_VALUES_ARR[x][y];
|
||||
if (Z_VALUES_ARR[x][y] > max) max = Z_VALUES_ARR[x][y];
|
||||
if (isnan(bedlevel.z_values[x][y])) return false;
|
||||
if (bedlevel.z_values[x][y] < min) min = bedlevel.z_values[x][y];
|
||||
if (bedlevel.z_values[x][y] > max) max = bedlevel.z_values[x][y];
|
||||
}
|
||||
return max <= UBL_Z_OFFSET_MAX && min >= UBL_Z_OFFSET_MIN;
|
||||
}
|
||||
@ -177,15 +174,15 @@ bool UBLMeshToolsClass::validate() {
|
||||
void UBLMeshToolsClass::Draw_Bed_Mesh(int16_t selected /*= -1*/, uint8_t gridline_width /*= 1*/, uint16_t padding_x /*= 8*/, uint16_t padding_y_top /*= 40 + 53 - 7*/) {
|
||||
drawing_mesh = true;
|
||||
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x;
|
||||
const uint16_t cell_width_px = total_width_px / GRID_MAX_POINTS_X;
|
||||
const uint16_t cell_height_px = total_width_px / GRID_MAX_POINTS_Y;
|
||||
const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X);
|
||||
const uint16_t cell_height_px = total_width_px / (GRID_MAX_POINTS_Y);
|
||||
const float v_max = abs(get_max_value()), v_min = abs(get_min_value()), range = _MAX(v_min, v_max);
|
||||
|
||||
// Clear background from previous selection and select new square
|
||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px);
|
||||
if (selected >= 0) {
|
||||
const auto selected_y = selected / GRID_MAX_POINTS_X;
|
||||
const auto selected_x = selected - (GRID_MAX_POINTS_X * selected_y);
|
||||
const auto selected_y = selected / (GRID_MAX_POINTS_X);
|
||||
const auto selected_x = selected - (GRID_MAX_POINTS_X) * selected_y;
|
||||
const auto start_y_px = padding_y_top + selected_y * cell_height_px;
|
||||
const auto start_x_px = padding_x + selected_x * cell_width_px;
|
||||
DWIN_Draw_Rectangle(1, Color_White, _MAX(0, start_x_px - gridline_width), _MAX(0, start_y_px - gridline_width), start_x_px + cell_width_px, start_y_px + cell_height_px);
|
||||
@ -196,14 +193,14 @@ bool UBLMeshToolsClass::validate() {
|
||||
GRID_LOOP(x, y) {
|
||||
const auto start_x_px = padding_x + x * cell_width_px;
|
||||
const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width;
|
||||
const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px;
|
||||
const auto start_y_px = padding_y_top + ((GRID_MAX_POINTS_Y) - y - 1) * cell_height_px;
|
||||
const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width;
|
||||
DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
|
||||
isnan(Z_VALUES_ARR[x][y]) ? Color_Grey : ( // gray if undefined
|
||||
(Z_VALUES_ARR[x][y] < 0 ?
|
||||
(uint16_t)round(0x1F * -Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
|
||||
(uint16_t)round(0x3F * Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
|
||||
_MIN(0x1F, (((uint8_t)abs(Z_VALUES_ARR[x][y]) / 10) * 4))), // + blue stepping for every mm
|
||||
isnan(bedlevel.z_values[x][y]) ? Color_Grey : ( // gray if undefined
|
||||
(bedlevel.z_values[x][y] < 0 ?
|
||||
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
|
||||
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
|
||||
_MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm
|
||||
start_x_px, start_y_px, end_x_px, end_y_px
|
||||
);
|
||||
|
||||
@ -213,14 +210,14 @@ bool UBLMeshToolsClass::validate() {
|
||||
// Draw value text on
|
||||
if (viewer_print_value) {
|
||||
int8_t offset_x, offset_y = cell_height_px / 2 - 6;
|
||||
if (isnan(Z_VALUES_ARR[x][y])) { // undefined
|
||||
if (isnan(bedlevel.z_values[x][y])) { // undefined
|
||||
DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
|
||||
}
|
||||
else { // has value
|
||||
if (GRID_MAX_POINTS_X < 10)
|
||||
sprintf_P(buf, PSTR("%s"), dtostrf(abs(Z_VALUES_ARR[x][y]), 1, 2, str_1));
|
||||
sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1));
|
||||
else
|
||||
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(Z_VALUES_ARR[x][y] - (int16_t)Z_VALUES_ARR[x][y]) * 100));
|
||||
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100));
|
||||
offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
|
||||
if (!(GRID_MAX_POINTS_X < 10))
|
||||
DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
|
||||
|
@ -341,8 +341,8 @@ void DGUSTxHandler::ABLGrid(DGUS_VP &vp) {
|
||||
int16_t fixed;
|
||||
|
||||
for (int i = 0; i < DGUS_LEVEL_GRID_SIZE; i++) {
|
||||
point.x = i % GRID_MAX_POINTS_X;
|
||||
point.y = i / GRID_MAX_POINTS_X;
|
||||
point.x = i % (GRID_MAX_POINTS_X);
|
||||
point.y = i / (GRID_MAX_POINTS_X);
|
||||
fixed = dgus_display.ToFixedPoint<float, int16_t, 3>(ExtUI::getMeshPoint(point));
|
||||
data[i] = Swap16(fixed);
|
||||
}
|
||||
|
@ -889,11 +889,11 @@ namespace ExtUI {
|
||||
|
||||
#if HAS_MESH
|
||||
|
||||
bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; }
|
||||
float getMeshPoint(const xy_uint8_t &pos) { return Z_VALUES(pos.x, pos.y); }
|
||||
bed_mesh_t& getMeshArray() { return bedlevel.z_values; }
|
||||
float getMeshPoint(const xy_uint8_t &pos) { return bedlevel.z_values[pos.x][pos.y]; }
|
||||
void setMeshPoint(const xy_uint8_t &pos, const_float_t zoff) {
|
||||
if (WITHIN(pos.x, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(pos.y, 0, (GRID_MAX_POINTS_Y) - 1)) {
|
||||
Z_VALUES(pos.x, pos.y) = zoff;
|
||||
bedlevel.z_values[pos.x][pos.y] = zoff;
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
|
||||
}
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ void MarlinUI::init() {
|
||||
|
||||
void MarlinUI::external_encoder() {
|
||||
if (external_control && encoderDiff) {
|
||||
ubl.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing
|
||||
bedlevel.encoder_diff += encoderDiff; // Encoder for UBL G29 mesh editing
|
||||
encoderDiff = 0; // Hide encoder events from the screen handler
|
||||
refresh(LCDVIEW_REDRAW_NOW); // ...but keep the refresh.
|
||||
}
|
||||
|
@ -203,14 +203,14 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co
|
||||
if (on_status_screen()) {
|
||||
defer_status_screen(false);
|
||||
clear_menu_history();
|
||||
TERN_(AUTO_BED_LEVELING_UBL, ubl.lcd_map_control = false);
|
||||
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.lcd_map_control = false);
|
||||
}
|
||||
|
||||
clear_lcd();
|
||||
|
||||
// Re-initialize custom characters that may be re-used
|
||||
#if HAS_MARLINUI_HD44780
|
||||
if (TERN1(AUTO_BED_LEVELING_UBL, !ubl.lcd_map_control))
|
||||
if (TERN1(AUTO_BED_LEVELING_UBL, !bedlevel.lcd_map_control))
|
||||
set_custom_characters(on_status_screen() ? CHARSET_INFO : CHARSET_MENU);
|
||||
#endif
|
||||
|
||||
|
@ -214,7 +214,7 @@
|
||||
BACK_ITEM(MSG_BED_LEVELING);
|
||||
EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, (GRID_MAX_POINTS_X) - 1);
|
||||
EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, (GRID_MAX_POINTS_Y) - 1);
|
||||
EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &Z_VALUES(xind, yind), -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner);
|
||||
EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &bedlevel.z_values[xind][yind], -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ void menu_bed_leveling() {
|
||||
#else
|
||||
#define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
|
||||
#endif
|
||||
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_BED_Z, &mbl.z_offset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_BED_Z, &bedlevel.z_offset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
|
@ -118,7 +118,7 @@ void menu_tune() {
|
||||
// Manual bed leveling, Bed Z:
|
||||
//
|
||||
#if BOTH(MESH_BED_LEVELING, LCD_BED_LEVELING)
|
||||
EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
|
||||
EDIT_ITEM(float43, MSG_BED_Z, &bedlevel.z_offset, -1, 1);
|
||||
#endif
|
||||
|
||||
//
|
||||
|
@ -58,7 +58,7 @@ inline float rounded_mesh_value() {
|
||||
|
||||
/**
|
||||
* This screen displays the temporary mesh value and updates it based on encoder
|
||||
* movement. While this screen is active ubl.fine_tune_mesh sits in a loop getting
|
||||
* movement. While this screen is active bedlevel.fine_tune_mesh sits in a loop getting
|
||||
* the current value via ubl_mesh_value, moves the Z axis, and updates the mesh
|
||||
* value until the encoder button is pressed.
|
||||
*
|
||||
@ -70,12 +70,12 @@ inline float rounded_mesh_value() {
|
||||
void _lcd_mesh_fine_tune(PGM_P const msg) {
|
||||
constexpr float mesh_edit_step = 1.0f / 200.0f;
|
||||
ui.defer_status_screen();
|
||||
if (ubl.encoder_diff) {
|
||||
if (bedlevel.encoder_diff) {
|
||||
mesh_edit_accumulator += TERN(IS_TFTGLCD_PANEL,
|
||||
ubl.encoder_diff * mesh_edit_step / ENCODER_PULSES_PER_STEP,
|
||||
ubl.encoder_diff > 0 ? mesh_edit_step : -mesh_edit_step
|
||||
bedlevel.encoder_diff * mesh_edit_step / ENCODER_PULSES_PER_STEP,
|
||||
bedlevel.encoder_diff > 0 ? mesh_edit_step : -mesh_edit_step
|
||||
);
|
||||
ubl.encoder_diff = 0;
|
||||
bedlevel.encoder_diff = 0;
|
||||
IF_DISABLED(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
|
||||
}
|
||||
TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
|
||||
@ -89,7 +89,7 @@ void _lcd_mesh_fine_tune(PGM_P const msg) {
|
||||
}
|
||||
|
||||
//
|
||||
// Init mesh editing and go to the fine tuning screen (ubl.fine_tune_mesh)
|
||||
// Init mesh editing and go to the fine tuning screen (bedlevel.fine_tune_mesh)
|
||||
// To capture encoder events UBL will also call ui.capture and ui.release.
|
||||
//
|
||||
void MarlinUI::ubl_mesh_edit_start(const_float_t initial) {
|
||||
@ -99,7 +99,7 @@ void MarlinUI::ubl_mesh_edit_start(const_float_t initial) {
|
||||
}
|
||||
|
||||
//
|
||||
// Get the mesh value within a Z adjustment loop (ubl.fine_tune_mesh)
|
||||
// Get the mesh value within a Z adjustment loop (bedlevel.fine_tune_mesh)
|
||||
//
|
||||
float MarlinUI::ubl_mesh_value() { return rounded_mesh_value(); }
|
||||
|
||||
@ -291,7 +291,7 @@ void _menu_ubl_fillin() {
|
||||
}
|
||||
|
||||
void _lcd_ubl_invalidate() {
|
||||
ubl.invalidate();
|
||||
bedlevel.invalidate();
|
||||
SERIAL_ECHOLNPGM("Mesh invalidated.");
|
||||
}
|
||||
|
||||
@ -390,8 +390,8 @@ void _lcd_ubl_storage_mesh() {
|
||||
*/
|
||||
void _lcd_ubl_map_edit_cmd() {
|
||||
char ubl_lcd_gcode[50], str[10], str2[10];
|
||||
dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str);
|
||||
dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2);
|
||||
dtostrf(bedlevel.get_mesh_x(x_plot), 0, 2, str);
|
||||
dtostrf(bedlevel.get_mesh_y(y_plot), 0, 2, str2);
|
||||
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29P4X%sY%sR%i"), str, str2, int(n_edit_pts));
|
||||
queue.inject(ubl_lcd_gcode);
|
||||
}
|
||||
@ -400,7 +400,7 @@ void _lcd_ubl_map_edit_cmd() {
|
||||
* UBL LCD Map Movement
|
||||
*/
|
||||
void ubl_map_move_to_xy() {
|
||||
const xy_pos_t xy = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) };
|
||||
const xy_pos_t xy = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) };
|
||||
|
||||
// Some printers have unreachable areas in the mesh. Skip the move if unreachable.
|
||||
if (!position_is_reachable(xy)) return;
|
||||
@ -459,7 +459,7 @@ void ubl_map_screen() {
|
||||
|
||||
// Validate if needed
|
||||
#if IS_KINEMATIC
|
||||
const xy_pos_t xy = { ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) };
|
||||
const xy_pos_t xy = { bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) };
|
||||
if (position_is_reachable(xy)) break; // Found a valid point
|
||||
ui.encoderPosition += step_dir; // Test the next point
|
||||
#endif
|
||||
@ -500,7 +500,7 @@ void _ubl_map_screen_homing() {
|
||||
ui.defer_status_screen();
|
||||
_lcd_draw_homing();
|
||||
if (all_axes_homed()) {
|
||||
ubl.lcd_map_control = true; // Return to the map screen after editing Z
|
||||
bedlevel.lcd_map_control = true; // Return to the map screen after editing Z
|
||||
ui.goto_screen(ubl_map_screen, grid_index(x_plot, y_plot)); // Pre-set the encoder value
|
||||
ui.manual_move.menu_scale = 0; // Immediate move
|
||||
ubl_map_move_to_xy(); // Move to current mesh point
|
||||
|
@ -180,8 +180,8 @@ void Touch::touch(touch_control_t *control) {
|
||||
ui.refresh();
|
||||
break;
|
||||
case SLIDER: hold(control); ui.encoderPosition = (x - control->x) * control->data / control->width; break;
|
||||
case INCREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? ubl.encoder_diff++ : ui.encoderPosition++, ui.encoderPosition++); break;
|
||||
case DECREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? ubl.encoder_diff-- : ui.encoderPosition--, ui.encoderPosition--); break;
|
||||
case INCREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? bedlevel.encoder_diff++ : ui.encoderPosition++, ui.encoderPosition++); break;
|
||||
case DECREASE: hold(control, repeat_delay - 5); TERN(AUTO_BED_LEVELING_UBL, ui.external_control ? bedlevel.encoder_diff-- : ui.encoderPosition--, ui.encoderPosition--); break;
|
||||
case HEATER:
|
||||
int8_t heater;
|
||||
heater = control->data;
|
||||
|
@ -501,14 +501,14 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft.add_rectangle(0, 0, GRID_WIDTH, GRID_HEIGHT, COLOR_WHITE);
|
||||
|
||||
for (uint16_t x = 0; x < GRID_MAX_POINTS_X ; x++)
|
||||
for (uint16_t y = 0; y < GRID_MAX_POINTS_Y ; y++)
|
||||
if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }))
|
||||
tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 2, 2, COLOR_UBL);
|
||||
for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++)
|
||||
for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++)
|
||||
if (position_is_reachable({ bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) }))
|
||||
tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL);
|
||||
|
||||
tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / GRID_MAX_POINTS_X / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / GRID_MAX_POINTS_Y / 2), 6, 6, COLOR_UBL);
|
||||
tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL);
|
||||
|
||||
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
|
||||
const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) },
|
||||
lpos = pos.asLogical();
|
||||
|
||||
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
|
||||
@ -531,7 +531,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(Z_LBL);
|
||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
tft_string.set(isnan(bedlevel.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
tft_string.trim();
|
||||
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
|
@ -485,12 +485,12 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
|
||||
for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++)
|
||||
for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++)
|
||||
if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }))
|
||||
if (position_is_reachable({ bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) }))
|
||||
tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL);
|
||||
|
||||
tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL);
|
||||
|
||||
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
|
||||
const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) },
|
||||
lpos = pos.asLogical();
|
||||
|
||||
tft.canvas(216, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 96, MENU_ITEM_HEIGHT);
|
||||
@ -513,7 +513,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(Z_LBL);
|
||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
tft_string.set(isnan(bedlevel.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
tft_string.trim();
|
||||
tft.add_text(96 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
|
@ -490,12 +490,12 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
|
||||
for (uint16_t x = 0; x < (GRID_MAX_POINTS_X); x++)
|
||||
for (uint16_t y = 0; y < (GRID_MAX_POINTS_Y); y++)
|
||||
if (position_is_reachable({ ubl.mesh_index_to_xpos(x), ubl.mesh_index_to_ypos(y) }))
|
||||
if (position_is_reachable({ bedlevel.get_mesh_x(x), bedlevel.get_mesh_y(y) }))
|
||||
tft.add_bar(1 + (x * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2, GRID_HEIGHT - 3 - ((y * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 2, 2, COLOR_UBL);
|
||||
|
||||
tft.add_rectangle((x_plot * 2 + 1) * (GRID_WIDTH - 4) / (GRID_MAX_POINTS_X) / 2 - 1, GRID_HEIGHT - 5 - ((y_plot * 2 + 1) * (GRID_HEIGHT - 4) / (GRID_MAX_POINTS_Y) / 2), 6, 6, COLOR_UBL);
|
||||
|
||||
const xy_pos_t pos = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) },
|
||||
const xy_pos_t pos = { bedlevel.get_mesh_x(x_plot), bedlevel.get_mesh_y(y_plot) },
|
||||
lpos = pos.asLogical();
|
||||
|
||||
tft.canvas(320, GRID_OFFSET_Y + (GRID_HEIGHT - MENU_ITEM_HEIGHT) / 2 - MENU_ITEM_HEIGHT, 120, MENU_ITEM_HEIGHT);
|
||||
@ -518,7 +518,7 @@ void MenuItem_confirm::draw_select_screen(PGM_P const yes, PGM_P const no, const
|
||||
tft.set_background(COLOR_BACKGROUND);
|
||||
tft_string.set(Z_LBL);
|
||||
tft.add_text(0, MENU_TEXT_Y_OFFSET, COLOR_MENU_TEXT, tft_string);
|
||||
tft_string.set(isnan(ubl.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
||||
tft_string.set(isnan(bedlevel.z_values[x_plot][y_plot]) ? "-----" : ftostr43sign(bedlevel.z_values[x_plot][y_plot]));
|
||||
tft_string.trim();
|
||||
tft.add_text(120 - tft_string.width(), MENU_TEXT_Y_OFFSET, COLOR_MENU_VALUE, tft_string);
|
||||
|
||||
|
Reference in New Issue
Block a user