Report on M92 with no arguments (#12833)

This commit is contained in:
Scott Lahteine 2019-02-04 05:24:15 -06:00 committed by GitHub
parent e10943d0d8
commit 4200bd2fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 16 deletions

View File

@ -23,19 +23,63 @@
#include "../gcode.h"
#include "../../module/planner.h"
void report_M92(
#if NUM_SERIAL > 1
const int8_t port,
#endif
const bool echo=true, const int8_t e=-1
) {
if (echo) SERIAL_ECHO_START_P(port); else SERIAL_CHAR(' ');
SERIAL_ECHOPAIR_P(port, " M92 X", LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]));
SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]));
SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]));
#if DISABLED(DISTINCT_E_FACTORS)
SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
#endif
SERIAL_EOL_P(port);
#if ENABLED(DISTINCT_E_FACTORS)
for (uint8_t i = 0; i < E_STEPPERS; i++) {
if (e >= 0 && i != e) continue;
if (echo) SERIAL_ECHO_START_P(port); else SERIAL_CHAR(' ');
SERIAL_ECHOPAIR_P(port, " M92 T", (int)i);
SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
}
#endif
}
/**
* M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E.
* (Follows the same syntax as G92)
*
* With multiple extruders use T to specify which one.
*
* If no argument is given print the current values.
*
* With MAGIC_NUMBERS_GCODE:
* Use 'H' and/or 'L' to get ideal layer-height information.
* 'H' specifies micro-steps to use. We guess if it's not supplied.
* 'L' specifies a desired layer height. Nearest good heights are shown.
*/
void GcodeSuite::M92() {
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
// No arguments? Show M92 report.
if (!parser.seen("XYZE"
#if ENABLED(MAGIC_NUMBERS_GCODE)
"HL"
#endif
)) return report_M92(
#if NUM_SERIAL > 1
command_queue_port[cmd_queue_index_r],
#endif
true, target_extruder
);
LOOP_XYZE(i) {
if (parser.seen(axis_codes[i])) {
if (parser.seenval(axis_codes[i])) {
if (i == E_AXIS) {
const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder)));
if (value < 20) {
@ -54,4 +98,27 @@ void GcodeSuite::M92() {
}
}
planner.refresh_positioning();
#if ENABLED(MAGIC_NUMBERS_GCODE)
#ifndef Z_MICROSTEPS
#define Z_MICROSTEPS 16
#endif
const float wanted = parser.floatval('L');
if (parser.seen('H') || wanted) {
const uint16_t argH = parser.ushortval('H'),
micro_steps = argH ? argH : Z_MICROSTEPS;
const float z_full_step_mm = micro_steps * planner.steps_to_mm[Z_AXIS];
SERIAL_ECHO_START();
SERIAL_ECHOPAIR("{ micro_steps:", micro_steps);
SERIAL_ECHOPAIR(", z_full_step_mm:", z_full_step_mm);
if (wanted) {
const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm;
SERIAL_ECHOPGM(", best:[");
SERIAL_ECHO(best);
if (best != wanted) { SERIAL_CHAR(','); SERIAL_ECHO(best + z_full_step_mm); }
SERIAL_CHAR(']');
}
SERIAL_ECHOLNPGM(" }");
}
#endif
}

View File

@ -2366,6 +2366,13 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#define SAY_UNITS_P(PORT, COLON) say_units(COLON)
#endif
void report_M92(
#if NUM_SERIAL > 1
const int8_t port,
#endif
const bool echo=true, const int8_t e=-1
);
/**
* M503 - Report current settings in RAM
*
@ -2458,21 +2465,12 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#endif // !NO_VOLUMETRICS
CONFIG_ECHO_HEADING("Steps per unit:");
CONFIG_ECHO_START();
SERIAL_ECHOPAIR_P(port, " M92 X", LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]));
SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]));
SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]));
#if DISABLED(DISTINCT_E_FACTORS)
SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
#endif
SERIAL_EOL_P(port);
#if ENABLED(DISTINCT_E_FACTORS)
CONFIG_ECHO_START();
for (uint8_t i = 0; i < E_STEPPERS; i++) {
SERIAL_ECHOPAIR_P(port, " M92 T", (int)i);
SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS + i]));
}
#endif
report_M92(
#if NUM_SERIAL > 1
port,
#endif
!forReplay
);
CONFIG_ECHO_HEADING("Maximum feedrates (units/s):");
CONFIG_ECHO_START();