Merge pull request #7255 from thinkyhead/bf_cleanup_july_6

Use FastIO for spindle, probe test, and case light
This commit is contained in:
Scott Lahteine 2017-07-06 22:03:27 -05:00 committed by GitHub
commit ce834bb78e
10 changed files with 46 additions and 42 deletions

View File

@ -5854,7 +5854,7 @@ inline void gcode_G92() {
WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT); // turn spindle off WRITE(SPINDLE_LASER_ENABLE_PIN, !SPINDLE_LASER_ENABLE_INVERT); // turn spindle off
delay_for_power_down(); delay_for_power_down();
} }
digitalWrite(SPINDLE_DIR_PIN, rotation_dir); WRITE(SPINDLE_DIR_PIN, rotation_dir);
#endif #endif
/** /**
@ -6474,20 +6474,20 @@ inline void gcode_M42() {
else { else {
report_pin_state_extended(pin, I_flag, true, "Pulsing "); report_pin_state_extended(pin, I_flag, true, "Pulsing ");
#if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO #if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
if (pin == 46) { if (pin == TEENSY_E2) {
SET_OUTPUT(46); SET_OUTPUT(TEENSY_E2);
for (int16_t j = 0; j < repeat; j++) { for (int16_t j = 0; j < repeat; j++) {
WRITE(46, 0); safe_delay(wait); WRITE(TEENSY_E2, LOW); safe_delay(wait);
WRITE(46, 1); safe_delay(wait); WRITE(TEENSY_E2, HIGH); safe_delay(wait);
WRITE(46, 0); safe_delay(wait); WRITE(TEENSY_E2, LOW); safe_delay(wait);
} }
} }
else if (pin == 47) { else if (pin == TEENSY_E3) {
SET_OUTPUT(47); SET_OUTPUT(TEENSY_E3);
for (int16_t j = 0; j < repeat; j++) { for (int16_t j = 0; j < repeat; j++) {
WRITE(47, 0); safe_delay(wait); WRITE(TEENSY_E3, LOW); safe_delay(wait);
WRITE(47, 1); safe_delay(wait); WRITE(TEENSY_E3, HIGH); safe_delay(wait);
WRITE(47, 0); safe_delay(wait); WRITE(TEENSY_E3, LOW); safe_delay(wait);
} }
} }
else else
@ -6569,10 +6569,10 @@ inline void gcode_M42() {
for (uint8_t i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
servo[probe_index].move(z_servo_angle[0]); //deploy servo[probe_index].move(z_servo_angle[0]); //deploy
safe_delay(500); safe_delay(500);
deploy_state = digitalRead(PROBE_TEST_PIN); deploy_state = READ(PROBE_TEST_PIN);
servo[probe_index].move(z_servo_angle[1]); //stow servo[probe_index].move(z_servo_angle[1]); //stow
safe_delay(500); safe_delay(500);
stow_state = digitalRead(PROBE_TEST_PIN); stow_state = READ(PROBE_TEST_PIN);
} }
if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards"); if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards");
@ -6607,9 +6607,9 @@ inline void gcode_M42() {
if (0 == j % (500 * 1)) // keep cmd_timeout happy if (0 == j % (500 * 1)) // keep cmd_timeout happy
refresh_cmd_timeout(); refresh_cmd_timeout();
if (deploy_state != digitalRead(PROBE_TEST_PIN)) { // probe triggered if (deploy_state != READ(PROBE_TEST_PIN)) { // probe triggered
for (probe_counter = 1; probe_counter < 50 && deploy_state != digitalRead(PROBE_TEST_PIN); ++probe_counter) for (probe_counter = 1; probe_counter < 50 && deploy_state != READ(PROBE_TEST_PIN); ++probe_counter)
safe_delay(2); safe_delay(2);
if (probe_counter == 50) if (probe_counter == 50)
@ -6671,7 +6671,7 @@ inline void gcode_M42() {
if (parser.seen('E')) { if (parser.seen('E')) {
endstop_monitor_flag = parser.value_bool(); endstop_monitor_flag = parser.value_bool();
SERIAL_PROTOCOLPGM("endstop monitor "); SERIAL_PROTOCOLPGM("endstop monitor ");
SERIAL_PROTOCOL(endstop_monitor_flag ? "en" : "dis"); serialprintPGM(endstop_monitor_flag ? PSTR("en") : PSTR("dis"));
SERIAL_PROTOCOLLNPGM("abled"); SERIAL_PROTOCOLLNPGM("abled");
return; return;
} }
@ -9876,9 +9876,9 @@ inline void gcode_M907() {
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) { if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness ); analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness );
} }
else digitalWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH ); else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? LOW : HIGH);
} }
else digitalWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW); else WRITE(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? HIGH : LOW);
} }
#endif // HAS_CASE_LIGHT #endif // HAS_CASE_LIGHT

View File

@ -382,6 +382,10 @@
#define DIO47_WPORT PORTE #define DIO47_WPORT PORTE
#define DIO47_PWM NULL #define DIO47_PWM NULL
#define DIO47_DDR DDRE #define DIO47_DDR DDRE
#define TEENSY_E2 46
#define TEENSY_E3 47
//-- end not supported by Teensyduino //-- end not supported by Teensyduino
#undef PA0 #undef PA0