0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-03-02 04:47:20 +00:00

Merge pull request #11248 from thinkyhead/bf1_tmc_unify_param_i

[1.1.x] Unify "I" parameter for M906,M912 etc.
This commit is contained in:
Scott Lahteine 2018-07-12 22:31:26 -05:00 committed by GitHub
commit cb0777dbeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 116 additions and 138 deletions

View file

@ -10979,26 +10979,26 @@ inline void gcode_M502() {
switch (i) { switch (i) {
case X_AXIS: case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
if (index == 0) TMC_SET_CURRENT(X); if (index < 2) TMC_SET_CURRENT(X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
if (index == 1) 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
if (index == 0) TMC_SET_CURRENT(Y); if (index < 2) TMC_SET_CURRENT(Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
if (index == 1) 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
if (index == 0) TMC_SET_CURRENT(Z); if (index < 2) TMC_SET_CURRENT(Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
if (index == 1) TMC_SET_CURRENT(Z2); if (!(index & 1)) TMC_SET_CURRENT(Z2);
#endif #endif
break; break;
case E_AXIS: { case E_AXIS: {
@ -11024,32 +11024,25 @@ inline void gcode_M502() {
} }
} }
if (report) LOOP_XYZE(i) switch (i) { if (report) {
case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
TMC_SAY_CURRENT(X); TMC_SAY_CURRENT(X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
TMC_SAY_CURRENT(X2); TMC_SAY_CURRENT(X2);
#endif #endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
TMC_SAY_CURRENT(Y); TMC_SAY_CURRENT(Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
TMC_SAY_CURRENT(Y2); TMC_SAY_CURRENT(Y2);
#endif #endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SAY_CURRENT(Z); TMC_SAY_CURRENT(Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SAY_CURRENT(Z2); TMC_SAY_CURRENT(Z2);
#endif #endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
TMC_SAY_CURRENT(E0); TMC_SAY_CURRENT(E0);
#endif #endif
@ -11065,7 +11058,6 @@ inline void gcode_M502() {
#if E4_IS_TRINAMIC #if E4_IS_TRINAMIC
TMC_SAY_CURRENT(E4); TMC_SAY_CURRENT(E4);
#endif #endif
break;
} }
} }
@ -11202,26 +11194,26 @@ inline void gcode_M502() {
switch (i) { switch (i) {
case X_AXIS: case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
if (index == 0) TMC_SET_PWMTHRS(X,X); if (index < 2) TMC_SET_PWMTHRS(X,X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
if (index == 1) 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
if (index == 0) TMC_SET_PWMTHRS(Y,Y); if (index < 2) TMC_SET_PWMTHRS(Y,Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
if (index == 1) 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
if (index == 0) TMC_SET_PWMTHRS(Z,Z); if (index < 2) TMC_SET_PWMTHRS(Z,Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
if (index == 1) TMC_SET_PWMTHRS(Z,Z2); if (!(index & 1)) TMC_SET_PWMTHRS(Z,Z2);
#endif #endif
break; break;
case E_AXIS: { case E_AXIS: {
@ -11247,32 +11239,25 @@ inline void gcode_M502() {
} }
} }
if (report) LOOP_XYZE(i) switch (i) { if (report) {
case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
TMC_SAY_PWMTHRS(X,X); TMC_SAY_PWMTHRS(X,X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
TMC_SAY_PWMTHRS(X,X2); TMC_SAY_PWMTHRS(X,X2);
#endif #endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
TMC_SAY_PWMTHRS(Y,Y); TMC_SAY_PWMTHRS(Y,Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
TMC_SAY_PWMTHRS(Y,Y2); TMC_SAY_PWMTHRS(Y,Y2);
#endif #endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SAY_PWMTHRS(Z,Z); TMC_SAY_PWMTHRS(Z,Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SAY_PWMTHRS(Z,Z2); TMC_SAY_PWMTHRS(Z,Z2);
#endif #endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(0); TMC_SAY_PWMTHRS_E(0);
#endif #endif
@ -11288,7 +11273,6 @@ inline void gcode_M502() {
#if E_STEPPERS > 4 && E4_IS_TRINAMIC #if E_STEPPERS > 4 && E4_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(4); TMC_SAY_PWMTHRS_E(4);
#endif #endif
break;
} }
} }
#endif // HYBRID_THRESHOLD #endif // HYBRID_THRESHOLD
@ -11310,66 +11294,60 @@ inline void gcode_M502() {
#if X_SENSORLESS #if X_SENSORLESS
case X_AXIS: case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
if (index == 0) TMC_SET_SGT(X); if (index < 2) TMC_SET_SGT(X);
#endif #endif
#if ENABLED(X2_IS_TMC2130) #if ENABLED(X2_IS_TMC2130)
if (index == 1) TMC_SET_SGT(X2); if (!(index & 1)) TMC_SET_SGT(X2);
#endif #endif
break; break;
#endif #endif
#if Y_SENSORLESS #if Y_SENSORLESS
case Y_AXIS: case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
if (index == 0) TMC_SET_SGT(Y); if (index < 2) TMC_SET_SGT(Y);
#endif #endif
#if ENABLED(Y2_IS_TMC2130) #if ENABLED(Y2_IS_TMC2130)
if (index == 1) TMC_SET_SGT(Y2); if (!(index & 1)) TMC_SET_SGT(Y2);
#endif #endif
break; break;
#endif #endif
#if Z_SENSORLESS #if Z_SENSORLESS
case Z_AXIS: case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
if (index == 0) TMC_SET_SGT(Z); if (index < 2) TMC_SET_SGT(Z);
#endif #endif
#if ENABLED(Z2_IS_TMC2130) #if ENABLED(Z2_IS_TMC2130)
if (index == 1) TMC_SET_SGT(Z2); if (!(index & 1)) TMC_SET_SGT(Z2);
#endif #endif
break; break;
#endif #endif
} }
} }
if (report) LOOP_XYZ(i) switch (i) { if (report) {
#if X_SENSORLESS #if X_SENSORLESS
case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(X); TMC_SAY_SGT(X);
#endif #endif
#if ENABLED(X2_IS_TMC2130) #if ENABLED(X2_IS_TMC2130)
TMC_SAY_SGT(X2); TMC_SAY_SGT(X2);
#endif #endif
break;
#endif #endif
#if Y_SENSORLESS #if Y_SENSORLESS
case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Y); TMC_SAY_SGT(Y);
#endif #endif
#if ENABLED(Y2_IS_TMC2130) #if ENABLED(Y2_IS_TMC2130)
TMC_SAY_SGT(Y2); TMC_SAY_SGT(Y2);
#endif #endif
break;
#endif #endif
#if Z_SENSORLESS #if Z_SENSORLESS
case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Z); TMC_SAY_SGT(Z);
#endif #endif
#if ENABLED(Z2_IS_TMC2130) #if ENABLED(Z2_IS_TMC2130)
TMC_SAY_SGT(Z2); TMC_SAY_SGT(Z2);
#endif #endif
break;
#endif #endif
} }
} }
@ -14757,6 +14735,6 @@ void loop() {
if (++cmd_queue_index_r >= BUFSIZE) cmd_queue_index_r = 0; if (++cmd_queue_index_r >= BUFSIZE) cmd_queue_index_r = 0;
} }
} }
endstops.report_state(); endstops.event_handler();
idle(); idle();
} }

