Browse Source

🏗️ Extend AXIS_CHAR to include E

Co-Authored-By: DerAndere <26200979+DerAndere1@users.noreply.github.com>
FB4S_WIFI
Scott Lahteine 3 years ago
committed by Scott Lahteine
parent
commit
d56731cd07
  1. 2
      Marlin/src/core/utility.h
  2. 44
      Marlin/src/feature/encoder_i2c.cpp
  3. 10
      Marlin/src/feature/encoder_i2c.h
  4. 4
      Marlin/src/gcode/config/M200-M205.cpp
  5. 2
      Marlin/src/gcode/config/M92.cpp
  6. 6
      Marlin/src/gcode/control/M17_M18_M84.cpp
  7. 8
      Marlin/src/gcode/control/M350_M351.cpp
  8. 4
      Marlin/src/gcode/feature/L6470/M906.cpp
  9. 2
      Marlin/src/gcode/feature/trinamic/M122.cpp
  10. 2
      Marlin/src/gcode/feature/trinamic/M569.cpp
  11. 2
      Marlin/src/gcode/feature/trinamic/M906.cpp
  12. 2
      Marlin/src/gcode/feature/trinamic/M911-M914.cpp
  13. 4
      Marlin/src/gcode/feature/trinamic/M919.cpp
  14. 4
      Marlin/src/gcode/geometry/G92.cpp
  15. 2
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  16. 2
      Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp
  17. 2
      Marlin/src/lcd/lcdprint.cpp
  18. 4
      Marlin/src/lcd/marlinui.cpp
  19. 2
      Marlin/src/lcd/tft/tft_string.cpp
  20. 6
      Marlin/src/libs/L64XX/L64XX_Marlin.cpp

2
Marlin/src/core/utility.h

@ -79,7 +79,7 @@ constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127)
// Axis names for G-code parsing, reports, etc. // Axis names for G-code parsing, reports, etc.
const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME); const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME);
#if NUM_AXES <= XYZ #if NUM_AXES <= XYZ && !HAS_EXTRUDERS
#define AXIS_CHAR(A) ((char)('X' + A)) #define AXIS_CHAR(A) ((char)('X' + A))
#define IAXIS_CHAR AXIS_CHAR #define IAXIS_CHAR AXIS_CHAR
#else #else

44
Marlin/src/feature/encoder_i2c.cpp

