Add custom types for position (#15204)

This commit is contained in:
Scott Lahteine
2019-09-29 04:25:39 -05:00
committed by GitHub
parent 43d6e9fa43
commit 50e4545255
227 changed files with 3147 additions and 3264 deletions

View File

@ -345,9 +345,10 @@ void MarlinUI::draw_status_screen() {
#endif
heat_bits = new_bits;
#endif
strcpy(xstring, ftostr4sign(LOGICAL_X_POSITION(current_position[X_AXIS])));
strcpy(ystring, ftostr4sign(LOGICAL_Y_POSITION(current_position[Y_AXIS])));
strcpy(zstring, ftostr52sp( LOGICAL_Z_POSITION(current_position[Z_AXIS])));
const xyz_pos_t lpos = current_position.asLogical();
strcpy(xstring, ftostr4sign(lpos.x));
strcpy(ystring, ftostr4sign(lpos.y));
strcpy(zstring, ftostr52sp( lpos.z));
#if ENABLED(FILAMENT_LCD_DISPLAY)
strcpy(wstring, ftostr12ns(filwidth.measured_mm));
strcpy(mstring, i16tostr3(planner.volumetric_percent(parser.volumetric_enabled)));

View File

@ -660,7 +660,7 @@ void ST7920_Lite_Status_Screen::draw_status_message() {
#endif
}
void ST7920_Lite_Status_Screen::draw_position(const float (&pos)[XYZE], const bool position_known) {
void ST7920_Lite_Status_Screen::draw_position(const xyz_pos_t &pos, const bool position_known) {
char str[7];
set_ddram_address(DDRAM_LINE_4);
begin_data();
@ -669,13 +669,13 @@ void ST7920_Lite_Status_Screen::draw_position(const float (&pos)[XYZE], const bo
const unsigned char alt_label = position_known ? 0 : (ui.get_blink() ? ' ' : 0);
write_byte(alt_label ? alt_label : 'X');
write_str(dtostrf(pos[X_AXIS], -4, 0, str), 4);
write_str(dtostrf(pos.x, -4, 0, str), 4);
write_byte(alt_label ? alt_label : 'Y');
write_str(dtostrf(pos[Y_AXIS], -4, 0, str), 4);
write_str(dtostrf(pos.y, -4, 0, str), 4);
write_byte(alt_label ? alt_label : 'Z');
write_str(dtostrf(pos[Z_AXIS], -5, 1, str), 5);
write_str(dtostrf(pos.z, -5, 1, str), 5);
}
bool ST7920_Lite_Status_Screen::indicators_changed() {
@ -750,8 +750,8 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
}
bool ST7920_Lite_Status_Screen::position_changed() {
const float x_pos = current_position[X_AXIS], y_pos = current_position[Y_AXIS], z_pos = current_position[Z_AXIS];
const uint8_t checksum = uint8_t(x_pos) ^ uint8_t(y_pos) ^ uint8_t(z_pos);
const xyz_pos_t pos = current_position;
const uint8_t checksum = uint8_t(pos.x) ^ uint8_t(pos.y) ^ uint8_t(pos.z);
static uint8_t last_checksum = 0, changed = last_checksum != checksum;
if (changed) last_checksum = checksum;
return changed;

View File

@ -17,6 +17,7 @@
#include "../../HAL/shared/HAL_ST7920.h"
#include "../../core/types.h"
#include "../../core/macros.h"
#include "../../libs/duration_t.h"
@ -86,7 +87,7 @@ class ST7920_Lite_Status_Screen {
static void draw_print_time(const duration_t &elapsed);
static void draw_feedrate_percentage(const uint16_t percentage);
static void draw_status_message();
static void draw_position(const float (&pos)[XYZE], bool position_known = true);
static void draw_position(const xyz_pos_t &pos, bool position_known = true);
static bool indicators_changed();
static bool position_changed();

View File

@ -547,10 +547,12 @@ 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) },
lpos = pos.asLogical();
lcd_put_u8str(5, 7, "X:");
lcd_put_u8str(ftostr52(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
lcd_put_u8str(ftostr52(lpos.x));
lcd_put_u8str(74, 7, "Y:");
lcd_put_u8str(ftostr52(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
lcd_put_u8str(ftostr52(lpos.y));
}
// Print plot position