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

LCD position in current units #20145

Merged
merged 29 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
42dafaa
Merge pull request #1 from MarlinFirmware/bugfix-2.0.x
rdhoggattjr Nov 10, 2020
2194198
INFO_DISPLAY_INCHES
rdhoggattjr Nov 10, 2020
d7245b2
Fix formatting
rdhoggattjr Nov 11, 2020
b08cda4
STATUS_DISPLAY_INCHES
rdhoggattjr Nov 15, 2020
9cc6a9b
Re-Push STATUS_DISPLAY_INCHES
rdhoggattjr Nov 15, 2020
9c7f516
Update Configuration.h
rdhoggattjr Nov 15, 2020
2f76e10
Remove white space and fix check
rdhoggattjr Nov 15, 2020
21edaeb
add imperial_units boolean
rdhoggattjr Nov 16, 2020
f3ce8cf
Update Configuration.h
rdhoggattjr Nov 17, 2020
1b7e561
Merge pull request #3 from rdhoggattjr/bugfix-2.0.x-temp
rdhoggattjr Nov 17, 2020
e39263e
added INCH_MANUAL_MOVEMENT
rdhoggattjr Nov 17, 2020
c9254fe
Adjust conditions for imperial_units boolean
rdhoggattjr Nov 17, 2020
a9f6e36
small fixes
rdhoggattjr Nov 17, 2020
de64692
fix #include check
rdhoggattjr Nov 17, 2020
80e4f2e
Merge pull request #4 from rdhoggattjr/bugfix-2.0.x-temp
rdhoggattjr Nov 17, 2020
f6dc7d6
More Small Fixes
rdhoggattjr Nov 18, 2020
5db27f1
Helper method
thinkyhead Nov 18, 2020
5aff43e
Merged STATUS_DISPLAY_INCHES into INCH_MODE_SUPPORT
rdhoggattjr Nov 18, 2020
9e26439
Merge branch 'bugfix-2.0.x-inch-manual-movement' into bugfix-2.0.x-temp
rdhoggattjr Nov 19, 2020
1433320
Merge pull request #5 from rdhoggattjr/bugfix-2.0.x-temp
rdhoggattjr Nov 19, 2020
e132f87
Convert to INCH_MODE_SUPPORT and using_inch_units()
rdhoggattjr Nov 19, 2020
52a44e0
Merge pull request #6 from rdhoggattjr/bugfix-2.0.x-inch-manual-movement
rdhoggattjr Nov 19, 2020
bf62c73
Update to use TERN
rdhoggattjr Nov 20, 2020
29a53fb
Remove whitespace
rdhoggattjr Nov 20, 2020
0dea5c4
Simplify
thinkyhead Nov 21, 2020
8f953fa
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/20145
thinkyhead Nov 21, 2020
8046978
Better macro
thinkyhead Nov 21, 2020
1dce0a4
Include parser
thinkyhead Nov 21, 2020
5046224
M114 tweak
thinkyhead Nov 22, 2020
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
7 changes: 1 addition & 6 deletions Marlin/src/gcode/host/M114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
}

void report_current_position_detail() {

// Position as sent by G-code
SERIAL_ECHOPGM("\nLogical:");
report_xyz(current_position.asLogical());
Expand All @@ -81,11 +80,7 @@

#if IS_KINEMATIC
// Kinematics applied to the leveled position
#if IS_SCARA
SERIAL_ECHOPGM("ScaraK: ");
#else
SERIAL_ECHOPGM("DeltaK: ");
#endif
SERIAL_ECHOPGM(TERN(IS_SCARA, "ScaraK: ", "DeltaK: "));
inverse_kinematics(leveled); // writes delta[]
report_xyz(delta);
#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/gcode/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ class GCodeParser {

#endif

static inline bool using_inch_units() { return mm_to_linear_unit(1.0f) != 1.0f; }

#define IN_TO_MM(I) ((I) * 25.4f)
#define MM_TO_IN(M) ((M) / 25.4f)
#define LINEAR_UNIT(V) parser.mm_to_linear_unit(V)
#define VOLUMETRIC_UNIT(V) parser.mm_to_volumetric_unit(V)

Expand Down
35 changes: 27 additions & 8 deletions Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
#include "../../module/motion.h"
#include "../../module/temperature.h"

#include "../../gcode/parser.h" // for units (and volumetric)

#if ENABLED(FILAMENT_LCD_DISPLAY)
#include "../../feature/filwidth.h"
#include "../../module/planner.h"
#include "../../gcode/parser.h"
#endif

#if HAS_CUTTER
Expand All @@ -67,6 +68,11 @@
#define X_LABEL_POS 3
#define X_VALUE_POS 11
#define XYZ_SPACING 37

#define X_LABEL_POS_IN (X_LABEL_POS - 2)
#define X_VALUE_POS_IN (X_VALUE_POS - 5)
#define XYZ_SPACING_IN (XYZ_SPACING + 9)

#define XYZ_BASELINE (30 + INFO_FONT_ASCENT)
#define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
#define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
Expand Down Expand Up @@ -370,10 +376,12 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t tx, cons
// Homed and known, display constantly.
//
FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
const bool is_inch = parser.using_inch_units();
const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
const uint8_t offs = (XYZ_SPACING) * a;
lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, axis_codes[axis]);
lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING);
lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, axis_codes[axis]);
lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE);