@ -49,7 +49,7 @@ void I2CPositionEncoder::init(const uint8_t address, const AxisEnum axis) {
initialized = true; initialized = true;
SERIAL_ECHOLNPGM("Setting up encoder on ", AS_CHAR(axis_codes[encoderAxis]), " axis, addr = ", address); SERIAL_ECHOLNPGM("Setting up encoder on ", AS_CHAR(AXIS_CHAR(encoderAxis)), " axis, addr = ", address);
position = get_position(); position = get_position();
} }
@ -67,7 +67,7 @@ void I2CPositionEncoder::update() {
/* /*
if (trusted) { //commented out as part of the note below if (trusted) { //commented out as part of the note below
trusted = false; trusted = false;
SERIAL_ECHOLNPGM("Fault detected on ", AS_CHAR(axis_codes[encoderAxis]), " axis encoder. Disengaging error correction until module is trusted again."); SERIAL_ECHOLNPGM("Fault detected on ", AS_CHAR(AXIS_CHAR(encoderAxis)), " axis encoder. Disengaging error correction until module is trusted again.");
} }
*/ */
return; return;
@ -92,7 +92,7 @@ void I2CPositionEncoder::update() {
if (millis() - lastErrorTime > I2CPE_TIME_TRUSTED) { if (millis() - lastErrorTime > I2CPE_TIME_TRUSTED) {
trusted = true; trusted = true;
SERIAL_ECHOLNPGM("Untrusted encoder module on ", AS_CHAR(axis_codes[encoderAxis]), " axis has been fault-free for set duration, reinstating error correction."); SERIAL_ECHOLNPGM("Untrusted encoder module on ", AS_CHAR(AXIS_CHAR(encoderAxis)), " axis has been fault-free for set duration, reinstating error correction.");
//the encoder likely lost its place when the error occurred, so we'll reset and use the printer's //the encoder likely lost its place when the error occurred, so we'll reset and use the printer's
//idea of where it the axis is to re-initialize //idea of where it the axis is to re-initialize
@ -172,7 +172,7 @@ void I2CPositionEncoder::update() {
float sumP = 0; float sumP = 0;
LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i]; LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i];
const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE)); const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE));
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.mm_per_step[encoderAxis], "mm"); SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.mm_per_step[encoderAxis], "mm");
babystep.add_steps(encoderAxis, -LROUND(errorP)); babystep.add_steps(encoderAxis, -LROUND(errorP));
errPrstIdx = 0; errPrstIdx = 0;
@ -192,7 +192,7 @@ void I2CPositionEncoder::update() {
if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) { if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) {
const millis_t ms = millis(); const millis_t ms = millis();
if (ELAPSED(ms, nextErrorCountTime)) { if (ELAPSED(ms, nextErrorCountTime)) {
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
SERIAL_ECHOLNPGM(" : LARGE ERR ", error, "; diffSum=", diffSum); SERIAL_ECHOLNPGM(" : LARGE ERR ", error, "; diffSum=", diffSum);
errorCount++; errorCount++;
nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS; nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS;
@ -212,7 +212,7 @@ void I2CPositionEncoder::set_homed() {
homed = trusted = true; homed = trusted = true;
#ifdef I2CPE_DEBUG #ifdef I2CPE_DEBUG
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
SERIAL_ECHOLNPGM(" axis encoder homed, offset of ", zeroOffset, " ticks."); SERIAL_ECHOLNPGM(" axis encoder homed, offset of ", zeroOffset, " ticks.");
#endif #endif
} }
@ -223,7 +223,7 @@ void I2CPositionEncoder::set_unhomed() {
homed = trusted = false; homed = trusted = false;
#ifdef I2CPE_DEBUG #ifdef I2CPE_DEBUG
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
SERIAL_ECHOLNPGM(" axis encoder unhomed."); SERIAL_ECHOLNPGM(" axis encoder unhomed.");
#endif #endif
} }
@ -231,7 +231,7 @@ void I2CPositionEncoder::set_unhomed() {
bool I2CPositionEncoder::passes_test(const bool report) { bool I2CPositionEncoder::passes_test(const bool report) {
if (report) { if (report) {
if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. "); if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. ");
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
serial_ternary(H == I2CPE_MAG_SIG_BAD, F(" axis "), F("magnetic strip "), F("encoder ")); serial_ternary(H == I2CPE_MAG_SIG_BAD, F(" axis "), F("magnetic strip "), F("encoder "));
switch (H) { switch (H) {
case I2CPE_MAG_SIG_GOOD: case I2CPE_MAG_SIG_GOOD:
@ -252,7 +252,7 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) {
error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading
if (report) { if (report) {
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
SERIAL_ECHOLNPGM(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm"); SERIAL_ECHOLNPGM(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm");
} }
@ -262,7 +262,7 @@ float I2CPositionEncoder::get_axis_error_mm(const bool report) {
int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) { int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
if (!active) { if (!active) {
if (report) { if (report) {
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
SERIAL_ECHOLNPGM(" axis encoder not active!"); SERIAL_ECHOLNPGM(" axis encoder not active!");
} }
return 0; return 0;
@ -287,7 +287,7 @@ int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
errorPrev = error; errorPrev = error;
if (report) { if (report) {
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(AXIS_CHAR(encoderAxis));
SERIAL_ECHOLNPGM(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error); SERIAL_ECHOLNPGM(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error);
} }
@ -657,7 +657,7 @@ void I2CPositionEncodersMgr::report_position(const int8_t idx, const bool units,
else { else {
if (noOffset) { if (noOffset) {
const int32_t raw_count = encoders[idx].get_raw_count(); const int32_t raw_count = encoders[idx].get_raw_count();
SERIAL_CHAR(axis_codes[encoders[idx].get_axis()], ' '); SERIAL_CHAR(AXIS_CHAR(encoders[idx).get_axis()], ' ');
for (uint8_t j = 31; j > 0; j--) for (uint8_t j = 31; j > 0; j--)
SERIAL_ECHO((bool)(0x00000001 & (raw_count >> j))); SERIAL_ECHO((bool)(0x00000001 & (raw_count >> j)));
@ -712,7 +712,7 @@ void I2CPositionEncodersMgr::change_module_address(const uint8_t oldaddr, const
// and enable it (it will likely have failed initialization on power-up, before the address change). // and enable it (it will likely have failed initialization on power-up, before the address change).
const int8_t idx = idx_from_addr(newaddr); const int8_t idx = idx_from_addr(newaddr);
if (idx >= 0 && !encoders[idx].get_active()) { if (idx >= 0 && !encoders[idx].get_active()) {
SERIAL_CHAR(axis_codes[encoders[idx].get_axis()]); SERIAL_CHAR(AXIS_CHAR(encoders[idx).get_axis()]);
SERIAL_ECHOLNPGM(" axis encoder was not detected on printer startup. Trying again."); SERIAL_ECHOLNPGM(" axis encoder was not detected on printer startup. Trying again.");
encoders[idx].set_active(encoders[idx].passes_test(true)); encoders[idx].set_active(encoders[idx].passes_test(true));
} }
@ -814,7 +814,7 @@ void I2CPositionEncodersMgr::M860() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen_test(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen_test(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) report_position(idx, hasU, hasO); if ((int8_t)idx >= 0) report_position(idx, hasU, hasO);
} }
@ -841,7 +841,7 @@ void I2CPositionEncodersMgr::M861() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) report_status(idx); if ((int8_t)idx >= 0) report_status(idx);
} }
@ -869,7 +869,7 @@ void I2CPositionEncodersMgr::M862() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) test_axis(idx); if ((int8_t)idx >= 0) test_axis(idx);
} }
@ -900,7 +900,7 @@ void I2CPositionEncodersMgr::M863() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) calibrate_steps_mm(idx, iterations); if ((int8_t)idx >= 0) calibrate_steps_mm(idx, iterations);
} }
@ -976,7 +976,7 @@ void I2CPositionEncodersMgr::M865() {
if (!I2CPE_addr) { if (!I2CPE_addr) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) report_module_firmware(encoders[idx].get_address()); if ((int8_t)idx >= 0) report_module_firmware(encoders[idx].get_address());
} }
@ -1007,7 +1007,7 @@ void I2CPositionEncodersMgr::M866() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) { if ((int8_t)idx >= 0) {
if (hasR) if (hasR)
@ -1045,7 +1045,7 @@ void I2CPositionEncodersMgr::M867() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) { if ((int8_t)idx >= 0) {
const bool ena = onoff == -1 ? !encoders[I2CPE_idx].get_ec_enabled() : !!onoff; const bool ena = onoff == -1 ? !encoders[I2CPE_idx].get_ec_enabled() : !!onoff;
@ -1081,7 +1081,7 @@ void I2CPositionEncodersMgr::M868() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) { if ((int8_t)idx >= 0) {
if (newThreshold != -9999) if (newThreshold != -9999)
@ -1115,7 +1115,7 @@ void I2CPositionEncodersMgr::M869() {
if (I2CPE_idx == 0xFF) { if (I2CPE_idx == 0xFF) {
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) { if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
const uint8_t idx = idx_from_axis(AxisEnum(i)); const uint8_t idx = idx_from_axis(AxisEnum(i));
if ((int8_t)idx >= 0) report_error(idx); if ((int8_t)idx >= 0) report_error(idx);
} }

10
Marlin/src/feature/encoder_i2c.h

@ -261,32 +261,32 @@ class I2CPositionEncodersMgr {
static void report_error_count(const int8_t idx, const AxisEnum axis) { static void report_error_count(const int8_t idx, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(axis_codes[axis]), " axis is ", encoders[idx].get_error_count()); SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(AXIS_CHAR(axis)), " axis is ", encoders[idx].get_error_count());
} }
static void reset_error_count(const int8_t idx, const AxisEnum axis) { static void reset_error_count(const int8_t idx, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
encoders[idx].set_error_count(0); encoders[idx].set_error_count(0);
SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(axis_codes[axis]), " axis has been reset."); SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(AXIS_CHAR(axis)), " axis has been reset.");
} }
static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) { static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
encoders[idx].set_ec_enabled(enabled); encoders[idx].set_ec_enabled(enabled);
SERIAL_ECHOPGM("Error correction on ", AS_CHAR(axis_codes[axis])); SERIAL_ECHOPGM("Error correction on ", AS_CHAR(AXIS_CHAR(axis)));
SERIAL_ECHO_TERNARY(encoders[idx].get_ec_enabled(), " axis is ", "en", "dis", "abled.\n"); SERIAL_ECHO_TERNARY(encoders[idx].get_ec_enabled(), " axis is ", "en", "dis", "abled.\n");
} }
static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) { static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
encoders[idx].set_ec_threshold(newThreshold); encoders[idx].set_ec_threshold(newThreshold);
SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis set to ", newThreshold, "mm."); SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(AXIS_CHAR(axis)), " axis set to ", newThreshold, "mm.");
} }
static void get_ec_threshold(const int8_t idx, const AxisEnum axis) { static void get_ec_threshold(const int8_t idx, const AxisEnum axis) {
CHECK_IDX(); CHECK_IDX();
const float threshold = encoders[idx].get_ec_threshold(); const float threshold = encoders[idx].get_ec_threshold();
SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis is ", threshold, "mm."); SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(AXIS_CHAR(axis)), " axis is ", threshold, "mm.");
} }
static int8_t idx_from_axis(const AxisEnum axis) { static int8_t idx_from_axis(const AxisEnum axis) {

4
Marlin/src/gcode/config/M200-M205.cpp

@ -134,7 +134,7 @@ void GcodeSuite::M201() {
#endif #endif
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (parser.seenval(axis_codes[i])) { if (parser.seenval(AXIS_CHAR(i))) {
const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i); const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a)); planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
} }
@ -183,7 +183,7 @@ void GcodeSuite::M203() {
if (target_extruder < 0) return; if (target_extruder < 0) return;
LOOP_LOGICAL_AXES(i) LOOP_LOGICAL_AXES(i)
if (parser.seenval(axis_codes[i])) { if (parser.seenval(AXIS_CHAR(i))) {
const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i); const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a)); planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
} }

