Browse Source

Use bool in pin compare

pull/1/head
Scott Lahteine 5 years ago
parent
commit
dda76e50a9
  1. 14
      Marlin/src/feature/controllerfan.cpp
  2. 78
      Marlin/src/module/stepper/indirection.h

14
Marlin/src/feature/controllerfan.cpp

@ -36,27 +36,27 @@ void controllerfan_update() {
if (ELAPSED(ms, nextMotorCheck)) {
nextMotorCheck = ms + 2500UL; // Not a time critical function, so only check every 2.5s
const bool xory = X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON;
const bool xory = X_ENABLE_READ() == bool(X_ENABLE_ON) || Y_ENABLE_READ() == bool(Y_ENABLE_ON);
// If any of the drivers or the bed are enabled...
if (xory || Z_ENABLE_READ() == Z_ENABLE_ON
if (xory || Z_ENABLE_READ() == bool(Z_ENABLE_ON)
#if HAS_HEATED_BED
|| thermalManager.temp_bed.soft_pwm_amount > 0
#endif
#if HAS_X2_ENABLE
|| X2_ENABLE_READ() == X_ENABLE_ON
|| X2_ENABLE_READ() == bool(X_ENABLE_ON)
#endif
#if HAS_Y2_ENABLE
|| Y2_ENABLE_READ() == Y_ENABLE_ON
|| Y2_ENABLE_READ() == bool(Y_ENABLE_ON)
#endif
#if HAS_Z2_ENABLE
|| Z2_ENABLE_READ() == Z_ENABLE_ON
|| Z2_ENABLE_READ() == bool(Z_ENABLE_ON)
#endif
#if HAS_Z3_ENABLE
|| Z3_ENABLE_READ() == Z_ENABLE_ON
|| Z3_ENABLE_READ() == bool(Z_ENABLE_ON)
#endif
#if E_STEPPERS
#define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON
#define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == bool(E_ENABLE_ON)
REPEAT(E_STEPPERS, _OR_ENABLED_E)
#endif
) {

78
Marlin/src/module/stepper/indirection.h

@ -51,70 +51,70 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#ifndef X_ENABLE_INIT
#define X_ENABLE_INIT() SET_OUTPUT(X_ENABLE_PIN)
#define X_ENABLE_WRITE(STATE) WRITE(X_ENABLE_PIN,STATE)
#define X_ENABLE_READ() READ(X_ENABLE_PIN)
#define X_ENABLE_READ() bool(READ(X_ENABLE_PIN))
#endif
#ifndef X_DIR_INIT
#define X_DIR_INIT() SET_OUTPUT(X_DIR_PIN)
#define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE)
#define X_DIR_READ() READ(X_DIR_PIN)
#define X_DIR_READ() bool(READ(X_DIR_PIN))
#endif
#define X_STEP_INIT() SET_OUTPUT(X_STEP_PIN)
#ifndef X_STEP_WRITE
#define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)
#endif
#define X_STEP_READ() READ(X_STEP_PIN)
#define X_STEP_READ() bool(READ(X_STEP_PIN))
// Y Stepper
#ifndef Y_ENABLE_INIT
#define Y_ENABLE_INIT() SET_OUTPUT(Y_ENABLE_PIN)
#define Y_ENABLE_WRITE(STATE) WRITE(Y_ENABLE_PIN,STATE)
#define Y_ENABLE_READ() READ(Y_ENABLE_PIN)
#define Y_ENABLE_READ() bool(READ(Y_ENABLE_PIN))
#endif
#ifndef Y_DIR_INIT
#define Y_DIR_INIT() SET_OUTPUT(Y_DIR_PIN)
#define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE)
#define Y_DIR_READ() READ(Y_DIR_PIN)
#define Y_DIR_READ() bool(READ(Y_DIR_PIN))
#endif
#define Y_STEP_INIT() SET_OUTPUT(Y_STEP_PIN)
#ifndef Y_STEP_WRITE
#define Y_STEP_WRITE(STATE) WRITE(Y_STEP_PIN,STATE)
#endif
#define Y_STEP_READ() READ(Y_STEP_PIN)
#define Y_STEP_READ() bool(READ(Y_STEP_PIN))
// Z Stepper
#ifndef Z_ENABLE_INIT
#define Z_ENABLE_INIT() SET_OUTPUT(Z_ENABLE_PIN)
#define Z_ENABLE_WRITE(STATE) WRITE(Z_ENABLE_PIN,STATE)
#define Z_ENABLE_READ() READ(Z_ENABLE_PIN)
#define Z_ENABLE_READ() bool(READ(Z_ENABLE_PIN))
#endif
#ifndef Z_DIR_INIT
#define Z_DIR_INIT() SET_OUTPUT(Z_DIR_PIN)
#define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE)
#define Z_DIR_READ() READ(Z_DIR_PIN)
#define Z_DIR_READ() bool(READ(Z_DIR_PIN))
#endif
#define Z_STEP_INIT() SET_OUTPUT(Z_STEP_PIN)
#ifndef Z_STEP_WRITE
#define Z_STEP_WRITE(STATE) WRITE(Z_STEP_PIN,STATE)
#endif
#define Z_STEP_READ() READ(Z_STEP_PIN)
#define Z_STEP_READ() bool(READ(Z_STEP_PIN))
// X2 Stepper
#if HAS_X2_ENABLE
#ifndef X2_ENABLE_INIT
#define X2_ENABLE_INIT() SET_OUTPUT(X2_ENABLE_PIN)
#define X2_ENABLE_WRITE(STATE) WRITE(X2_ENABLE_PIN,STATE)
#define X2_ENABLE_READ() READ(X2_ENABLE_PIN)
#define X2_ENABLE_READ() bool(READ(X2_ENABLE_PIN))
#endif
#ifndef X2_DIR_INIT
#define X2_DIR_INIT() SET_OUTPUT(X2_DIR_PIN)
#define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE)
#define X2_DIR_READ() READ(X2_DIR_PIN)
#define X2_DIR_READ() bool(READ(X2_DIR_PIN))
#endif
#define X2_STEP_INIT() SET_OUTPUT(X2_STEP_PIN)
#ifndef X2_STEP_WRITE
#define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE)
#endif
#define X2_STEP_READ() READ(X2_STEP_PIN)
#define X2_STEP_READ() bool(READ(X2_STEP_PIN))
#endif
// Y2 Stepper
@ -122,18 +122,18 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#ifndef Y2_ENABLE_INIT
#define Y2_ENABLE_INIT() SET_OUTPUT(Y2_ENABLE_PIN)
#define Y2_ENABLE_WRITE(STATE) WRITE(Y2_ENABLE_PIN,STATE)
#define Y2_ENABLE_READ() READ(Y2_ENABLE_PIN)
#define Y2_ENABLE_READ() bool(READ(Y2_ENABLE_PIN))
#endif
#ifndef Y2_DIR_INIT
#define Y2_DIR_INIT() SET_OUTPUT(Y2_DIR_PIN)
#define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE)
#define Y2_DIR_READ() READ(Y2_DIR_PIN)
#define Y2_DIR_READ() bool(READ(Y2_DIR_PIN))
#endif
#define Y2_STEP_INIT() SET_OUTPUT(Y2_STEP_PIN)
#ifndef Y2_STEP_WRITE
#define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE)
#endif
#define Y2_STEP_READ() READ(Y2_STEP_PIN)
#define Y2_STEP_READ() bool(READ(Y2_STEP_PIN))
#else
#define Y2_DIR_WRITE(STATE) NOOP
#endif
@ -143,18 +143,18 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#ifndef Z2_ENABLE_INIT
#define Z2_ENABLE_INIT() SET_OUTPUT(Z2_ENABLE_PIN)
#define Z2_ENABLE_WRITE(STATE) WRITE(Z2_ENABLE_PIN,STATE)
#define Z2_ENABLE_READ() READ(Z2_ENABLE_PIN)
#define Z2_ENABLE_READ() bool(READ(Z2_ENABLE_PIN))
#endif
#ifndef Z2_DIR_INIT
#define Z2_DIR_INIT() SET_OUTPUT(Z2_DIR_PIN)
#define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE)
#define Z2_DIR_READ() READ(Z2_DIR_PIN)
#define Z2_DIR_READ() bool(READ(Z2_DIR_PIN))
#endif
#define Z2_STEP_INIT() SET_OUTPUT(Z2_STEP_PIN)
#ifndef Z2_STEP_WRITE
#define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE)
#endif
#define Z2_STEP_READ() READ(Z2_STEP_PIN)
#define Z2_STEP_READ() bool(READ(Z2_STEP_PIN))
#else
#define Z2_DIR_WRITE(STATE) NOOP
#endif
@ -164,18 +164,18 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#ifndef Z3_ENABLE_INIT
#define Z3_ENABLE_INIT() SET_OUTPUT(Z3_ENABLE_PIN)
#define Z3_ENABLE_WRITE(STATE) WRITE(Z3_ENABLE_PIN,STATE)
#define Z3_ENABLE_READ() READ(Z3_ENABLE_PIN)
#define Z3_ENABLE_READ() bool(READ(Z3_ENABLE_PIN))
#endif
#ifndef Z3_DIR_INIT
#define Z3_DIR_INIT() SET_OUTPUT(Z3_DIR_PIN)
#define Z3_DIR_WRITE(STATE) WRITE(Z3_DIR_PIN,STATE)
#define Z3_DIR_READ() READ(Z3_DIR_PIN)
#define Z3_DIR_READ() bool(READ(Z3_DIR_PIN))
#endif
#define Z3_STEP_INIT() SET_OUTPUT(Z3_STEP_PIN)
#ifndef Z3_STEP_WRITE
#define Z3_STEP_WRITE(STATE) WRITE(Z3_STEP_PIN,STATE)
#endif
#define Z3_STEP_READ() READ(Z3_STEP_PIN)
#define Z3_STEP_READ() bool(READ(Z3_STEP_PIN))
#else
#define Z3_DIR_WRITE(STATE) NOOP
#endif
@ -184,103 +184,103 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
#ifndef E0_ENABLE_INIT
#define E0_ENABLE_INIT() SET_OUTPUT(E0_ENABLE_PIN)
#define E0_ENABLE_WRITE(STATE) WRITE(E0_ENABLE_PIN,STATE)
#define E0_ENABLE_READ() READ(E0_ENABLE_PIN)
#define E0_ENABLE_READ() bool(READ(E0_ENABLE_PIN))
#endif
#ifndef E0_DIR_INIT
#define E0_DIR_INIT() SET_OUTPUT(E0_DIR_PIN)
#define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE)
#define E0_DIR_READ() READ(E0_DIR_PIN)
#define E0_DIR_READ() bool(READ(E0_DIR_PIN))
#endif
#define E0_STEP_INIT() SET_OUTPUT(E0_STEP_PIN)
#ifndef E0_STEP_WRITE
#define E0_STEP_WRITE(STATE) WRITE(E0_STEP_PIN,STATE)
#endif
#define E0_STEP_READ() READ(E0_STEP_PIN)
#define E0_STEP_READ() bool(READ(E0_STEP_PIN))
// E1 Stepper
#ifndef E1_ENABLE_INIT
#define E1_ENABLE_INIT() SET_OUTPUT(E1_ENABLE_PIN)
#define E1_ENABLE_WRITE(STATE) WRITE(E1_ENABLE_PIN,STATE)
#define E1_ENABLE_READ() READ(E1_ENABLE_PIN)
#define E1_ENABLE_READ() bool(READ(E1_ENABLE_PIN))
#endif
#ifndef E1_DIR_INIT
#define E1_DIR_INIT() SET_OUTPUT(E1_DIR_PIN)
#define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE)
#define E1_DIR_READ() READ(E1_DIR_PIN)
#define E1_DIR_READ() bool(READ(E1_DIR_PIN))
#endif
#define E1_STEP_INIT() SET_OUTPUT(E1_STEP_PIN)
#ifndef E1_STEP_WRITE
#define E1_STEP_WRITE(STATE) WRITE(E1_STEP_PIN,STATE)
#endif
#define E1_STEP_READ() READ(E1_STEP_PIN)
#define E1_STEP_READ() bool(READ(E1_STEP_PIN))
// E2 Stepper
#ifndef E2_ENABLE_INIT
#define E2_ENABLE_INIT() SET_OUTPUT(E2_ENABLE_PIN)
#define E2_ENABLE_WRITE(STATE) WRITE(E2_ENABLE_PIN,STATE)
#define E2_ENABLE_READ() READ(E2_ENABLE_PIN)
#define E2_ENABLE_READ() bool(READ(E2_ENABLE_PIN))
#endif
#ifndef E2_DIR_INIT
#define E2_DIR_INIT() SET_OUTPUT(E2_DIR_PIN)
#define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE)
#define E2_DIR_READ() READ(E2_DIR_PIN)
#define E2_DIR_READ() bool(READ(E2_DIR_PIN))
#endif
#define E2_STEP_INIT() SET_OUTPUT(E2_STEP_PIN)
#ifndef E2_STEP_WRITE
#define E2_STEP_WRITE(STATE) WRITE(E2_STEP_PIN,STATE)
#endif
#define E2_STEP_READ() READ(E2_STEP_PIN)
#define E2_STEP_READ() bool(READ(E2_STEP_PIN))
// E3 Stepper
#ifndef E3_ENABLE_INIT
#define E3_ENABLE_INIT() SET_OUTPUT(E3_ENABLE_PIN)
#define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
#define E3_ENABLE_READ() READ(E3_ENABLE_PIN)
#define E3_ENABLE_READ() bool(READ(E3_ENABLE_PIN))
#endif
#ifndef E3_DIR_INIT
#define E3_DIR_INIT() SET_OUTPUT(E3_DIR_PIN)
#define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE)
#define E3_DIR_READ() READ(E3_DIR_PIN)
#define E3_DIR_READ() bool(READ(E3_DIR_PIN))
#endif
#define E3_STEP_INIT() SET_OUTPUT(E3_STEP_PIN)
#ifndef E3_STEP_WRITE
#define E3_STEP_WRITE(STATE) WRITE(E3_STEP_PIN,STATE)
#endif
#define E3_STEP_READ() READ(E3_STEP_PIN)
#define E3_STEP_READ() bool(READ(E3_STEP_PIN))
// E4 Stepper
#ifndef E4_ENABLE_INIT
#define E4_ENABLE_INIT() SET_OUTPUT(E4_ENABLE_PIN)
#define E4_ENABLE_WRITE(STATE) WRITE(E4_ENABLE_PIN,STATE)
#define E4_ENABLE_READ() READ(E4_ENABLE_PIN)
#define E4_ENABLE_READ() bool(READ(E4_ENABLE_PIN))
#endif
#ifndef E4_DIR_INIT
#define E4_DIR_INIT() SET_OUTPUT(E4_DIR_PIN)
#define E4_DIR_WRITE(STATE) WRITE(E4_DIR_PIN,STATE)
#define E4_DIR_READ() READ(E4_DIR_PIN)
#define E4_DIR_READ() bool(READ(E4_DIR_PIN))
#endif
#define E4_STEP_INIT() SET_OUTPUT(E4_STEP_PIN)
#ifndef E4_STEP_WRITE
#define E4_STEP_WRITE(STATE) WRITE(E4_STEP_PIN,STATE)
#endif
#define E4_STEP_READ() READ(E4_STEP_PIN)
#define E4_STEP_READ() bool(READ(E4_STEP_PIN))
// E5 Stepper
#ifndef E5_ENABLE_INIT
#define E5_ENABLE_INIT() SET_OUTPUT(E5_ENABLE_PIN)
#define E5_ENABLE_WRITE(STATE) WRITE(E5_ENABLE_PIN,STATE)
#define E5_ENABLE_READ() READ(E5_ENABLE_PIN)
#define E5_ENABLE_READ() bool(READ(E5_ENABLE_PIN))
#endif
#ifndef E5_DIR_INIT
#define E5_DIR_INIT() SET_OUTPUT(E5_DIR_PIN)
#define E5_DIR_WRITE(STATE) WRITE(E5_DIR_PIN,STATE)
#define E5_DIR_READ() READ(E5_DIR_PIN)
#define E5_DIR_READ() bool(READ(E5_DIR_PIN))
#endif
#define E5_STEP_INIT() SET_OUTPUT(E5_STEP_PIN)
#ifndef E5_STEP_WRITE
#define E5_STEP_WRITE(STATE) WRITE(E5_STEP_PIN,STATE)
#endif
#define E5_STEP_READ() READ(E5_STEP_PIN)
#define E5_STEP_READ() bool(READ(E5_STEP_PIN))
/**
* Extruder indirection for the single E axis

Loading…
Cancel
Save