View file

@ -189,7 +189,7 @@ void Endstops::init() {
} // Endstops::init } // Endstops::init
// Called from ISR: Poll endstop state if required // Called at ~1KHz from Temperature ISR: Poll endstop state if required
void Endstops::poll() { void Endstops::poll() {
#if ENABLED(PINS_DEBUGGING) #if ENABLED(PINS_DEBUGGING)
@ -231,8 +231,8 @@ void Endstops::not_homing() {
// If the last move failed to trigger an endstop, call kill // If the last move failed to trigger an endstop, call kill
void Endstops::validate_homing_move() { void Endstops::validate_homing_move() {
if (!trigger_state()) kill(PSTR(MSG_ERR_HOMING_FAILED)); if (trigger_state()) hit_on_purpose();
hit_on_purpose(); else kill(PSTR(MSG_ERR_HOMING_FAILED));
} }
// Enable / disable endstop z-probe checking // Enable / disable endstop z-probe checking
@ -256,8 +256,9 @@ void Endstops::validate_homing_move() {
} }
#endif #endif
void Endstops::report_state() { void Endstops::event_handler() {
if (hit_state) { static uint8_t prev_hit_state; // = 0
if (hit_state && hit_state != prev_hit_state) {
#if ENABLED(ULTRA_LCD) #if ENABLED(ULTRA_LCD)
char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' '; char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' ';
#define _SET_STOP_CHAR(A,C) (chr## A = C) #define _SET_STOP_CHAR(A,C) (chr## A = C)
@ -293,8 +294,6 @@ void Endstops::report_state() {
lcd_status_printf_P(0, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP); lcd_status_printf_P(0, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP);
#endif #endif
hit_on_purpose();
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT) #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)
if (planner.abort_on_endstop_hit) { if (planner.abort_on_endstop_hit) {
card.sdprinting = false; card.sdprinting = false;
@ -304,6 +303,7 @@ void Endstops::report_state() {
} }
#endif #endif
} }
prev_hit_state = hit_state;
} // Endstops::report_state } // Endstops::report_state
void Endstops::M119() { void Endstops::M119() {
@ -365,7 +365,7 @@ void Endstops::M119() {
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
// Check endstops - Could be called from ISR! // Check endstops - Could be called from Temperature ISR!
void Endstops::update() { void Endstops::update() {
#if DISABLED(ENDSTOP_NOISE_FILTER) #if DISABLED(ENDSTOP_NOISE_FILTER)
@ -540,7 +540,7 @@ void Endstops::update() {
if (dual_hit) { \ if (dual_hit) { \
_ENDSTOP_HIT(AXIS1, MINMAX); \ _ENDSTOP_HIT(AXIS1, MINMAX); \
/* if not performing home or if both endstops were trigged during homing... */ \ /* if not performing home or if both endstops were trigged during homing... */ \
if (!stepper.homing_dual_axis || dual_hit == 0x3) \ if (!stepper.homing_dual_axis || dual_hit == 0b11) \
planner.endstop_triggered(_AXIS(AXIS1)); \ planner.endstop_triggered(_AXIS(AXIS1)); \
} \ } \
}while(0) }while(0)

View file

@ -127,7 +127,7 @@ class Endstops {
/** /**
* Report endstop hits to serial. Called from loop(). * Report endstop hits to serial. Called from loop().
*/ */
static void report_state(); static void event_handler();
/** /**
* Report endstop positions in response to M119 * Report endstop positions in response to M119