2
Marlin/src/gcode/config/M92.cpp

@ -47,7 +47,7 @@ void GcodeSuite::M92() {
return M92_report(true, target_extruder); return M92_report(true, target_extruder);
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (parser.seenval(axis_codes[i])) { if (parser.seenval(AXIS_CHAR(i))) {
if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i); planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i);
else { else {

6
Marlin/src/gcode/control/M17_M18_M84.cpp

@ -75,7 +75,7 @@ void do_enable(const stepper_flags_t to_enable) {
LOOP_NUM_AXES(a) { LOOP_NUM_AXES(a) {
if (TEST(shall_enable, a)) { if (TEST(shall_enable, a)) {
stepper.enable_axis(AxisEnum(a)); // Mark and enable the requested axis stepper.enable_axis(AxisEnum(a)); // Mark and enable the requested axis
DEBUG_ECHOLNPGM("Enabled ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... Enabled: ", hex_word(stepper.axis_enabled.bits)); DEBUG_ECHOLNPGM("Enabled ", AXIS_CHAR(a), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... Enabled: ", hex_word(stepper.axis_enabled.bits));
also_enabled |= enable_overlap[a]; also_enabled |= enable_overlap[a];
} }
} }
@ -157,7 +157,7 @@ void try_to_disable(const stepper_flags_t to_disable) {
// Attempt to disable all flagged axes // Attempt to disable all flagged axes
LOOP_NUM_AXES(a) LOOP_NUM_AXES(a)
if (TEST(to_disable.bits, a)) { if (TEST(to_disable.bits, a)) {
DEBUG_ECHOPGM("Try to disable ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... "); DEBUG_ECHOPGM("Try to disable ", AXIS_CHAR(a), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... ");
if (stepper.disable_axis(AxisEnum(a))) { // Mark the requested axis and request to disable if (stepper.disable_axis(AxisEnum(a))) { // Mark the requested axis and request to disable
DEBUG_ECHOPGM("OK"); DEBUG_ECHOPGM("OK");
still_enabled &= ~(_BV(a) | enable_overlap[a]); // If actually disabled, clear one or more tracked bits still_enabled &= ~(_BV(a) | enable_overlap[a]); // If actually disabled, clear one or more tracked bits
@ -195,7 +195,7 @@ void try_to_disable(const stepper_flags_t to_disable) {
// If any of the requested axes are still enabled, give a warning // If any of the requested axes are still enabled, give a warning
LOOP_NUM_AXES(a) { LOOP_NUM_AXES(a) {
if (TEST(still_enabled, a)) { if (TEST(still_enabled, a)) {
SERIAL_CHAR(axis_codes[a]); SERIAL_CHAR(AXIS_CHAR(a));
overlap_warning(stepper.axis_enabled.bits & enable_overlap[a]); overlap_warning(stepper.axis_enabled.bits & enable_overlap[a]);
} }
} }

8
Marlin/src/gcode/control/M350_M351.cpp

@ -40,21 +40,21 @@ void GcodeSuite::M350() {
} }
/** /**
* M351: Toggle MS1 MS2 pins directly with axis codes X Y Z E B * M351: Toggle MS1 MS2 pins directly with axis codes X Y Z . . . E [B]
* S# determines MS1, MS2 or MS3, X# sets the pin high/low. * S# determines MS1, MS2 or MS3, X# sets the pin high/low.
*/ */
void GcodeSuite::M351() { void GcodeSuite::M351() {
if (parser.seenval('S')) switch (parser.value_byte()) { if (parser.seenval('S')) switch (parser.value_byte()) {
case 1: case 1:
LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1, -1); LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, parser.value_byte(), -1, -1);
if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1, -1); if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1, -1);
break; break;
case 2: case 2:
LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte(), -1); LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, parser.value_byte(), -1);
if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte(), -1); if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte(), -1);
break; break;
case 3: case 3:
LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, -1, parser.value_byte()); LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, -1, parser.value_byte());
if (parser.seenval('B')) stepper.microstep_ms(4, -1, -1, parser.value_byte()); if (parser.seenval('B')) stepper.microstep_ms(4, -1, -1, parser.value_byte());
break; break;
} }

4
Marlin/src/gcode/feature/L6470/M906.cpp

@ -211,7 +211,7 @@ void L64XX_report_current(L64XX &motor, const L64XX_axis_t axis) {
* 1 - monitor only X2, Y2, Z2 * 1 - monitor only X2, Y2, Z2
* 2 - monitor only Z3 * 2 - monitor only Z3
* 3 - monitor only Z4 * 3 - monitor only Z4
* Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional) * Xxxx, Yxxx, Zxxx, Axxx, Bxxx, Cxxx, Uxxx, Vxxx, Wxxx, Exxx - axis to change (optional)
* L6474 - current in mA (4A max) * L6474 - current in mA (4A max)
* All others - 0-255 * All others - 0-255
* *
@ -236,7 +236,7 @@ void GcodeSuite::M906() {
constexpr int8_t index = -1; constexpr int8_t index = -1;
#endif #endif
LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) {
report_current = false; report_current = false;

2
Marlin/src/gcode/feature/trinamic/M122.cpp

@ -35,7 +35,7 @@ void GcodeSuite::M122() {
xyze_bool_t print_axis = ARRAY_N_1(LOGICAL_AXES, false); xyze_bool_t print_axis = ARRAY_N_1(LOGICAL_AXES, false);
bool print_all = true; bool print_all = true;
LOOP_LOGICAL_AXES(i) if (parser.seen_test(axis_codes[i])) { print_axis[i] = true; print_all = false; } LOOP_LOGICAL_AXES(i) if (parser.seen_test(AXIS_CHAR(i))) { print_axis[i] = true; print_all = false; }
if (print_all) LOOP_LOGICAL_AXES(i) print_axis[i] = true; if (print_all) LOOP_LOGICAL_AXES(i) print_axis[i] = true;

2
Marlin/src/gcode/feature/trinamic/M569.cpp

@ -53,7 +53,7 @@ static void set_stealth_status(const bool enable, const int8_t eindex) {
constexpr int8_t index = -1; constexpr int8_t index = -1;
#endif #endif
LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (parser.seen(AXIS_CHAR(i))) {
switch (i) { switch (i) {
case X_AXIS: case X_AXIS:
TERN_(X_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(X)); TERN_(X_HAS_STEALTHCHOP, if (index < 0 || index == 0) TMC_SET_STEALTH(X));

2
Marlin/src/gcode/feature/trinamic/M906.cpp

@ -66,7 +66,7 @@ void GcodeSuite::M906() {
constexpr int8_t index = -1; constexpr int8_t index = -1;
#endif #endif
LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) {
report = false; report = false;
switch (i) { switch (i) {
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)

2
Marlin/src/gcode/feature/trinamic/M911-M914.cpp

@ -288,7 +288,7 @@
#elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z)
constexpr uint8_t index = 0; constexpr uint8_t index = 0;
#endif #endif
LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(AXIS_CHAR(i))) {
report = false; report = false;
switch (i) { switch (i) {
#if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP #if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP

4
Marlin/src/gcode/feature/trinamic/M919.cpp

@ -112,13 +112,13 @@ void GcodeSuite::M919() {
int8_t eindex = -1; int8_t eindex = -1;
#endif #endif
bool report = true; bool report = true;
LOOP_LOGICAL_AXES(i) if (parser.seen_test(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (parser.seen_test(AXIS_CHAR(i))) {
report = false; report = false;
// Get the chopper timing for the specified axis and index // Get the chopper timing for the specified axis and index
switch (i) { switch (i) {
default: // A specified axis isn't Trinamic default: // A specified axis isn't Trinamic
SERIAL_ECHOLNPGM("?Axis ", AS_CHAR(axis_codes[i]), " has no TMC drivers."); SERIAL_ECHOLNPGM("?Axis ", AS_CHAR(AXIS_CHAR(i)), " has no TMC drivers.");
break; break;
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2) #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)

4
Marlin/src/gcode/geometry/G92.cpp

@ -74,7 +74,7 @@ void GcodeSuite::G92() {
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
case 9: // G92.9 - Set Current Position directly (like Marlin 1.0) case 9: // G92.9 - Set Current Position directly (like Marlin 1.0)
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (parser.seenval(axis_codes[i])) { if (parser.seenval(AXIS_CHAR(i))) {
if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
sync_XYZE = true; sync_XYZE = true;
else { else {
@ -88,7 +88,7 @@ void GcodeSuite::G92() {
case 0: case 0:
LOOP_LOGICAL_AXES(i) { LOOP_LOGICAL_AXES(i) {
if (parser.seenval(axis_codes[i])) { if (parser.seenval(AXIS_CHAR(i))) {
const float l = parser.value_axis_units((AxisEnum)i), // Given axis coordinate value, converted to millimeters const float l = parser.value_axis_units((AxisEnum)i), // Given axis coordinate value, converted to millimeters
v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset) v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset)
d = v - current_position[i]; // How much is the current axis position altered by? d = v - current_position[i]; // How much is the current axis position altered by?

2
Marlin/src/lcd/dogm/status_screen_DOGM.cpp

@ -432,7 +432,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
const bool is_inch = parser.using_inch_units(); const bool is_inch = parser.using_inch_units();
const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis); const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING); 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_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis));
lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE); lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE);
if (blink) if (blink)

2
Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp

@ -72,7 +72,7 @@ void DWIN_String::add(const char *tpl, const int8_t index, const char *cstr/*=nu
else if (ch == '$' && cstr) else if (ch == '$' && cstr)
add(cstr); add(cstr);
else if (ch == '@') else if (ch == '@')
add_character(axis_codes[index]); add_character(AXIS_CHAR(index));
else else
add_character(ch); add_character(ch);
} }

2
Marlin/src/lcd/lcdprint.cpp

@ -78,7 +78,7 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/
n -= lcd_put_u8str_max(cstr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH); n -= lcd_put_u8str_max(cstr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
} }
else if (ch == '@') { else if (ch == '@') {
lcd_put_wchar(axis_codes[ind]); lcd_put_wchar(AXIS_CHAR(ind));
n--; n--;
} }
else { else {

4
Marlin/src/lcd/marlinui.cpp

@ -840,7 +840,7 @@ void MarlinUI::init() {
TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder
); );
//SERIAL_ECHOLNPGM("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s); //SERIAL_ECHOLNPGM("Add planner.move with Axis ", AS_CHAR(AXIS_CHAR(axis)), " at FR ", fr_mm_s);
axis = NO_AXIS_ENUM; axis = NO_AXIS_ENUM;
@ -857,7 +857,7 @@ void MarlinUI::init() {
TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex); TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex);
start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
axis = move_axis; axis = move_axis;
//SERIAL_ECHOLNPGM("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon."); //SERIAL_ECHOLNPGM("Post Move with Axis ", AS_CHAR(AXIS_CHAR(axis)), " soon.");
} }
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)

2
Marlin/src/lcd/tft/tft_string.cpp

@ -116,7 +116,7 @@ void TFT_String::add(const char *tpl, const int8_t index, const char *cstr/*=nul
else if (ch == '$' && cstr) else if (ch == '$' && cstr)
add(cstr); add(cstr);
else if (ch == '@') else if (ch == '@')
add_character(axis_codes[index]); add_character(AXIS_CHAR(index));
else else
add_character(ch); add_character(ch);
} }

6
Marlin/src/libs/L64XX/L64XX_Marlin.cpp

@ -412,11 +412,11 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in
} }
uint8_t found_displacement = false; uint8_t found_displacement = false;
LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(axis_codes[i])) { LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(AXIS_CHAR(i))) {
found_displacement = true; found_displacement = true;
displacement = _displacement; displacement = _displacement;
const uint8_t axis_offset = parser.byteval('J'); const uint8_t axis_offset = parser.byteval('J');
axis_mon[0][0] = axis_codes[i]; // Axis first character, one of XYZ...E axis_mon[0][0] = AXIS_CHAR(i); // Axis first character, one of XYZ...E
const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E', const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E',
one_or_more = !single_or_e && axis_offset == 0; one_or_more = !single_or_e && axis_offset == 0;
uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference
@ -667,7 +667,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in
static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
const uint8_t num_feedrates = COUNT(default_max_feedrate); const uint8_t num_feedrates = COUNT(default_max_feedrate);
for (j = 0; j < num_feedrates; j++) { for (j = 0; j < num_feedrates; j++) {
if (axis_codes[j] == axis_mon[0][0]) { if (AXIS_CHAR(j) == axis_mon[0][0]) {
final_feedrate = default_max_feedrate[j]; final_feedrate = default_max_feedrate[j];
break; break;
} }

Loading…
Cancel
Save