mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-28 22:35:21 +00:00
Merge pull request #9543 from thinkyhead/bf1_reliable_probe_heaters_off
[1.1.x] More reliable PROBING_HEATERS_OFF with BED_LIMIT_SWITCHING
This commit is contained in:
commit
8979990805
@ -226,10 +226,6 @@ void clear_command_queue();
|
|||||||
extern millis_t previous_cmd_ms;
|
extern millis_t previous_cmd_ms;
|
||||||
inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
|
inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
|
||||||
|
|
||||||
#if ENABLED(FAST_PWM_FAN)
|
|
||||||
void setPwmFrequency(uint8_t pin, int val);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feedrate scaling and conversion
|
* Feedrate scaling and conversion
|
||||||
*/
|
*/
|
||||||
|
@ -6996,10 +6996,10 @@ inline void gcode_M31() {
|
|||||||
/**
|
/**
|
||||||
* Sensitive pin test for M42, M226
|
* Sensitive pin test for M42, M226
|
||||||
*/
|
*/
|
||||||
static bool pin_is_protected(const int8_t pin) {
|
static bool pin_is_protected(const pin_t pin) {
|
||||||
static const int8_t sensitive_pins[] PROGMEM = SENSITIVE_PINS;
|
static const pin_t sensitive_pins[] PROGMEM = SENSITIVE_PINS;
|
||||||
for (uint8_t i = 0; i < COUNT(sensitive_pins); i++)
|
for (uint8_t i = 0; i < COUNT(sensitive_pins); i++)
|
||||||
if (pin == (int8_t)pgm_read_byte(&sensitive_pins[i])) return true;
|
if (pin == (pin_t)pgm_read_byte(&sensitive_pins[i])) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7013,7 +7013,7 @@ inline void gcode_M42() {
|
|||||||
if (!parser.seenval('S')) return;
|
if (!parser.seenval('S')) return;
|
||||||
const byte pin_status = parser.value_byte();
|
const byte pin_status = parser.value_byte();
|
||||||
|
|
||||||
const int pin_number = parser.intval('P', LED_PIN);
|
const pin_t pin_number = parser.byteval('P', LED_PIN);
|
||||||
if (pin_number < 0) return;
|
if (pin_number < 0) return;
|
||||||
|
|
||||||
if (pin_is_protected(pin_number)) {
|
if (pin_is_protected(pin_number)) {
|
||||||
@ -7270,8 +7270,8 @@ inline void gcode_M42() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the range of pins to test or watch
|
// Get the range of pins to test or watch
|
||||||
const uint8_t first_pin = parser.byteval('P'),
|
const pin_t first_pin = parser.byteval('P'),
|
||||||
last_pin = parser.seenval('P') ? first_pin : NUM_DIGITAL_PINS - 1;
|
last_pin = parser.seenval('P') ? first_pin : NUM_DIGITAL_PINS - 1;
|
||||||
|
|
||||||
if (first_pin > last_pin) return;
|
if (first_pin > last_pin) return;
|
||||||
|
|
||||||
@ -7281,7 +7281,7 @@ inline void gcode_M42() {
|
|||||||
if (parser.boolval('W')) {
|
if (parser.boolval('W')) {
|
||||||
SERIAL_PROTOCOLLNPGM("Watching pins");
|
SERIAL_PROTOCOLLNPGM("Watching pins");
|
||||||
byte pin_state[last_pin - first_pin + 1];
|
byte pin_state[last_pin - first_pin + 1];
|
||||||
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
for (pin_t pin = first_pin; pin <= last_pin; pin++) {
|
||||||
if (pin_is_protected(pin) && !ignore_protection) continue;
|
if (pin_is_protected(pin) && !ignore_protection) continue;
|
||||||
pinMode(pin, INPUT_PULLUP);
|
pinMode(pin, INPUT_PULLUP);
|
||||||
delay(1);
|
delay(1);
|
||||||
@ -7299,7 +7299,7 @@ inline void gcode_M42() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
for (pin_t pin = first_pin; pin <= last_pin; pin++) {
|
||||||
if (pin_is_protected(pin) && !ignore_protection) continue;
|
if (pin_is_protected(pin) && !ignore_protection) continue;
|
||||||
const byte val =
|
const byte val =
|
||||||
/*
|
/*
|
||||||
@ -7327,7 +7327,7 @@ inline void gcode_M42() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Report current state of selected pin(s)
|
// Report current state of selected pin(s)
|
||||||
for (uint8_t pin = first_pin; pin <= last_pin; pin++)
|
for (pin_t pin = first_pin; pin <= last_pin; pin++)
|
||||||
report_pin_state_extended(pin, ignore_protection, true);
|
report_pin_state_extended(pin, ignore_protection, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9142,16 +9142,16 @@ inline void gcode_M221() {
|
|||||||
*/
|
*/
|
||||||
inline void gcode_M226() {
|
inline void gcode_M226() {
|
||||||
if (parser.seen('P')) {
|
if (parser.seen('P')) {
|
||||||
const int pin_number = parser.value_int(),
|
const int pin = parser.value_int(),
|
||||||
pin_state = parser.intval('S', -1); // required pin state - default is inverted
|
pin_state = parser.intval('S', -1); // required pin state - default is inverted
|
||||||
|
|
||||||
if (WITHIN(pin_state, -1, 1) && pin_number > -1 && !pin_is_protected(pin_number)) {
|
if (WITHIN(pin_state, -1, 1) && pin > -1 && !pin_is_protected(pin)) {
|
||||||
|
|
||||||
int target = LOW;
|
int target = LOW;
|
||||||
|
|
||||||
stepper.synchronize();
|
stepper.synchronize();
|
||||||
|
|
||||||
pinMode(pin_number, INPUT);
|
pinMode(pin, INPUT);
|
||||||
switch (pin_state) {
|
switch (pin_state) {
|
||||||
case 1:
|
case 1:
|
||||||
target = HIGH;
|
target = HIGH;
|
||||||
@ -9160,13 +9160,13 @@ inline void gcode_M226() {
|
|||||||
target = LOW;
|
target = LOW;
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
target = !digitalRead(pin_number);
|
target = !digitalRead(pin);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (digitalRead(pin_number) != target) idle();
|
while (digitalRead(pin) != target) idle();
|
||||||
|
|
||||||
} // pin_state -1 0 1 && pin_number > -1
|
} // pin_state -1 0 1 && pin > -1
|
||||||
} // parser.seen('P')
|
} // parser.seen('P')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13257,45 +13257,6 @@ void prepare_move_to_destination() {
|
|||||||
|
|
||||||
#endif // FILAMENT_RUNOUT_SENSOR
|
#endif // FILAMENT_RUNOUT_SENSOR
|
||||||
|
|
||||||
#if ENABLED(FAST_PWM_FAN)
|
|
||||||
|
|
||||||
void setPwmFrequency(uint8_t pin, int val) {
|
|
||||||
val &= 0x07;
|
|
||||||
switch (digitalPinToTimer(pin)) {
|
|
||||||
#ifdef TCCR0A
|
|
||||||
#if !AVR_AT90USB1286_FAMILY
|
|
||||||
case TIMER0A:
|
|
||||||
#endif
|
|
||||||
case TIMER0B: //_SET_CS(0, val);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef TCCR1A
|
|
||||||
case TIMER1A: case TIMER1B: //_SET_CS(1, val);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#if defined(TCCR2) || defined(TCCR2A)
|
|
||||||
#ifdef TCCR2
|
|
||||||
case TIMER2:
|
|
||||||
#endif
|
|
||||||
#ifdef TCCR2A
|
|
||||||
case TIMER2A: case TIMER2B:
|
|
||||||
#endif
|
|
||||||
_SET_CS(2, val); break;
|
|
||||||
#endif
|
|
||||||
#ifdef TCCR3A
|
|
||||||
case TIMER3A: case TIMER3B: case TIMER3C: _SET_CS(3, val); break;
|
|
||||||
#endif
|
|
||||||
#ifdef TCCR4A
|
|
||||||
case TIMER4A: case TIMER4B: case TIMER4C: _SET_CS(4, val); break;
|
|
||||||
#endif
|
|
||||||
#ifdef TCCR5A
|
|
||||||
case TIMER5A: case TIMER5B: case TIMER5C: _SET_CS(5, val); break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // FAST_PWM_FAN
|
|
||||||
|
|
||||||
void enable_all_steppers() {
|
void enable_all_steppers() {
|
||||||
#if ENABLED(AUTO_POWER_CONTROL)
|
#if ENABLED(AUTO_POWER_CONTROL)
|
||||||
powerManager.power_on();
|
powerManager.power_on();
|
||||||
|
@ -297,7 +297,7 @@ bool Sd2Card::eraseSingleBlockEnable() {
|
|||||||
* \return true for success, false for failure.
|
* \return true for success, false for failure.
|
||||||
* The reason for failure can be determined by calling errorCode() and errorData().
|
* The reason for failure can be determined by calling errorCode() and errorData().
|
||||||
*/
|
*/
|
||||||
bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
|
bool Sd2Card::init(uint8_t sckRateID, pin_t chipSelectPin) {
|
||||||
errorCode_ = type_ = 0;
|
errorCode_ = type_ = 0;
|
||||||
chipSelectPin_ = chipSelectPin;
|
chipSelectPin_ = chipSelectPin;
|
||||||
// 16-bit init start time allows over a minute
|
// 16-bit init start time allows over a minute
|
||||||
|
@ -140,7 +140,7 @@ class Sd2Card {
|
|||||||
* \return true for success or false for failure.
|
* \return true for success or false for failure.
|
||||||
*/
|
*/
|
||||||
bool init(uint8_t sckRateID = SPI_FULL_SPEED,
|
bool init(uint8_t sckRateID = SPI_FULL_SPEED,
|
||||||
uint8_t chipSelectPin = SD_CHIP_SELECT_PIN);
|
pin_t chipSelectPin = SD_CHIP_SELECT_PIN);
|
||||||
bool readBlock(uint32_t block, uint8_t* dst);
|
bool readBlock(uint32_t block, uint8_t* dst);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +29,10 @@
|
|||||||
#ifndef _FASTIO_ARDUINO_H
|
#ifndef _FASTIO_ARDUINO_H
|
||||||
#define _FASTIO_ARDUINO_H
|
#define _FASTIO_ARDUINO_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef uint8_t pin_t;
|
||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
|
#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
|
||||||
|
@ -71,7 +71,7 @@ bool endstop_monitor_flag = false;
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char * const name;
|
const char * const name;
|
||||||
uint8_t pin;
|
pin_t pin;
|
||||||
bool is_digital;
|
bool is_digital;
|
||||||
} PinInfo;
|
} PinInfo;
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ int Temperature::getHeaterPower(int heater) {
|
|||||||
#if HAS_AUTO_FAN
|
#if HAS_AUTO_FAN
|
||||||
|
|
||||||
void Temperature::checkExtruderAutoFans() {
|
void Temperature::checkExtruderAutoFans() {
|
||||||
static const int8_t fanPin[] PROGMEM = { E0_AUTO_FAN_PIN, E1_AUTO_FAN_PIN, E2_AUTO_FAN_PIN, E3_AUTO_FAN_PIN, E4_AUTO_FAN_PIN };
|
static const pin_t fanPin[] PROGMEM = { E0_AUTO_FAN_PIN, E1_AUTO_FAN_PIN, E2_AUTO_FAN_PIN, E3_AUTO_FAN_PIN, E4_AUTO_FAN_PIN };
|
||||||
static const uint8_t fanBit[] PROGMEM = {
|
static const uint8_t fanBit[] PROGMEM = {
|
||||||
0,
|
0,
|
||||||
AUTO_1_IS_0 ? 0 : 1,
|
AUTO_1_IS_0 ? 0 : 1,
|
||||||
@ -524,7 +524,7 @@ int Temperature::getHeaterPower(int heater) {
|
|||||||
|
|
||||||
uint8_t fanDone = 0;
|
uint8_t fanDone = 0;
|
||||||
for (uint8_t f = 0; f < COUNT(fanPin); f++) {
|
for (uint8_t f = 0; f < COUNT(fanPin); f++) {
|
||||||
int8_t pin = pgm_read_byte(&fanPin[f]);
|
pin_t pin = pgm_read_byte(&fanPin[f]);
|
||||||
const uint8_t bit = pgm_read_byte(&fanBit[f]);
|
const uint8_t bit = pgm_read_byte(&fanBit[f]);
|
||||||
if (pin >= 0 && !TEST(fanDone, bit)) {
|
if (pin >= 0 && !TEST(fanDone, bit)) {
|
||||||
uint8_t newFanSpeed = TEST(fanState, bit) ? EXTRUDER_AUTO_FAN_SPEED : 0;
|
uint8_t newFanSpeed = TEST(fanState, bit) ? EXTRUDER_AUTO_FAN_SPEED : 0;
|
||||||
@ -738,6 +738,10 @@ float Temperature::get_pid_output(const int8_t e) {
|
|||||||
*/
|
*/
|
||||||
void Temperature::manage_heater() {
|
void Temperature::manage_heater() {
|
||||||
|
|
||||||
|
#if ENABLED(PROBING_HEATERS_OFF) && ENABLED(BED_LIMIT_SWITCHING)
|
||||||
|
static bool last_pause_state;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!temp_meas_ready) return;
|
if (!temp_meas_ready) return;
|
||||||
|
|
||||||
updateTemperaturesFromRawValues(); // also resets the watchdog
|
updateTemperaturesFromRawValues(); // also resets the watchdog
|
||||||
@ -814,8 +818,15 @@ void Temperature::manage_heater() {
|
|||||||
#endif // WATCH_THE_BED
|
#endif // WATCH_THE_BED
|
||||||
|
|
||||||
#if DISABLED(PIDTEMPBED)
|
#if DISABLED(PIDTEMPBED)
|
||||||
if (PENDING(ms, next_bed_check_ms)) return;
|
if (PENDING(ms, next_bed_check_ms)
|
||||||
|
#if ENABLED(PROBING_HEATERS_OFF) && ENABLED(BED_LIMIT_SWITCHING)
|
||||||
|
&& paused == last_pause_state
|
||||||
|
#endif
|
||||||
|
) return;
|
||||||
next_bed_check_ms = ms + BED_CHECK_INTERVAL;
|
next_bed_check_ms = ms + BED_CHECK_INTERVAL;
|
||||||
|
#if ENABLED(PROBING_HEATERS_OFF) && ENABLED(BED_LIMIT_SWITCHING)
|
||||||
|
last_pause_state = paused;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_TEMP_BED
|
#if HAS_TEMP_BED
|
||||||
@ -1256,6 +1267,45 @@ void Temperature::init() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLED(FAST_PWM_FAN)
|
||||||
|
|
||||||
|
void setPwmFrequency(const pin_t pin, int val) {
|
||||||
|
val &= 0x07;
|
||||||
|
switch (digitalPinToTimer(pin)) {
|
||||||
|
#ifdef TCCR0A
|
||||||
|
#if !AVR_AT90USB1286_FAMILY
|
||||||
|
case TIMER0A:
|
||||||
|
#endif
|
||||||
|
case TIMER0B: //_SET_CS(0, val);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef TCCR1A
|
||||||
|
case TIMER1A: case TIMER1B: //_SET_CS(1, val);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if defined(TCCR2) || defined(TCCR2A)
|
||||||
|
#ifdef TCCR2
|
||||||
|
case TIMER2:
|
||||||
|
#endif
|
||||||
|
#ifdef TCCR2A
|
||||||
|
case TIMER2A: case TIMER2B:
|
||||||
|
#endif
|
||||||
|
_SET_CS(2, val); break;
|
||||||
|
#endif
|
||||||
|
#ifdef TCCR3A
|
||||||
|
case TIMER3A: case TIMER3B: case TIMER3C: _SET_CS(3, val); break;
|
||||||
|
#endif
|
||||||
|
#ifdef TCCR4A
|
||||||
|
case TIMER4A: case TIMER4B: case TIMER4C: _SET_CS(4, val); break;
|
||||||
|
#endif
|
||||||
|
#ifdef TCCR5A
|
||||||
|
case TIMER5A: case TIMER5B: case TIMER5C: _SET_CS(5, val); break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // FAST_PWM_FAN
|
||||||
|
|
||||||
#if WATCH_HOTENDS
|
#if WATCH_HOTENDS
|
||||||
/**
|
/**
|
||||||
* Start Heating Sanity Check for hotends that are below
|
* Start Heating Sanity Check for hotends that are below
|
||||||
|
@ -587,6 +587,10 @@ class Temperature {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
#if ENABLED(FAST_PWM_FAN)
|
||||||
|
void setPwmFrequency(const pin_t pin, int val);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void set_current_temp_raw();
|
static void set_current_temp_raw();
|
||||||
|
|
||||||
static void updateTemperaturesFromRawValues();
|
static void updateTemperaturesFromRawValues();
|
||||||
|
Loading…
Reference in New Issue
Block a user