Use direct pin manipulation whenever possible

This commit is contained in:
Scott Lahteine 2017-04-14 16:36:12 -05:00
parent 19d0c6a0c0
commit ea734f910b
2 changed files with 16 additions and 16 deletions

View File

@ -963,15 +963,15 @@ void servo_init() {
// This variant uses 3 separate pins for the RGB components.
// If the pins can do PWM then their intensity will be set.
digitalWrite(RGB_LED_R_PIN, r ? HIGH : LOW);
digitalWrite(RGB_LED_G_PIN, g ? HIGH : LOW);
digitalWrite(RGB_LED_B_PIN, b ? HIGH : LOW);
WRITE(RGB_LED_R_PIN, r ? HIGH : LOW);
WRITE(RGB_LED_G_PIN, g ? HIGH : LOW);
WRITE(RGB_LED_B_PIN, b ? HIGH : LOW);
analogWrite(RGB_LED_R_PIN, r);
analogWrite(RGB_LED_G_PIN, g);
analogWrite(RGB_LED_B_PIN, b);
#if ENABLED(RGBW_LED)
digitalWrite(RGB_LED_W_PIN, w ? HIGH : LOW);
WRITE(RGB_LED_W_PIN, w ? HIGH : LOW);
analogWrite(RGB_LED_W_PIN, w);
#endif
@ -8548,7 +8548,7 @@ inline void gcode_M907() {
uint8_t case_light_brightness = 255;
void update_case_light() {
digitalWrite(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? HIGH : LOW);
WRITE(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? HIGH : LOW);
analogWrite(CASE_LIGHT_PIN, case_light_on != INVERT_CASE_LIGHT ? case_light_brightness : 0);
}
@ -10739,7 +10739,7 @@ void prepare_move_to_destination() {
uint8_t speed = (!lastMotorOn || ELAPSED(ms, lastMotorOn + (CONTROLLERFAN_SECS) * 1000UL)) ? 0 : CONTROLLERFAN_SPEED;
// allows digital or PWM fan output to be used (see M42 handling)
digitalWrite(CONTROLLERFAN_PIN, speed);
WRITE(CONTROLLERFAN_PIN, speed);
analogWrite(CONTROLLERFAN_PIN, speed);
}
}

View File

@ -1484,33 +1484,33 @@ void Stepper::report_positions() {
void Stepper::microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
if (ms1 >= 0) switch (driver) {
case 0: digitalWrite(X_MS1_PIN, ms1); break;
case 0: WRITE(X_MS1_PIN, ms1); break;
#if HAS_MICROSTEPS_Y
case 1: digitalWrite(Y_MS1_PIN, ms1); break;
case 1: WRITE(Y_MS1_PIN, ms1); break;
#endif
#if HAS_MICROSTEPS_Z
case 2: digitalWrite(Z_MS1_PIN, ms1); break;
case 2: WRITE(Z_MS1_PIN, ms1); break;
#endif
#if HAS_MICROSTEPS_E0
case 3: digitalWrite(E0_MS1_PIN, ms1); break;
case 3: WRITE(E0_MS1_PIN, ms1); break;
#endif
#if HAS_MICROSTEPS_E1
case 4: digitalWrite(E1_MS1_PIN, ms1); break;
case 4: WRITE(E1_MS1_PIN, ms1); break;
#endif
}
if (ms2 >= 0) switch (driver) {
case 0: digitalWrite(X_MS2_PIN, ms2); break;
case 0: WRITE(X_MS2_PIN, ms2); break;
#if HAS_MICROSTEPS_Y
case 1: digitalWrite(Y_MS2_PIN, ms2); break;
case 1: WRITE(Y_MS2_PIN, ms2); break;
#endif
#if HAS_MICROSTEPS_Z
case 2: digitalWrite(Z_MS2_PIN, ms2); break;
case 2: WRITE(Z_MS2_PIN, ms2); break;
#endif
#if HAS_MICROSTEPS_E0
case 3: digitalWrite(E0_MS2_PIN, ms2); break;
case 3: WRITE(E0_MS2_PIN, ms2); break;
#endif
#if HAS_MICROSTEPS_E1
case 4: digitalWrite(E1_MS2_PIN, ms2); break;
case 4: WRITE(E1_MS2_PIN, ms2); break;
#endif
}
}