Add 'I' parameter to M906/M913/M914; 'T' to M906/M913

This commit is contained in:
Scott Lahteine 2018-03-14 07:25:27 -05:00
parent cfc13ed7f3
commit a46bac3100
3 changed files with 166 additions and 107 deletions

View file

@ -37,50 +37,54 @@ void GcodeSuite::M906() {
#define TMC_SET_CURRENT(Q) tmc_set_current(stepper##Q, TMC_##Q, value) #define TMC_SET_CURRENT(Q) tmc_set_current(stepper##Q, TMC_##Q, value)
bool report = true; bool report = true;
const uint8_t index = parser.byteval('I');
LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) { LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) {
report = false; report = false;
switch (i) { switch (i) {
case X_AXIS: case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
TMC_SET_CURRENT(X); if (index == 0) TMC_SET_CURRENT(X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
TMC_SET_CURRENT(X2); if (index == 1) TMC_SET_CURRENT(X2);
#endif #endif
break; break;
case Y_AXIS: case Y_AXIS:
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
TMC_SET_CURRENT(Y); if (index == 0) TMC_SET_CURRENT(Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
TMC_SET_CURRENT(Y2); if (index == 1) TMC_SET_CURRENT(Y2);
#endif #endif
break; break;
case Z_AXIS: case Z_AXIS:
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SET_CURRENT(Z); if (index == 0) TMC_SET_CURRENT(Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SET_CURRENT(Z2); if (index == 1) TMC_SET_CURRENT(Z2);
#endif #endif
break; break;
case E_AXIS: case E_AXIS: {
if (get_target_extruder_from_command()) return;
switch (target_extruder) {
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
TMC_SET_CURRENT(E0); case 0: TMC_SET_CURRENT(E0); break;
#endif #endif
#if E1_IS_TRINAMIC #if E1_IS_TRINAMIC
TMC_SET_CURRENT(E1); case 1: TMC_SET_CURRENT(E1); break;
#endif #endif
#if E2_IS_TRINAMIC #if E2_IS_TRINAMIC
TMC_SET_CURRENT(E2); case 2: TMC_SET_CURRENT(E2); break;
#endif #endif
#if E3_IS_TRINAMIC #if E3_IS_TRINAMIC
TMC_SET_CURRENT(E3); case 3: TMC_SET_CURRENT(E3); break;
#endif #endif
#if E4_IS_TRINAMIC #if E4_IS_TRINAMIC
TMC_SET_CURRENT(E4); case 4: TMC_SET_CURRENT(E4); break;
#endif #endif
break; }
} break;
} }
} }

View file

@ -86,50 +86,54 @@ void GcodeSuite::M912() {
#define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, TMC_E##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0) #define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, TMC_E##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
bool report = true; bool report = true;
const uint8_t index = parser.byteval('I');
LOOP_XYZE(i) if (int32_t value = parser.longval(axis_codes[i])) { LOOP_XYZE(i) if (int32_t value = parser.longval(axis_codes[i])) {
report = false; report = false;
switch (i) { switch (i) {
case X_AXIS: case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
TMC_SET_PWMTHRS(X,X); if (index == 0) TMC_SET_PWMTHRS(X,X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
TMC_SET_PWMTHRS(X,X2); if (index == 1) TMC_SET_PWMTHRS(X,X2);
#endif #endif
break; break;
case Y_AXIS: case Y_AXIS:
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
TMC_SET_PWMTHRS(Y,Y); if (index == 0) TMC_SET_PWMTHRS(Y,Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
TMC_SET_PWMTHRS(Y,Y2); if (index == 1) TMC_SET_PWMTHRS(Y,Y2);
#endif #endif
break; break;
case Z_AXIS: case Z_AXIS:
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SET_PWMTHRS(Z,Z); if (index == 0) TMC_SET_PWMTHRS(Z,Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SET_PWMTHRS(Z,Z2); if (index == 1) TMC_SET_PWMTHRS(Z,Z2);
#endif #endif
break; break;
case E_AXIS: case E_AXIS: {
if (get_target_extruder_from_command()) return;
switch (target_extruder) {
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
TMC_SET_PWMTHRS_E(0); case 0: TMC_SET_PWMTHRS_E(0); break;
#endif #endif
#if E1_IS_TRINAMIC #if E_STEPPERS > 1 && E1_IS_TRINAMIC
TMC_SET_PWMTHRS_E(1); case 1: TMC_SET_PWMTHRS_E(1); break;
#endif #endif
#if E2_IS_TRINAMIC #if E_STEPPERS > 2 && E2_IS_TRINAMIC
TMC_SET_PWMTHRS_E(2); case 2: TMC_SET_PWMTHRS_E(2); break;
#endif #endif
#if E3_IS_TRINAMIC #if E_STEPPERS > 3 && E3_IS_TRINAMIC
TMC_SET_PWMTHRS_E(3); case 3: TMC_SET_PWMTHRS_E(3); break;
#endif #endif
#if E4_IS_TRINAMIC #if E_STEPPERS > 4 && E4_IS_TRINAMIC
TMC_SET_PWMTHRS_E(4); case 4: TMC_SET_PWMTHRS_E(4); break;
#endif #endif
break; }
} break;
} }
} }
@ -162,16 +166,16 @@ void GcodeSuite::M912() {
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(0); TMC_SAY_PWMTHRS_E(0);
#endif #endif
#if E1_IS_TRINAMIC #if E_STEPPERS > 1 && E1_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(1); TMC_SAY_PWMTHRS_E(1);
#endif #endif
#if E2_IS_TRINAMIC #if E_STEPPERS > 2 && E2_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(2); TMC_SAY_PWMTHRS_E(2);
#endif #endif
#if E3_IS_TRINAMIC #if E_STEPPERS > 3 && E3_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(3); TMC_SAY_PWMTHRS_E(3);
#endif #endif
#if E4_IS_TRINAMIC #if E_STEPPERS > 4 && E4_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(4); TMC_SAY_PWMTHRS_E(4);
#endif #endif
break; break;
@ -188,32 +192,33 @@ void GcodeSuite::M912() {
#define TMC_SET_SGT(Q) tmc_set_sgt(stepper##Q, TMC_##Q, value) #define TMC_SET_SGT(Q) tmc_set_sgt(stepper##Q, TMC_##Q, value)
bool report = true; bool report = true;
const uint8_t index = parser.byteval('I');
LOOP_XYZ(i) if (parser.seen(axis_codes[i])) { LOOP_XYZ(i) if (parser.seen(axis_codes[i])) {
const int8_t value = (int8_t)constrain(parser.value_int(), -63, 64); const int8_t value = (int8_t)constrain(parser.value_int(), -63, 64);
report = false; report = false;
switch (i) { switch (i) {
case X_AXIS: case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_SGT(X); if (index == 0) TMC_SET_SGT(X);
#endif #endif
#if ENABLED(X2_IS_TMC2130) #if ENABLED(X2_IS_TMC2130)
TMC_SET_SGT(X2); if (index == 1) TMC_SET_SGT(X2);
#endif #endif
break; break;
case Y_AXIS: case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_SGT(Y); if (index == 0) TMC_SET_SGT(Y);
#endif #endif
#if ENABLED(Y2_IS_TMC2130) #if ENABLED(Y2_IS_TMC2130)
TMC_SET_SGT(Y2); if (index == 1) TMC_SET_SGT(Y2);
#endif #endif
break; break;
case Z_AXIS: case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_SGT(Z); if (index == 0) TMC_SET_SGT(Z);
#endif #endif
#if ENABLED(Z2_IS_TMC2130) #if ENABLED(Z2_IS_TMC2130)
TMC_SET_SGT(Z2); if (index == 1) TMC_SET_SGT(Z2);
#endif #endif
break; break;
} }

View file

@ -1892,6 +1892,14 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0) #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0)
#if HAS_TRINAMIC
void say_M906() { SERIAL_ECHOPGM_P(port, " M906 "); }
void say_M913() { SERIAL_ECHOPGM_P(port, " M913 "); }
#if ENABLED(SENSORLESS_HOMING)
void say_M914() { SERIAL_ECHOPGM_P(port, " M914 "); }
#endif
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE) #if ENABLED(ADVANCED_PAUSE_FEATURE)
void say_M603() { SERIAL_ECHOPGM_P(port, " M603 "); } void say_M603() { SERIAL_ECHOPGM_P(port, " M603 "); }
#endif #endif
@ -2373,34 +2381,51 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOLNPGM_P(port, "Stepper driver current:"); SERIAL_ECHOLNPGM_P(port, "Stepper driver current:");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPGM_P(port, " M906");
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " X", stepperX.getCurrent()); say_M906();
#elif X2_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "X", stepperX.getCurrent());
SERIAL_ECHOPAIR_P(port, " X", stepperX2.getCurrent()); #endif
#if X2_IS_TRINAMIC
say_M906();
SERIAL_ECHOLNPAIR_P(port, "I1 X", stepperX2.getCurrent());
#endif #endif
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Y", stepperY.getCurrent()); say_M906();
#elif Y2_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "Y", stepperY.getCurrent());
SERIAL_ECHOPAIR_P(port, " Y", stepperY2.getCurrent()); #endif
#if Y2_IS_TRINAMIC
say_M906();
SERIAL_ECHOLNPAIR_P(port, "I1 Y", stepperY2.getCurrent());
#endif #endif
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Z", stepperZ.getCurrent()); say_M906();
#elif Z2_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "Z", stepperZ.getCurrent());
SERIAL_ECHOPAIR_P(port, " Z", stepperZ2.getCurrent()); #endif
#if Z2_IS_TRINAMIC
say_M906();
SERIAL_ECHOLNPAIR_P(port, "I1 Z", stepperZ2.getCurrent());
#endif #endif
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", stepperE0.getCurrent()); say_M906();
#elif E1_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "T0 E", stepperE0.getCurrent());
SERIAL_ECHOPAIR_P(port, " E", stepperE1.getCurrent());
#elif E2_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", stepperE2.getCurrent());
#elif E3_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", stepperE3.getCurrent());
#elif E4_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", stepperE4.getCurrent());
#endif #endif
SERIAL_EOL(); #if E_STEPPERS > 1 && E1_IS_TRINAMIC
say_M906();
SERIAL_ECHOLNPAIR_P(port, "T1 E", stepperE1.getCurrent());
#endif
#if E_STEPPERS > 2 && E2_IS_TRINAMIC
say_M906();
SERIAL_ECHOLNPAIR_P(port, "T2 E", stepperE2.getCurrent());
#endif
#if E_STEPPERS > 3 && E3_IS_TRINAMIC
say_M906();
SERIAL_ECHOLNPAIR_P(port, "T3 E", stepperE3.getCurrent());
#endif
#if E_STEPPERS > 4 && E4_IS_TRINAMIC
say_M906();
SERIAL_ECHOLNPAIR_P(port, "T4 E", stepperE4.getCurrent());
#endif
SERIAL_EOL_P(port);
/** /**
* TMC2130 / TMC2208 / TRAMS Hybrid Threshold * TMC2130 / TMC2208 / TRAMS Hybrid Threshold
@ -2410,34 +2435,51 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOLNPGM_P(port, "Hybrid Threshold:"); SERIAL_ECHOLNPGM_P(port, "Hybrid Threshold:");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPGM_P(port, " M913");
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " X", TMC_GET_PWMTHRS(X, X)); say_M913();
#elif X2_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "X", TMC_GET_PWMTHRS(X, X));
SERIAL_ECHOPAIR_P(port, " X", TMC_GET_PWMTHRS(X, X2)); #endif
#if X2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "I1 X", TMC_GET_PWMTHRS(X, X2));
#endif #endif
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Y", TMC_GET_PWMTHRS(Y, Y)); say_M913();
#elif Y2_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "Y", TMC_GET_PWMTHRS(Y, Y));
SERIAL_ECHOPAIR_P(port, " Y", TMC_GET_PWMTHRS(Y, Y2)); #endif
#if Y2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "I1 Y", TMC_GET_PWMTHRS(Y, Y2));
#endif #endif
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Z", TMC_GET_PWMTHRS(Z, Z)); say_M913();
#elif Z2_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "Z", TMC_GET_PWMTHRS(Z, Z));
SERIAL_ECHOPAIR_P(port, " Z", TMC_GET_PWMTHRS(Z, Z2)); #endif
#if Z2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "I1 Z", TMC_GET_PWMTHRS(Z, Z2));
#endif #endif
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", TMC_GET_PWMTHRS(E, E0)); say_M913();
#elif E1_IS_TRINAMIC SERIAL_ECHOLNPAIR_P(port, "T0 E", TMC_GET_PWMTHRS(E, E0));
SERIAL_ECHOPAIR_P(port, " E", TMC_GET_PWMTHRS(E, E1));
#elif E2_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", TMC_GET_PWMTHRS(E, E2));
#elif E3_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", TMC_GET_PWMTHRS(E, E3));
#elif E4_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E", TMC_GET_PWMTHRS(E, E4));
#endif #endif
SERIAL_EOL(); #if E_STEPPERS > 1 && E1_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T1 E", TMC_GET_PWMTHRS(E, E1));
#endif
#if E_STEPPERS > 2 && E2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T2 E", TMC_GET_PWMTHRS(E, E2));
#endif
#if E_STEPPERS > 3 && E3_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T3 E", TMC_GET_PWMTHRS(E, E3));
#endif
#if E_STEPPERS > 4 && E4_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T4 E", TMC_GET_PWMTHRS(E, E4));
#endif
SERIAL_EOL_P(port);
/** /**
* TMC2130 Sensorless homing thresholds * TMC2130 Sensorless homing thresholds
@ -2448,29 +2490,37 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOLNPGM_P(port, "Sensorless homing threshold:"); SERIAL_ECHOLNPGM_P(port, "Sensorless homing threshold:");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPGM_P(port, " M914");
#ifdef X_HOMING_SENSITIVITY #ifdef X_HOMING_SENSITIVITY
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
SERIAL_ECHOPAIR_P(port, " X", stepperX.sgt()); say_M914();
#elif ENABLED(X2_IS_TMC2130) SERIAL_ECHOLNPAIR_P(port, "X", stepperX.sgt());
SERIAL_ECHOPAIR_P(port, " X", stepperX2.sgt()); #endif
#if ENABLED(X2_IS_TMC2130)
say_M914();
SERIAL_ECHOLNPAIR_P(port, "I1 X", stepperX2.sgt());
#endif #endif
#endif #endif
#ifdef Y_HOMING_SENSITIVITY #ifdef Y_HOMING_SENSITIVITY
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
SERIAL_ECHOPAIR_P(port, " Y", stepperY.sgt()); say_M914();
#elif ENABLED(Y2_IS_TMC2130) SERIAL_ECHOLNPAIR_P(port, "Y", stepperY.sgt());
SERIAL_ECHOPAIR_P(port, " Y", stepperY2.sgt()); #endif
#if ENABLED(Y2_IS_TMC2130)
say_M914();
SERIAL_ECHOLNPAIR_P(port, "I1 Y", stepperY2.sgt());
#endif #endif
#endif #endif
#ifdef Z_HOMING_SENSITIVITY #ifdef Z_HOMING_SENSITIVITY
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
SERIAL_ECHOPAIR_P(port, " Z", stepperZ.sgt()); say_M914();
#elif ENABLED(Z2_IS_TMC2130) SERIAL_ECHOLNPAIR_P(port, "Z", stepperZ.sgt());
SERIAL_ECHOPAIR_P(port, " Z", stepperZ2.sgt()); #endif
#if ENABLED(Z2_IS_TMC2130)
say_M914();
SERIAL_ECHOLNPAIR_P(port, "I1 Z", stepperZ2.sgt());
#endif #endif
#endif #endif
SERIAL_EOL(); SERIAL_EOL_P(port);
#endif #endif
#endif // HAS_TRINAMIC #endif // HAS_TRINAMIC