if (blink)
lcd_put_u8str(value);
else {
Expand All @@ -390,9 +398,16 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
}
}

/**
* Draw the Status Screen for a 128x64 DOGM (U8glib) display.
*
* Called as needed to update the current display stripe.
* Use the PAGE_CONTAINS macros to avoid pointless draw calls.
*/
void MarlinUI::draw_status_screen() {
constexpr int xystorage = TERN(INCH_MODE_SUPPORT, 8, 5);
static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, xystorage)], ystring[xystorage], zstring[8];

static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, 5)], ystring[5], zstring[8];
#if ENABLED(FILAMENT_LCD_DISPLAY)
static char wstring[5], mstring[4];
#endif
Expand Down Expand Up @@ -439,7 +454,8 @@ void MarlinUI::draw_status_screen() {
#endif

const xyz_pos_t lpos = current_position.asLogical();
strcpy(zstring, ftostr52sp(lpos.z));
const bool is_inch = parser.using_inch_units();
strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z));

if (show_e_total) {
#if ENABLED(LCD_SHOW_E_TOTAL)
Expand All @@ -448,8 +464,8 @@ void MarlinUI::draw_status_screen() {
#endif
}
else {
strcpy(xstring, ftostr4sign(lpos.x));
strcpy(ystring, ftostr4sign(lpos.y));
strcpy(xstring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.x)) : ftostr4sign(lpos.x));
strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y));
}

#if ENABLED(FILAMENT_LCD_DISPLAY)
Expand Down Expand Up @@ -854,6 +870,9 @@ void MarlinUI::draw_status_screen() {
}
}

/**
* Draw the Status Message area
*/
void MarlinUI::draw_status_message(const bool blink) {

// Get the UTF8 character count of the string
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ namespace Language_en {
PROGMEM Language_Str MSG_MOVE_01MM = _UxGT("Move 0.1mm");
PROGMEM Language_Str MSG_MOVE_1MM = _UxGT("Move 1mm");
PROGMEM Language_Str MSG_MOVE_10MM = _UxGT("Move 10mm");
PROGMEM Language_Str MSG_MOVE_0001IN = _UxGT("Move 0.001in");
PROGMEM Language_Str MSG_MOVE_001IN = _UxGT("Move 0.01in");
PROGMEM Language_Str MSG_MOVE_01IN = _UxGT("Move 0.1in");
PROGMEM Language_Str MSG_SPEED = _UxGT("Speed");
PROGMEM Language_Str MSG_BED_Z = _UxGT("Bed Z");
PROGMEM Language_Str MSG_NOZZLE = _UxGT("Nozzle");
Expand Down
55 changes: 34 additions & 21 deletions Marlin/src/lcd/menu/menu_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "menu_addon.h"

#include "../../module/motion.h"
#include "../../gcode/parser.h" // for inch support

#if ENABLED(DELTA)
#include "../../module/delta.h"
Expand Down Expand Up @@ -95,7 +96,12 @@ static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) {
ui.manual_move.processing ? destination[axis] : current_position[axis] + TERN0(IS_KINEMATIC, ui.manual_move.offset),
axis
);
MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr63(pos));
if (parser.using_inch_units()) {
const float imp_pos = LINEAR_UNIT(pos);
MenuEditItemBase::draw_edit_screen(name, ftostr63(imp_pos));
}
else
MenuEditItemBase::draw_edit_screen(name, ui.manual_move.menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr63(pos));
}
}
void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); }
Expand Down Expand Up @@ -165,26 +171,33 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int
}

BACK_ITEM(MSG_MOVE_AXIS);
SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); });
SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); });
SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); });
if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
// Determine digits needed right of decimal
constexpr uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
!UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2;
PGM_P const label = GET_TEXT(MSG_MOVE_Z_DIST);
char tmp[strlen_P(label) + 10 + 1], numstr[10];
sprintf_P(tmp, label, dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));

#if DISABLED(HAS_GRAPHICAL_TFT)
extern const char NUL_STR[];
SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780));
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();
#else
SUBMENU_P(tmp, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
#endif
if (parser.using_inch_units()) {
SUBMENU(MSG_MOVE_01IN, []{ _goto_manual_move(IN_TO_MM(0.100f)); });
SUBMENU(MSG_MOVE_001IN, []{ _goto_manual_move(IN_TO_MM(0.010f)); });
SUBMENU(MSG_MOVE_0001IN, []{ _goto_manual_move(IN_TO_MM(0.001f)); });
}
else {
SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); });
SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); });
SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); });
if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
// Determine digits needed right of decimal
constexpr uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
!UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2;
PGM_P const label = GET_TEXT(MSG_MOVE_Z_DIST);
char tmp[strlen_P(label) + 10 + 1], numstr[10];
sprintf_P(tmp, label, dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));

#if DISABLED(HAS_GRAPHICAL_TFT)
extern const char NUL_STR[];
SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
MENU_ITEM_ADDON_START(0 + ENABLED(HAS_MARLINUI_HD44780));
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();
#else
SUBMENU_P(tmp, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
#endif
}
}
END_MENU();
}
Expand Down