Apply TERN to compact code (#17619)

This commit is contained in:
Scott Lahteine 2020-04-22 16:35:03 -05:00 committed by GitHub
parent 88bdd26c99
commit 6d90d1e1f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
162 changed files with 1493 additions and 3530 deletions

View file

@ -73,9 +73,7 @@ int MarlinSerialUSB::peek() {
pending_char = udi_cdc_getc(); pending_char = udi_cdc_getc();
#if ENABLED(EMERGENCY_PARSER) TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)pending_char));
emergency_parser.update(emergency_state, (char)pending_char);
#endif
return pending_char; return pending_char;
} }
@ -97,9 +95,7 @@ int MarlinSerialUSB::read() {
int c = udi_cdc_getc(); int c = udi_cdc_getc();
#if ENABLED(EMERGENCY_PARSER) TERN_(EMERGENCY_PARSER, emergency_parser.update(emergency_state, (char)c));
emergency_parser.update(emergency_state, (char)c);
#endif
return c; return c;
} }

View file

@ -47,43 +47,21 @@ void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
#if HAS_X_MAX TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
_ATTACH(X_MAX_PIN); TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
#endif TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
#if HAS_X_MIN TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
_ATTACH(X_MIN_PIN); TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
#endif TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
#if HAS_Y_MAX TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
_ATTACH(Y_MAX_PIN); TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
#endif TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
#if HAS_Y_MIN TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
_ATTACH(Y_MIN_PIN); TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
#endif TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
#if HAS_Z_MAX TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
_ATTACH(Z_MAX_PIN); TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
#endif TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
#if HAS_Z_MIN TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
_ATTACH(Z_MIN_PIN); TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
#endif
#if HAS_Z2_MAX
_ATTACH(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
_ATTACH(Z2_MIN_PIN);
#endif
#if HAS_Z3_MAX
_ATTACH(Z3_MAX_PIN);
#endif
#if HAS_Z3_MIN
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif
} }

View file

@ -174,7 +174,7 @@
#define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0) #define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
// Shorthand // Shorthand
#define OUT_WRITE(IO,V) { SET_OUTPUT(IO); WRITE(IO,V); } #define OUT_WRITE(IO,V) do{ SET_OUTPUT(IO); WRITE(IO,V); }while(0)
// digitalRead/Write wrappers // digitalRead/Write wrappers
#define extDigitalRead(IO) digitalRead(IO) #define extDigitalRead(IO) digitalRead(IO)

View file

@ -97,9 +97,7 @@ void HAL_init_board() {
esp3dlib.init(); esp3dlib.init();
#elif ENABLED(WIFISUPPORT) #elif ENABLED(WIFISUPPORT)
wifi_init(); wifi_init();
#if ENABLED(OTASUPPORT) TERN_(OTASUPPORT, OTA_init());
OTA_init();
#endif
#if ENABLED(WEBSUPPORT) #if ENABLED(WEBSUPPORT)
spiffs_init(); spiffs_init();
web_init(); web_init();
@ -133,9 +131,7 @@ void HAL_idletask() {
#if BOTH(WIFISUPPORT, OTASUPPORT) #if BOTH(WIFISUPPORT, OTASUPPORT)
OTA_handle(); OTA_handle();
#endif #endif
#if ENABLED(ESP3D_WIFISUPPORT) TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask());
esp3dlib.idletask();
#endif
} }
void HAL_clear_reset_source() { } void HAL_clear_reset_source() { }
@ -176,39 +172,17 @@ void HAL_adc_init() {
adc1_config_width(ADC_WIDTH_12Bit); adc1_config_width(ADC_WIDTH_12Bit);
// Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects // Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects
#if HAS_TEMP_ADC_0 TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db));
adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db); TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db));
#endif TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db));
#if HAS_TEMP_ADC_1 TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db));
adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db); TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db));
#endif TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db));
#if HAS_TEMP_ADC_2 TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db));
adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db); TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
#endif TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
#if HAS_TEMP_ADC_3 TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db); TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
#endif
#if HAS_TEMP_ADC_4
adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_5
adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_6
adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_7
adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db);
#endif
#if HAS_HEATED_BED
adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_CHAMBER
adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db);
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db);
#endif
// Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail. // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
// That's why we're not setting it up here. // That's why we're not setting it up here.

View file

@ -61,9 +61,7 @@ void Servo::move(const int value) {
if (attach(0) >= 0) { if (attach(0) >= 0) {
write(value); write(value);
safe_delay(servo_delay[channel]); safe_delay(servo_delay[channel]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }
#endif // HAS_SERVOS #endif // HAS_SERVOS

View file

@ -42,43 +42,21 @@ void ICACHE_RAM_ATTR endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
#if HAS_X_MAX TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
_ATTACH(X_MAX_PIN); TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
#endif TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
#if HAS_X_MIN TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
_ATTACH(X_MIN_PIN); TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
#endif TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
#if HAS_Y_MAX TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
_ATTACH(Y_MAX_PIN); TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
#endif TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
#if HAS_Y_MIN TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
_ATTACH(Y_MIN_PIN); TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
#endif TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
#if HAS_Z_MAX TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
_ATTACH(Z_MAX_PIN); TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
#endif TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
#if HAS_Z_MIN TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
_ATTACH(Z_MIN_PIN); TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
#endif
#if HAS_Z2_MAX
_ATTACH(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
_ATTACH(Z2_MIN_PIN);
#endif
#if HAS_Z3_MAX
_ATTACH(Z3_MAX_PIN);
#endif
#if HAS_Z3_MIN
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif
} }

View file

@ -28,7 +28,5 @@
#define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION) #define HAL_ADC_RANGE _BV(HAL_ADC_RESOLUTION)
inline void watchdog_refresh() { inline void watchdog_refresh() {
#if ENABLED(USE_WATCHDOG) TERN_(USE_WATCHDOG, HAL_watchdog_refresh());
HAL_watchdog_refresh();
#endif
} }

View file

@ -211,11 +211,7 @@ void HardFault_HandlerC(unsigned long *sp, unsigned long lr, unsigned long cause
// Nothing below here is compiled because NVIC_SystemReset loops forever // Nothing below here is compiled because NVIC_SystemReset loops forever
for (;;) { for (;;) { TERN_(USE_WATCHDOG, watchdog_init()); }
#if ENABLED(USE_WATCHDOG)
watchdog_init();
#endif
}
} }
extern "C" { extern "C" {

View file

@ -70,9 +70,7 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
void flashFirmware(const int16_t) { NVIC_SystemReset(); } void flashFirmware(const int16_t) { NVIC_SystemReset(); }
void HAL_clear_reset_source(void) { void HAL_clear_reset_source(void) {
#if ENABLED(USE_WATCHDOG) TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
watchdog_clear_timeout_flag();
#endif
} }
uint8_t HAL_get_reset_source(void) { uint8_t HAL_get_reset_source(void) {

View file

@ -46,8 +46,7 @@ public:
#if ENABLED(EMERGENCY_PARSER) #if ENABLED(EMERGENCY_PARSER)
, emergency_state(EmergencyParser::State::EP_RESET) , emergency_state(EmergencyParser::State::EP_RESET)
#endif #endif
{ { }
}
void end() {} void end() {}

View file

@ -60,9 +60,7 @@ class libServo: public Servo {
if (attach(servo_info[servoIndex].Pin.nbr) >= 0) { // try to reattach if (attach(servo_info[servoIndex].Pin.nbr) >= 0) { // try to reattach
write(value); write(value);
safe_delay(servo_delay[servoIndex]); // delay to allow servo to reach position safe_delay(servo_delay[servoIndex]); // delay to allow servo to reach position
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }

View file

@ -29,71 +29,19 @@
// Local defines // Local defines
// ------------------------ // ------------------------
#if HAS_TEMP_ADC_0 #define GET_TEMP_0_ADC() TERN(HAS_TEMP_ADC_0, PIN_TO_ADC(TEMP_0_PIN), -1)
#define GET_TEMP_0_ADC() PIN_TO_ADC(TEMP_0_PIN) #define GET_TEMP_1_ADC() TERN(HAS_TEMP_ADC_1, PIN_TO_ADC(TEMP_1_PIN), -1)
#else #define GET_TEMP_2_ADC() TERN(HAS_TEMP_ADC_2, PIN_TO_ADC(TEMP_2_PIN), -1)
#define GET_TEMP_0_ADC() -1 #define GET_TEMP_3_ADC() TERN(HAS_TEMP_ADC_3, PIN_TO_ADC(TEMP_3_PIN), -1)
#endif #define GET_TEMP_4_ADC() TERN(HAS_TEMP_ADC_4, PIN_TO_ADC(TEMP_4_PIN), -1)
#if HAS_TEMP_ADC_1 #define GET_TEMP_5_ADC() TERN(HAS_TEMP_ADC_5, PIN_TO_ADC(TEMP_5_PIN), -1)
#define GET_TEMP_1_ADC() PIN_TO_ADC(TEMP_1_PIN) #define GET_TEMP_6_ADC() TERN(HAS_TEMP_ADC_6, PIN_TO_ADC(TEMP_6_PIN), -1)
#else #define GET_TEMP_7_ADC() TERN(HAS_TEMP_ADC_7, PIN_TO_ADC(TEMP_7_PIN), -1)
#define GET_TEMP_1_ADC() -1 #define GET_PROBE_ADC() TERN(HAS_TEMP_PROBE, PIN_TO_ADC(TEMP_PROBE_PIN), -1)
#endif #define GET_BED_ADC() TERN(HAS_TEMP_ADC_BED, PIN_TO_ADC(TEMP_BED_PIN), -1)
#if HAS_TEMP_ADC_2 #define GET_CHAMBER_ADC() TERN(HAS_TEMP_ADC_CHAMBER, PIN_TO_ADC(TEMP_CHAMBER_PIN), -1)
#define GET_TEMP_2_ADC() PIN_TO_ADC(TEMP_2_PIN) #define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1)
#else #define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1)
#define GET_TEMP_2_ADC() -1
#endif
#if HAS_TEMP_ADC_3
#define GET_TEMP_3_ADC() PIN_TO_ADC(TEMP_3_PIN)
#else
#define GET_TEMP_3_ADC() -1
#endif
#if HAS_TEMP_ADC_4
#define GET_TEMP_4_ADC() PIN_TO_ADC(TEMP_4_PIN)
#else
#define GET_TEMP_4_ADC() -1
#endif
#if HAS_TEMP_ADC_5
#define GET_TEMP_5_ADC() PIN_TO_ADC(TEMP_5_PIN)
#else
#define GET_TEMP_5_ADC() -1
#endif
#if HAS_TEMP_ADC_6
#define GET_TEMP_6_ADC() PIN_TO_ADC(TEMP_6_PIN)
#else
#define GET_TEMP_6_ADC() -1
#endif
#if HAS_TEMP_ADC_7
#define GET_TEMP_7_ADC() PIN_TO_ADC(TEMP_7_PIN)
#else
#define GET_TEMP_7_ADC() -1
#endif
#if HAS_TEMP_PROBE
#define GET_PROBE_ADC() PIN_TO_ADC(TEMP_PROBE_PIN)
#else
#define GET_PROBE_ADC() -1
#endif
#if HAS_TEMP_ADC_BED
#define GET_BED_ADC() PIN_TO_ADC(TEMP_BED_PIN)
#else
#define GET_BED_ADC() -1
#endif
#if HAS_TEMP_ADC_CHAMBER
#define GET_CHAMBER_ADC() PIN_TO_ADC(TEMP_CHAMBER_PIN)
#else
#define GET_CHAMBER_ADC() -1
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
#define GET_FILAMENT_WIDTH_ADC() PIN_TO_ADC(FILWIDTH_PIN)
#else
#define GET_FILAMENT_WIDTH_ADC() -1
#endif
#if HAS_ADC_BUTTONS
#define GET_BUTTONS_ADC() PIN_TO_ADC(ADC_KEYPAD_PIN)
#else
#define GET_BUTTONS_ADC() -1
#endif
#define IS_ADC_REQUIRED(n) ( \ #define IS_ADC_REQUIRED(n) ( \
GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \ GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
@ -105,21 +53,22 @@
|| GET_BUTTONS_ADC() == n \ || GET_BUTTONS_ADC() == n \
) )
#define ADC0_IS_REQUIRED IS_ADC_REQUIRED(0) #if IS_ADC_REQUIRED(0)
#define ADC1_IS_REQUIRED IS_ADC_REQUIRED(1) #define ADC0_IS_REQUIRED 1
#define ADC_IS_REQUIRED (ADC0_IS_REQUIRED || ADC1_IS_REQUIRED)
#if ADC0_IS_REQUIRED
#define FIRST_ADC 0 #define FIRST_ADC 0
#else #else
#define FIRST_ADC 1 #define FIRST_ADC 1
#endif #endif
#if ADC1_IS_REQUIRED #if IS_ADC_REQUIRED(1)
#define ADC1_IS_REQUIRED 1
#define LAST_ADC 1 #define LAST_ADC 1
#else #else
#define LAST_ADC 0 #define LAST_ADC 0
#endif #endif
#if ADC0_IS_REQUIRED || ADC1_IS_REQUIRED
#define DMA_IS_REQUIRED ADC_IS_REQUIRED #define ADC_IS_REQUIRED 1
#define DMA_IS_REQUIRED 1
#endif
// ------------------------ // ------------------------
// Types // Types
@ -423,9 +372,7 @@ uint16_t HAL_adc_result;
// HAL initialization task // HAL initialization task
void HAL_init() { void HAL_init() {
#if DMA_IS_REQUIRED TERN_(DMA_IS_REQUIRED, dma_init());
dma_init();
#endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT) #if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
SET_INPUT_PULLUP(SD_DETECT_PIN); SET_INPUT_PULLUP(SD_DETECT_PIN);

View file

@ -76,20 +76,18 @@ void HAL_init() {
#endif #endif
#if ENABLED(SRAM_EEPROM_EMULATION) #if ENABLED(SRAM_EEPROM_EMULATION)
// Enable access to backup SRAM
__HAL_RCC_PWR_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess(); HAL_PWR_EnableBkUpAccess(); // Enable access to backup SRAM
__HAL_RCC_BKPSRAM_CLK_ENABLE(); __HAL_RCC_BKPSRAM_CLK_ENABLE();
LL_PWR_EnableBkUpRegulator(); // Enable backup regulator
// Enable backup regulator while (!LL_PWR_IsActiveFlag_BRR()); // Wait until backup regulator is initialized
LL_PWR_EnableBkUpRegulator();
// Wait until backup regulator is initialized
while (!LL_PWR_IsActiveFlag_BRR());
#endif #endif
#if HAS_TMC_SW_SERIAL #if HAS_TMC_SW_SERIAL
SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0); SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
#endif #endif
TERN_(HAS_TMC_SW_SERIAL, SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0));
} }
void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); } void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }

View file

@ -148,7 +148,7 @@
__HAL_RCC_SDIO_CLK_ENABLE(); // turn on SDIO clock __HAL_RCC_SDIO_CLK_ENABLE(); // turn on SDIO clock
} }
constexpr uint8_t SD_RETRY_COUNT = 1 + 2 * ENABLED(SD_CHECK_AND_RETRY); constexpr uint8_t SD_RETRY_COUNT = TERN(SD_CHECK_AND_RETRY, 3, 1);
bool SDIO_Init() { bool SDIO_Init() {
//init SDIO and get SD card info //init SDIO and get SD card info

View file

@ -52,9 +52,7 @@ void libServo::move(const int value) {
if (attach(0) >= 0) { if (attach(0) >= 0) {
write(value); write(value);
safe_delay(delay); safe_delay(delay);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }
#endif // HAS_SERVOS #endif // HAS_SERVOS

View file

@ -28,43 +28,22 @@
void endstop_ISR() { endstops.update(); } void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#if HAS_X_MAX #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
#endif TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
#if HAS_X_MIN TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
#endif TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
#if HAS_Y_MAX TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
#endif TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
#if HAS_Y_MIN TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
#endif TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
#if HAS_Z_MAX TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
#endif TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
#if HAS_Z_MIN TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
#endif TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
#if HAS_Z2_MAX
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z2_MIN
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MAX
attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MIN
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MAX
attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MIN
attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
#endif
} }

View file

@ -138,9 +138,7 @@ void libServo::move(const int32_t value) {
angle = constrain(value, minAngle, maxAngle); angle = constrain(value, minAngle, maxAngle);
servoWrite(pin, US_TO_COMPARE(ANGLE_TO_US(angle))); servoWrite(pin, US_TO_COMPARE(ANGLE_TO_US(angle)));
safe_delay(servo_delay[servoIndex]); safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }

View file

@ -53,43 +53,22 @@
void endstop_ISR() { endstops.update(); } void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#if HAS_X_MAX #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); // assign it TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
#endif TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
#if HAS_X_MIN TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
#endif TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
#if HAS_Y_MAX TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
#endif TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
#if HAS_Y_MIN TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
#endif TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
#if HAS_Z_MAX TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
#endif TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
#if HAS_Z_MIN TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
#endif TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
#if HAS_Z2_MAX
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z2_MIN
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MAX
attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MIN
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MAX
attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MIN
attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
#endif
} }

View file

@ -44,9 +44,7 @@ void libServo::move(const int value) {
if (attach(0) >= 0) { if (attach(0) >= 0) {
write(value); write(value);
safe_delay(servo_delay[servoIndex]); safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }

View file

@ -28,43 +28,22 @@
void endstop_ISR() { endstops.update(); } void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#if HAS_X_MAX #define _ATTACH(P) attachInterrupt(P, endstop_ISR, CHANGE)
attachInterrupt(X_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
#endif TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
#if HAS_X_MIN TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
attachInterrupt(X_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
#endif TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
#if HAS_Y_MAX TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
attachInterrupt(Y_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
#endif TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
#if HAS_Y_MIN TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
attachInterrupt(Y_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
#endif TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
#if HAS_Z_MAX TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
attachInterrupt(Z_MAX_PIN, endstop_ISR, CHANGE); TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
#endif TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
#if HAS_Z_MIN TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
attachInterrupt(Z_MIN_PIN, endstop_ISR, CHANGE); TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
#endif TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
#if HAS_Z2_MAX
attachInterrupt(Z2_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z2_MIN
attachInterrupt(Z2_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MAX
attachInterrupt(Z3_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z3_MIN
attachInterrupt(Z3_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MAX
attachInterrupt(Z4_MAX_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z4_MIN
attachInterrupt(Z4_MIN_PIN, endstop_ISR, CHANGE);
#endif
#if HAS_Z_MIN_PROBE_PIN
attachInterrupt(Z_MIN_PROBE_PIN, endstop_ISR, CHANGE);
#endif
} }

View file

@ -46,9 +46,7 @@ void libServo::move(const int value) {
if (attach(0) >= 0) { if (attach(0) >= 0) {
write(value); write(value);
safe_delay(servo_delay[servoIndex]); safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }

View file

@ -47,31 +47,21 @@ void endstop_ISR() { endstops.update(); }
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
#if HAS_X_MAX TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
_ATTACH(X_MAX_PIN); TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
#endif TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
#if HAS_X_MIN TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
_ATTACH(X_MIN_PIN); TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
#endif TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
#if HAS_Y_MAX TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
_ATTACH(Y_MAX_PIN); TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
#endif TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
#if HAS_Y_MIN TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
_ATTACH(Y_MIN_PIN); TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
#endif TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
#if HAS_Z_MAX TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
_ATTACH(Z_MAX_PIN); TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
#endif TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
#if HAS_Z_MIN TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
_ATTACH(Z_MIN_PIN); TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
#endif
#if HAS_Z2_MAX
_ATTACH(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
_ATTACH(Z2_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif
} }

View file

@ -46,9 +46,7 @@ void libServo::move(const int value) {
if (attach(0) >= 0) { if (attach(0) >= 0) {
write(value); write(value);
safe_delay(servo_delay[servoIndex]); safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }

View file

@ -46,43 +46,21 @@ void endstop_ISR() { endstops.update(); }
*/ */
void setup_endstop_interrupts() { void setup_endstop_interrupts() {
#define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE) #define _ATTACH(P) attachInterrupt(digitalPinToInterrupt(P), endstop_ISR, CHANGE)
#if HAS_X_MAX TERN_(HAS_X_MAX, _ATTACH(X_MAX_PIN));
_ATTACH(X_MAX_PIN); TERN_(HAS_X_MIN, _ATTACH(X_MIN_PIN));
#endif TERN_(HAS_Y_MAX, _ATTACH(Y_MAX_PIN));
#if HAS_X_MIN TERN_(HAS_Y_MIN, _ATTACH(Y_MIN_PIN));
_ATTACH(X_MIN_PIN); TERN_(HAS_Z_MAX, _ATTACH(Z_MAX_PIN));
#endif TERN_(HAS_Z_MIN, _ATTACH(Z_MIN_PIN));
#if HAS_Y_MAX TERN_(HAS_X2_MAX, _ATTACH(X2_MAX_PIN));
_ATTACH(Y_MAX_PIN); TERN_(HAS_X2_MIN, _ATTACH(X2_MIN_PIN));
#endif TERN_(HAS_Y2_MAX, _ATTACH(Y2_MAX_PIN));
#if HAS_Y_MIN TERN_(HAS_Y2_MIN, _ATTACH(Y2_MIN_PIN));
_ATTACH(Y_MIN_PIN); TERN_(HAS_Z2_MAX, _ATTACH(Z2_MAX_PIN));
#endif TERN_(HAS_Z2_MIN, _ATTACH(Z2_MIN_PIN));
#if HAS_Z_MAX TERN_(HAS_Z3_MAX, _ATTACH(Z3_MAX_PIN));
_ATTACH(Z_MAX_PIN); TERN_(HAS_Z3_MIN, _ATTACH(Z3_MIN_PIN));
#endif TERN_(HAS_Z4_MAX, _ATTACH(Z4_MAX_PIN));
#if HAS_Z_MIN TERN_(HAS_Z4_MIN, _ATTACH(Z4_MIN_PIN));
_ATTACH(Z_MIN_PIN); TERN_(HAS_Z_MIN_PROBE_PIN, _ATTACH(Z_MIN_PROBE_PIN));
#endif
#if HAS_Z2_MAX
_ATTACH(Z2_MAX_PIN);
#endif
#if HAS_Z2_MIN
_ATTACH(Z2_MIN_PIN);
#endif
#if HAS_Z3_MAX
_ATTACH(Z3_MAX_PIN);
#endif
#if HAS_Z3_MIN
_ATTACH(Z3_MIN_PIN);
#endif
#if HAS_Z4_MAX
_ATTACH(Z4_MAX_PIN);
#endif
#if HAS_Z4_MIN
_ATTACH(Z4_MIN_PIN);
#endif
#if HAS_Z_MIN_PROBE_PIN
_ATTACH(Z_MIN_PROBE_PIN);
#endif
} }

View file

@ -150,9 +150,7 @@ void Servo::move(const int value) {
if (attach(0) >= 0) { if (attach(0) >= 0) {
write(value); write(value);
safe_delay(servo_delay[servoIndex]); safe_delay(servo_delay[servoIndex]);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) TERN_(DEACTIVATE_SERVOS_AFTER_MOVE, detach());
detach();
#endif
} }
} }

View file

@ -313,9 +313,7 @@ void enable_e_steppers() {
} }
void enable_all_steppers() { void enable_all_steppers() {
#if ENABLED(AUTO_POWER_CONTROL) TERN_(AUTO_POWER_CONTROL, powerManager.power_on());
powerManager.power_on();
#endif
ENABLE_AXIS_X(); ENABLE_AXIS_X();
ENABLE_AXIS_Y(); ENABLE_AXIS_Y();
ENABLE_AXIS_Z(); ENABLE_AXIS_Z();
@ -359,9 +357,7 @@ void disable_all_steppers() {
} }
void event_probe_recover() { void event_probe_recover() {
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR));
host_prompt_do(PROMPT_INFO, PSTR("G29 Retrying"), DISMISS_STR);
#endif
#ifdef ACTION_ON_G29_RECOVER #ifdef ACTION_ON_G29_RECOVER
host_action(PSTR(ACTION_ON_G29_RECOVER)); host_action(PSTR(ACTION_ON_G29_RECOVER));
#endif #endif
@ -394,12 +390,8 @@ bool printingIsPaused() {
void startOrResumeJob() { void startOrResumeJob() {
if (!printingIsPaused()) { if (!printingIsPaused()) {
#if ENABLED(CANCEL_OBJECTS) TERN_(CANCEL_OBJECTS, cancelable.reset());
cancelable.reset(); TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0);
#endif
#if ENABLED(LCD_SHOW_E_TOTAL)
e_move_accumulator = 0;
#endif
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
ui.reset_remaining_time(); ui.reset_remaining_time();
#endif #endif
@ -410,11 +402,7 @@ void startOrResumeJob() {
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
inline void abortSDPrinting() { inline void abortSDPrinting() {
card.endFilePrint( card.endFilePrint(TERN_(SD_RESORT, true));
#if SD_RESORT
true
#endif
);
queue.clear(); queue.clear();
quickstop_stepper(); quickstop_stepper();
print_job_timer.stop(); print_job_timer.stop();
@ -427,9 +415,7 @@ void startOrResumeJob() {
cutter.kill(); // Full cutter shutdown including ISR control cutter.kill(); // Full cutter shutdown including ISR control
#endif #endif
wait_for_heatup = false; wait_for_heatup = false;
#if ENABLED(POWER_LOSS_RECOVERY) TERN_(POWER_LOSS_RECOVERY, recovery.purge());
recovery.purge();
#endif
#ifdef EVENT_GCODE_SD_STOP #ifdef EVENT_GCODE_SD_STOP
queue.inject_P(PSTR(EVENT_GCODE_SD_STOP)); queue.inject_P(PSTR(EVENT_GCODE_SD_STOP));
#endif #endif
@ -534,13 +520,9 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
} }
#endif #endif
#if ENABLED(USE_CONTROLLER_FAN) TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
controllerFan.update(); // Check if fan should be turned on to cool stepper drivers down
#endif
#if ENABLED(AUTO_POWER_CONTROL) TERN_(AUTO_POWER_CONTROL, powerManager.check());
powerManager.check();
#endif
#if ENABLED(EXTRUDER_RUNOUT_PREVENT) #if ENABLED(EXTRUDER_RUNOUT_PREVENT)
if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP
@ -608,17 +590,11 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
} }
#endif #endif
#if ENABLED(TEMP_STAT_LEDS) TERN_(TEMP_STAT_LEDS, handle_status_leds());
handle_status_leds();
#endif
#if ENABLED(MONITOR_DRIVER_STATUS) TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers());
monitor_tmc_drivers();
#endif
#if ENABLED(MONITOR_L6470_DRIVER_STATUS) TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver());
L64xxManager.monitor_driver();
#endif
// Limit check_axes_activity frequency to 10Hz // Limit check_axes_activity frequency to 10Hz
static millis_t next_check_axes_ms = 0; static millis_t next_check_axes_ms = 0;
@ -669,17 +645,13 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
thermalManager.manage_heater(); thermalManager.manage_heater();
// Max7219 heartbeat, animation, etc // Max7219 heartbeat, animation, etc
#if ENABLED(MAX7219_DEBUG) TERN_(MAX7219_DEBUG, max7219.idle_tasks());
max7219.idle_tasks();
#endif
// Return if setup() isn't completed // Return if setup() isn't completed
if (marlin_state == MF_INITIALIZING) return; if (marlin_state == MF_INITIALIZING) return;
// Handle filament runout sensors // Handle filament runout sensors
#if HAS_FILAMENT_SENSOR TERN_(HAS_FILAMENT_SENSOR, runout.run());
runout.run();
#endif
// Run HAL idle tasks // Run HAL idle tasks
#ifdef HAL_IDLETASK #ifdef HAL_IDLETASK
@ -700,29 +672,19 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
#endif #endif
// Handle SD Card insert / remove // Handle SD Card insert / remove
#if ENABLED(SDSUPPORT) TERN_(SDSUPPORT, card.manage_media());
card.manage_media();
#endif
// Handle USB Flash Drive insert / remove // Handle USB Flash Drive insert / remove
#if ENABLED(USB_FLASH_DRIVE_SUPPORT) TERN_(USB_FLASH_DRIVE_SUPPORT, Sd2Card::idle());
Sd2Card::idle();
#endif
// Announce Host Keepalive state (if any) // Announce Host Keepalive state (if any)
#if ENABLED(HOST_KEEPALIVE_FEATURE) TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive());
gcode.host_keepalive();
#endif
// Update the Print Job Timer state // Update the Print Job Timer state
#if ENABLED(PRINTCOUNTER) TERN_(PRINTCOUNTER, print_job_timer.tick());
print_job_timer.tick();
#endif
// Update the Beeper queue // Update the Beeper queue
#if USE_BEEPER TERN_(USE_BEEPER, buzzer.tick());
buzzer.tick();
#endif
// Read Buttons and Update the LCD // Read Buttons and Update the LCD
ui.update(); ui.update();
@ -742,24 +704,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
// Auto-report Temperatures / SD Status // Auto-report Temperatures / SD Status
#if HAS_AUTO_REPORTING #if HAS_AUTO_REPORTING
if (!gcode.autoreport_paused) { if (!gcode.autoreport_paused) {
#if ENABLED(AUTO_REPORT_TEMPERATURES) TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_report_temperatures());
thermalManager.auto_report_temperatures(); TERN_(AUTO_REPORT_SD_STATUS, card.auto_report_sd_status());
#endif
#if ENABLED(AUTO_REPORT_SD_STATUS)
card.auto_report_sd_status();
#endif
} }
#endif #endif
// Update the Prusa MMU2 // Update the Prusa MMU2
#if ENABLED(PRUSA_MMU2) TERN_(PRUSA_MMU2, mmu2.mmu_loop());
mmu2.mmu_loop();
#endif
// Handle Joystick jogging // Handle Joystick jogging
#if ENABLED(POLL_JOG) TERN_(POLL_JOG, joystick.inject_jog_moves());
joystick.inject_jog_moves();
#endif
} }
/** /**
@ -769,9 +723,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) { void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
thermalManager.disable_all_heaters(); thermalManager.disable_all_heaters();
#if HAS_CUTTER TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
cutter.kill(); // Full cutter shutdown including ISR control
#endif
SERIAL_ERROR_MSG(STR_ERR_KILLED); SERIAL_ERROR_MSG(STR_ERR_KILLED);
@ -802,20 +754,14 @@ void minkill(const bool steppers_off/*=false*/) {
// Reiterate heaters off // Reiterate heaters off
thermalManager.disable_all_heaters(); thermalManager.disable_all_heaters();
#if HAS_CUTTER TERN_(HAS_CUTTER, cutter.kill()); // Reiterate cutter shutdown
cutter.kill(); // Reiterate cutter shutdown
#endif
// Power off all steppers (for M112) or just the E steppers // Power off all steppers (for M112) or just the E steppers
steppers_off ? disable_all_steppers() : disable_e_steppers(); steppers_off ? disable_all_steppers() : disable_e_steppers();
#if ENABLED(PSU_CONTROL) TERN_(PSU_CONTROL, PSU_OFF());
PSU_OFF();
#endif
#if HAS_SUICIDE TERN_(HAS_SUICIDE, suicide());
suicide();
#endif
#if HAS_KILL #if HAS_KILL
@ -1016,9 +962,7 @@ void setup() {
SETUP_RUN(touch.init()); SETUP_RUN(touch.init());
#endif #endif
#if HAS_M206_COMMAND TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset
current_position += home_offset; // Init current position based on home_offset
#endif
sync_plan_position(); // Vital to init stepper/planner equivalent for current_position sync_plan_position(); // Vital to init stepper/planner equivalent for current_position

View file

@ -86,6 +86,10 @@
|| AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \ || AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \
|| AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) ) || AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) )
//
// Trinamic Stepper Drivers
//
// Test for supported TMC drivers that require advanced configuration // Test for supported TMC drivers that require advanced configuration
// Does not match standalone configurations // Does not match standalone configurations
#if ( HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \ #if ( HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) \
@ -171,8 +175,9 @@
#define HAS_TMC_SPI 1 #define HAS_TMC_SPI 1
#endif #endif
// Defines that can't be evaluated now //
#define HAS_TMC_SW_SERIAL ANY_AXIS_HAS(SW_SERIAL) // L64XX Stepper Drivers
//
#if HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01) #if HAS_DRIVER(L6470) || HAS_DRIVER(L6474) || HAS_DRIVER(L6480) || HAS_DRIVER(POWERSTEP01)
#define HAS_L64XX 1 #define HAS_L64XX 1

View file

@ -57,21 +57,21 @@ void safe_delay(millis_t ms) {
void log_machine_info() { void log_machine_info() {
SERIAL_ECHOLNPGM("Machine Type: " SERIAL_ECHOLNPGM("Machine Type: "
TERN(DELTA, "Delta", "") TERN_(DELTA, "Delta")
TERN(IS_SCARA, "SCARA", "") TERN_(IS_SCARA, "SCARA")
TERN(IS_CORE, "Core", "") TERN_(IS_CORE, "Core")
TERN(IS_CARTESIAN, "Cartesian", "") TERN_(IS_CARTESIAN, "Cartesian")
); );
SERIAL_ECHOLNPGM("Probe: " SERIAL_ECHOLNPGM("Probe: "
TERN(PROBE_MANUALLY, "PROBE_MANUALLY", "") TERN_(PROBE_MANUALLY, "PROBE_MANUALLY")
TERN(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE", "") TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE")
TERN(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE", "") TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE")
TERN(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"), "") TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"))
TERN(TOUCH_MI_PROBE, "TOUCH_MI_PROBE", "") TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE")
TERN(Z_PROBE_SLED, "Z_PROBE_SLED", "") TERN_(Z_PROBE_SLED, "Z_PROBE_SLED")
TERN(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY", "") TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY")
TERN(SOLENOID_PROBE, "SOLENOID_PROBE", "") TERN_(SOLENOID_PROBE, "SOLENOID_PROBE")
TERN(PROBE_SELECTED, "", "NONE") TERN(PROBE_SELECTED, "", "NONE")
); );
@ -108,10 +108,10 @@ void safe_delay(millis_t ms) {
#if HAS_ABL_OR_UBL #if HAS_ABL_OR_UBL
SERIAL_ECHOPGM("Auto Bed Leveling: " SERIAL_ECHOPGM("Auto Bed Leveling: "
TERN(AUTO_BED_LEVELING_LINEAR, "LINEAR", "") TERN_(AUTO_BED_LEVELING_LINEAR, "LINEAR")
TERN(AUTO_BED_LEVELING_BILINEAR, "BILINEAR", "") TERN_(AUTO_BED_LEVELING_BILINEAR, "BILINEAR")
TERN(AUTO_BED_LEVELING_3POINT, "3POINT", "") TERN_(AUTO_BED_LEVELING_3POINT, "3POINT")
TERN(AUTO_BED_LEVELING_UBL, "UBL", "") TERN_(AUTO_BED_LEVELING_UBL, "UBL")
); );
if (planner.leveling_active) { if (planner.leveling_active) {

View file

@ -58,9 +58,7 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return; if (DISABLED(BABYSTEP_WITHOUT_HOMING) && !TEST(axis_known_position, axis)) return;
accum += distance; // Count up babysteps for the UI accum += distance; // Count up babysteps for the UI
#if ENABLED(BABYSTEP_DISPLAY_TOTAL) TERN_(BABYSTEP_DISPLAY_TOTAL, axis_total[BS_TOTAL_IND(axis)] += distance);
axis_total[BS_TOTAL_IND(axis)] += distance;
#endif
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE) #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
#define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: ENABLE_AXIS_X(); break; case Y_AXIS: ENABLE_AXIS_Y(); break; case Z_AXIS: ENABLE_AXIS_Z(); break; default: break; } }while(0) #define BSA_ENABLE(AXIS) do{ switch (AXIS) { case X_AXIS: ENABLE_AXIS_X(); break; case Y_AXIS: ENABLE_AXIS_Y(); break; case Z_AXIS: ENABLE_AXIS_Z(); break; default: break; } }while(0)
@ -107,13 +105,10 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
#endif #endif
steps[BS_AXIS_IND(axis)] += distance; steps[BS_AXIS_IND(axis)] += distance;
#endif #endif
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
gcode.reset_stepper_timeout();
#endif
#if ENABLED(INTEGRATED_BABYSTEPPING) TERN_(BABYSTEP_ALWAYS_AVAILABLE, gcode.reset_stepper_timeout());
if (has_steps()) stepper.initiateBabystepping();
#endif TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping());
} }
#endif // BABYSTEPPING #endif // BABYSTEPPING

View file

@ -55,11 +55,8 @@ public:
#if ENABLED(BABYSTEP_DISPLAY_TOTAL) #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
static int16_t axis_total[BS_TOTAL_IND(Z_AXIS) + 1]; // Total babysteps since G28 static int16_t axis_total[BS_TOTAL_IND(Z_AXIS) + 1]; // Total babysteps since G28
static inline void reset_total(const AxisEnum axis) { static inline void reset_total(const AxisEnum axis) {
if (true if (TERN1(BABYSTEP_XY, axis == Z_AXIS))
#if ENABLED(BABYSTEP_XY) axis_total[BS_TOTAL_IND(axis)] = 0;
&& axis == Z_AXIS
#endif
) axis_total[BS_TOTAL_IND(axis)] = 0;
} }
#endif #endif

View file

@ -55,26 +55,16 @@ public:
static inline float get_measurement(const AxisEnum a) { static inline float get_measurement(const AxisEnum a) {
// Return the measurement averaged over all readings // Return the measurement averaged over all readings
return ( return TERN(MEASURE_BACKLASH_WHEN_PROBING
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) , measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0
measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : , 0
#endif
0
); );
#if DISABLED(MEASURE_BACKLASH_WHEN_PROBING) TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
UNUSED(a);
#endif
} }
static inline bool has_measurement(const AxisEnum a) { static inline bool has_measurement(const AxisEnum a) {
return (false return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING) TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
|| (measured_count[a] > 0)
#endif
);
#if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
UNUSED(a);
#endif
} }
static inline bool has_any_measurement() { static inline bool has_any_measurement() {

View file

@ -74,9 +74,7 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t
// Take the average instead of the median // Take the average instead of the median
z_values[x][y] = (a + b + c) / 3.0; z_values[x][y] = (a + b + c) / 3.0;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
// Median is robust (ignores outliers). // Median is robust (ignores outliers).
// z_values[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c) // z_values[x][y] = (a < b) ? ((b < c) ? b : (c < a) ? a : c)
@ -241,9 +239,7 @@ void print_bilinear_leveling_grid() {
// Refresh after other values have been updated // Refresh after other values have been updated
void refresh_bed_level() { void refresh_bed_level() {
bilinear_grid_factor = bilinear_grid_spacing.reciprocal(); bilinear_grid_factor = bilinear_grid_spacing.reciprocal();
#if ENABLED(ABL_BILINEAR_SUBDIVISION) TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
bed_level_virt_interpolate();
#endif
} }
#if ENABLED(ABL_BILINEAR_SUBDIVISION) #if ENABLED(ABL_BILINEAR_SUBDIVISION)

View file

@ -145,9 +145,7 @@ void reset_bed_level() {
bilinear_grid_spacing.reset(); bilinear_grid_spacing.reset();
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
z_values[x][y] = NAN; z_values[x][y] = NAN;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, 0));
ExtUI::onMeshUpdate(x, y, 0);
#endif
} }
#elif ABL_PLANAR #elif ABL_PLANAR
planner.bed_level_matrix.set_to_identity(); planner.bed_level_matrix.set_to_identity();
@ -245,9 +243,7 @@ void reset_bed_level() {
current_position = pos; current_position = pos;
#if ENABLED(LCD_BED_LEVELING) TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
ui.wait_for_move = false;
#endif
} }
#endif #endif

View file

@ -113,9 +113,7 @@
void unified_bed_leveling::set_all_mesh_points_to_value(const float value) { void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
z_values[x][y] = value; z_values[x][y] = value;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, value));
ExtUI::onMeshUpdate(x, y, value);
#endif
} }
} }

View file

@ -305,17 +305,13 @@
const int8_t p_val = parser.intval('P', -1); const int8_t p_val = parser.intval('P', -1);
const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J'); const bool may_move = p_val == 1 || p_val == 2 || p_val == 4 || parser.seen('J');
#if HOTENDS > 1 TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder);
const uint8_t old_tool_index = active_extruder;
#endif
// Check for commands that require the printer to be homed // Check for commands that require the printer to be homed
if (may_move) { if (may_move) {
planner.synchronize(); planner.synchronize();
if (axes_need_homing()) gcode.home_all_axes(); if (axes_need_homing()) gcode.home_all_axes();
#if HOTENDS > 1 TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
if (active_extruder != 0) tool_change(0);
#endif
} }
// Invalidate Mesh Points. This command is a little bit asymmetrical because // Invalidate Mesh Points. This command is a little bit asymmetrical because
@ -340,9 +336,7 @@
break; // No more invalid Mesh Points to populate break; // No more invalid Mesh Points to populate
} }
z_values[cpos.x][cpos.y] = NAN; z_values[cpos.x][cpos.y] = NAN;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, 0.0f));
ExtUI::onMeshUpdate(cpos, 0.0f);
#endif
cnt++; cnt++;
} }
} }
@ -369,9 +363,7 @@
const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x, const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
p2 = 0.5f * (GRID_MAX_POINTS_Y) - y; p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
z_values[x][y] += 2.0f * HYPOT(p1, p2); z_values[x][y] += 2.0f * HYPOT(p1, p2);
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
} }
break; break;
@ -392,9 +384,7 @@
for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in for (uint8_t x = (GRID_MAX_POINTS_X) / 3; x < 2 * (GRID_MAX_POINTS_X) / 3; x++) // Create a rectangular raised area in
for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) { // the center of the bed for (uint8_t y = (GRID_MAX_POINTS_Y) / 3; y < 2 * (GRID_MAX_POINTS_Y) / 3; y++) { // the center of the bed
z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f; z_values[x][y] += parser.seen('C') ? g29_constant : 9.99f;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
} }
break; break;
} }
@ -540,9 +530,7 @@
} }
else { else {
z_values[cpos.x][cpos.y] = g29_constant; z_values[cpos.x][cpos.y] = g29_constant;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, g29_constant));
ExtUI::onMeshUpdate(cpos, g29_constant);
#endif
} }
} }
} }
@ -683,9 +671,7 @@
UNUSED(probe_deployed); UNUSED(probe_deployed);
#endif #endif
#if HOTENDS > 1 TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
tool_change(old_tool_index);
#endif
return; return;
} }
@ -718,9 +704,7 @@
GRID_LOOP(x, y) GRID_LOOP(x, y)
if (!isnan(z_values[x][y])) { if (!isnan(z_values[x][y])) {
z_values[x][y] -= mean + value; z_values[x][y] -= mean + value;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
} }
} }
@ -728,9 +712,7 @@
GRID_LOOP(x, y) GRID_LOOP(x, y)
if (!isnan(z_values[x][y])) { if (!isnan(z_values[x][y])) {
z_values[x][y] += g29_constant; z_values[x][y] += g29_constant;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
} }
} }
@ -742,9 +724,7 @@
void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) { void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) {
probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.capture());
ui.capture();
#endif
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
uint8_t count = GRID_MAX_POINTS; uint8_t count = GRID_MAX_POINTS;
@ -755,9 +735,7 @@
const int point_num = (GRID_MAX_POINTS) - count + 1; const int point_num = (GRID_MAX_POINTS) - count + 1;
SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n"); SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n");
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS));
#endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
if (ui.button_pressed()) { if (ui.button_pressed()) {
@ -776,9 +754,7 @@
: find_closest_mesh_point_of_type(INVALID, near, true); : find_closest_mesh_point_of_type(INVALID, near, true);
if (best.pos.x >= 0) { // mesh point found and is reachable by probe if (best.pos.x >= 0) { // mesh point found and is reachable by probe
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START));
ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START);
#endif
const float measured_z = probe.probe_at_point( const float measured_z = probe.probe_at_point(
best.meshpos(), best.meshpos(),
stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level
@ -793,13 +769,10 @@
} while (best.pos.x >= 0 && --count); } while (best.pos.x >= 0 && --count);
#if HAS_LCD_MENU // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
ui.release(); TERN_(HAS_LCD_MENU, ui.release());
#endif probe.stow();
probe.stow(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW TERN_(HAS_LCD_MENU, ui.capture());
#if HAS_LCD_MENU
ui.capture();
#endif
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
probe.move_z_after_probing(); probe.move_z_after_probing();
@ -858,9 +831,7 @@
static void echo_and_take_a_measurement() { SERIAL_ECHOLNPGM(" and take a measurement."); } static void echo_and_take_a_measurement() { SERIAL_ECHOLNPGM(" and take a measurement."); }
float unified_bed_leveling::measure_business_card_thickness(float in_height) { float unified_bed_leveling::measure_business_card_thickness(float in_height) {
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.capture());
ui.capture();
#endif
save_ubl_active_state_and_disable(); // Disable bed level correction for probing save_ubl_active_state_and_disable(); // Disable bed level correction for probing
do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height); do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), in_height);
@ -899,9 +870,7 @@
} }
void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) { void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.capture());
ui.capture();
#endif
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
do_blocking_move_to_xy_z(current_position, z_clearance); do_blocking_move_to_xy_z(current_position, z_clearance);
@ -929,9 +898,7 @@
do_blocking_move_to_z(z_clearance); do_blocking_move_to_z(z_clearance);
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.capture());
ui.capture();
#endif
if (do_ubl_mesh_map) display_map(g29_map_type); // show user where we're probing if (do_ubl_mesh_map) display_map(g29_map_type); // show user where we're probing
@ -950,9 +917,7 @@
} }
z_values[lpos.x][lpos.y] = current_position.z - thick; z_values[lpos.x][lpos.y] = current_position.z - thick;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, z_values[lpos.x][lpos.y]));
ExtUI::onMeshUpdate(location, z_values[lpos.x][lpos.y]);
#endif
if (g29_verbose_level > 2) if (g29_verbose_level > 2)
SERIAL_ECHOLNPAIR_F("Mesh Point Measured at: ", z_values[lpos.x][lpos.y], 6); SERIAL_ECHOLNPAIR_F("Mesh Point Measured at: ", z_values[lpos.x][lpos.y], 6);
@ -998,14 +963,11 @@
save_ubl_active_state_and_disable(); save_ubl_active_state_and_disable();
LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH); LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.capture()); // Take over control of the LCD encoder
ui.capture(); // Take over control of the LCD encoder
#endif
do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
#if ENABLED(UBL_MESH_EDIT_MOVES_Z) TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset)); // Move Z to the given 'H' offset
do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset
#endif
MeshFlags done_flags{0}; MeshFlags done_flags{0};
const xy_int8_t &lpos = location.pos; const xy_int8_t &lpos = location.pos;
@ -1026,9 +988,7 @@
do_blocking_move_to(raw); // Move the nozzle to the edit point with probe clearance do_blocking_move_to(raw); // Move the nozzle to the edit point with probe clearance
#if ENABLED(UBL_MESH_EDIT_MOVES_Z) TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset)); // Move Z to the given 'H' offset before editing
do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset before editing
#endif
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
@ -1044,9 +1004,7 @@
do { do {
new_z = lcd_mesh_edit(); new_z = lcd_mesh_edit();
#if ENABLED(UBL_MESH_EDIT_MOVES_Z) TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited
do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
#endif
idle(); idle();
SERIAL_FLUSH(); // Prevent host M105 buffer overrun. SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
} while (!ui.button_pressed()); } while (!ui.button_pressed());
@ -1056,9 +1014,7 @@
if (click_and_hold(abort_fine_tune)) break; // Button held down? Abort editing if (click_and_hold(abort_fine_tune)) break; // Button held down? Abort editing
z_values[lpos.x][lpos.y] = new_z; // Save the updated Z value z_values[lpos.x][lpos.y] = new_z; // Save the updated Z value
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, new_z));
ExtUI::onMeshUpdate(location, new_z);
#endif
serial_delay(20); // No switch noise serial_delay(20); // No switch noise
ui.refresh(); ui.refresh();
@ -1086,9 +1042,7 @@
bool unified_bed_leveling::g29_parameter_parsing() { bool unified_bed_leveling::g29_parameter_parsing() {
bool err_flag = false; bool err_flag = false;
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29)));
set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29));
#endif
g29_constant = 0; g29_constant = 0;
g29_repetition_cnt = 0; g29_repetition_cnt = 0;
@ -1210,9 +1164,7 @@
ubl_state_recursion_chk++; ubl_state_recursion_chk++;
if (ubl_state_recursion_chk != 1) { if (ubl_state_recursion_chk != 1) {
SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row."); SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR)));
set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR));
#endif
return; return;
} }
#endif #endif
@ -1224,9 +1176,7 @@
#if ENABLED(UBL_DEVEL_DEBUGGING) #if ENABLED(UBL_DEVEL_DEBUGGING)
if (--ubl_state_recursion_chk) { if (--ubl_state_recursion_chk) {
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times."); SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR)));
set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR));
#endif
return; return;
} }
#endif #endif
@ -1341,9 +1291,7 @@
const float v2 = z_values[dx + xdir][dy + ydir]; const float v2 = z_values[dx + xdir][dy + ydir];
if (!isnan(v2)) { if (!isnan(v2)) {
z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2; z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
return true; return true;
} }
} }
@ -1407,9 +1355,7 @@
if (do_3_pt_leveling) { if (do_3_pt_leveling) {
SERIAL_ECHOLNPGM("Tilting mesh (1/3)"); SERIAL_ECHOLNPGM("Tilting mesh (1/3)");
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif
measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level); measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level);
if (isnan(measured_z)) if (isnan(measured_z))
@ -1428,9 +1374,7 @@
if (!abort_flag) { if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (2/3)"); SERIAL_ECHOLNPGM("Tilting mesh (2/3)");
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif
measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level); measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level);
#ifdef VALIDATE_MESH_TILT #ifdef VALIDATE_MESH_TILT
@ -1450,9 +1394,7 @@
if (!abort_flag) { if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (3/3)"); SERIAL_ECHOLNPGM("Tilting mesh (3/3)");
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif
measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level); measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level);
#ifdef VALIDATE_MESH_TILT #ifdef VALIDATE_MESH_TILT
@ -1495,9 +1437,7 @@
if (!abort_flag) { if (!abort_flag) {
SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n"); SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points);
#endif
measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
@ -1586,9 +1526,7 @@
} }
z_values[i][j] = mz - lsf_results.D; z_values[i][j] = mz - lsf_results.D;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, z_values[i][j]));
ExtUI::onMeshUpdate(i, j, z_values[i][j]);
#endif
} }
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -1684,9 +1622,7 @@
} }
const float ez = -lsf_results.D - lsf_results.A * ppos.x - lsf_results.B * ppos.y; const float ez = -lsf_results.D - lsf_results.A * ppos.x - lsf_results.B * ppos.y;
z_values[ix][iy] = ez; z_values[ix][iy] = ez;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]));
ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
#endif
idle(); // housekeeping idle(); // housekeeping
} }
} }
@ -1826,9 +1762,7 @@
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
z_values[x][y] -= tmp_z_values[x][y]; z_values[x][y] -= tmp_z_values[x][y];
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
} }
} }

View file

@ -82,9 +82,7 @@ private:
} }
transfer_active = true; transfer_active = true;
data_waiting = 0; data_waiting = 0;
#if ENABLED(BINARY_STREAM_COMPRESSION) TERN_(BINARY_STREAM_COMPRESSION, heatshrink_decoder_reset(&hsd));
heatshrink_decoder_reset(&hsd);
#endif
return true; return true;
} }
@ -127,9 +125,7 @@ private:
card.closefile(); card.closefile();
card.release(); card.release();
} }
#if ENABLED(BINARY_STREAM_COMPRESSION) TERN_(BINARY_STREAM_COMPRESSION, heatshrink_decoder_finish(&hsd));
heatshrink_decoder_finish(&hsd);
#endif
transfer_active = false; transfer_active = false;
return true; return true;
} }
@ -139,9 +135,7 @@ private:
card.closefile(); card.closefile();
card.removeFile(card.filename); card.removeFile(card.filename);
card.release(); card.release();
#if ENABLED(BINARY_STREAM_COMPRESSION) TERN_(BINARY_STREAM_COMPRESSION, heatshrink_decoder_finish(&hsd));
heatshrink_decoder_finish(&hsd);
#endif
} }
transfer_active = false; transfer_active = false;
return; return;

View file

@ -124,9 +124,7 @@ bool BLTouch::deploy_proc() {
} }
// One of the recommended ANTClabs ways to probe, using SW MODE // One of the recommended ANTClabs ways to probe, using SW MODE
#if ENABLED(BLTOUCH_FORCE_SW_MODE) TERN_(BLTOUCH_FORCE_SW_MODE, _set_SW_mode());
_set_SW_mode();
#endif
// Now the probe is ready to issue a 10ms pulse when the pin goes up. // Now the probe is ready to issue a 10ms pulse when the pin goes up.
// The trigger STOW (see motion.cpp for example) will pull up the probes pin as soon as the pulse // The trigger STOW (see motion.cpp for example) will pull up the probes pin as soon as the pulse

View file

@ -81,11 +81,8 @@ void ControllerFan::update() {
; ;
// If any of the drivers or the heated bed are enabled... // If any of the drivers or the heated bed are enabled...
if (motor_on if (motor_on || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0))
#if HAS_HEATED_BED lastMotorOn = ms; //... set time to NOW so the fan will turn on
|| thermalManager.temp_bed.soft_pwm_amount > 0
#endif
) lastMotorOn = ms; //... set time to NOW so the fan will turn on
// Fan Settings. Set fan > 0: // Fan Settings. Set fan > 0:
// - If AutoMode is on and steppers have been enabled for CONTROLLERFAN_IDLE_TIME seconds. // - If AutoMode is on and steppers have been enabled for CONTROLLERFAN_IDLE_TIME seconds.

View file

@ -62,11 +62,7 @@ class ControllerFan {
#endif #endif
static inline bool state() { return speed > 0; } static inline bool state() { return speed > 0; }
static inline void init() { reset(); } static inline void init() { reset(); }
static inline void reset() { static inline void reset() { TERN_(CONTROLLER_FAN_EDITABLE, settings = controllerFan_defaults); }
#if ENABLED(CONTROLLER_FAN_EDITABLE)
settings = controllerFan_defaults;
#endif
}
static void setup(); static void setup();
static void update(); static void update();
}; };

View file

@ -459,9 +459,7 @@ void I2CPositionEncoder::reset() {
Wire.write(I2CPE_RESET_COUNT); Wire.write(I2CPE_RESET_COUNT);
Wire.endTransmission(); Wire.endTransmission();
#if ENABLED(I2CPE_ERR_ROLLING_AVERAGE) TERN_(I2CPE_ERR_ROLLING_AVERAGE, ZERO(err));
ZERO(err);
#endif
} }

View file

@ -60,9 +60,7 @@ float FWRetract::current_retract[EXTRUDERS], // Retract value used by p
FWRetract::current_hop; FWRetract::current_hop;
void FWRetract::reset() { void FWRetract::reset() {
#if ENABLED(FWRETRACT_AUTORETRACT) TERN_(FWRETRACT_AUTORETRACT, autoretract_enabled = false);
autoretract_enabled = false;
#endif
settings.retract_length = RETRACT_LENGTH; settings.retract_length = RETRACT_LENGTH;
settings.retract_feedrate_mm_s = RETRACT_FEEDRATE; settings.retract_feedrate_mm_s = RETRACT_FEEDRATE;
settings.retract_zraise = RETRACT_ZRAISE; settings.retract_zraise = RETRACT_ZRAISE;
@ -128,7 +126,7 @@ void FWRetract::retract(const bool retracting
SERIAL_ECHOLNPAIR("current_hop ", current_hop); SERIAL_ECHOLNPAIR("current_hop ", current_hop);
//*/ //*/
const float base_retract = TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1) const float base_retract = TERN1(RETRACT_SYNC_MIXING, (MIXING_STEPPERS))
* (swapping ? settings.swap_retract_length : settings.retract_length); * (swapping ? settings.swap_retract_length : settings.retract_length);
// The current position will be the destination for E and Z moves // The current position will be the destination for E and Z moves
@ -144,7 +142,7 @@ void FWRetract::retract(const bool retracting
// Retract by moving from a faux E position back to the current E position // Retract by moving from a faux E position back to the current E position
current_retract[active_extruder] = base_retract; current_retract[active_extruder] = base_retract;
prepare_internal_move_to_destination( // set current to destination prepare_internal_move_to_destination( // set current to destination
settings.retract_feedrate_mm_s * TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1) settings.retract_feedrate_mm_s * TERN1(RETRACT_SYNC_MIXING, (MIXING_STEPPERS))
); );
// Is a Z hop set, and has the hop not yet been done? // Is a Z hop set, and has the hop not yet been done?
@ -170,9 +168,11 @@ void FWRetract::retract(const bool retracting
current_retract[active_extruder] = 0; current_retract[active_extruder] = 0;
const feedRate_t fr_mm_s = TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1) // Recover E, set_current_to_destination
* (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s); prepare_internal_move_to_destination(
prepare_internal_move_to_destination(fr_mm_s); // Recover E, set_current_to_destination (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s)
* TERN1(RETRACT_SYNC_MIXING, (MIXING_STEPPERS))
);
} }
TERN_(RETRACT_SYNC_MIXING, mixer.T(old_mixing_tool)); // Restore original mixing tool TERN_(RETRACT_SYNC_MIXING, mixer.T(old_mixing_tool)); // Restore original mixing tool

View file

@ -108,11 +108,7 @@ void host_action(const char * const pstr, const bool eol) {
} }
void filament_load_host_prompt() { void filament_load_host_prompt() {
const bool disable_to_continue = (false const bool disable_to_continue = TERN0(HAS_FILAMENT_SENSOR, runout.filament_ran_out);
#if HAS_FILAMENT_SENSOR
|| runout.filament_ran_out
#endif
);
host_prompt_do(PROMPT_FILAMENT_RUNOUT, PSTR("Paused"), PSTR("PurgeMore"), host_prompt_do(PROMPT_FILAMENT_RUNOUT, PSTR("Paused"), PSTR("PurgeMore"),
disable_to_continue ? PSTR("DisableRunout") : CONTINUE_STR disable_to_continue ? PSTR("DisableRunout") : CONTINUE_STR
); );
@ -160,9 +156,7 @@ void host_action(const char * const pstr, const bool eol) {
} }
break; break;
case PROMPT_USER_CONTINUE: case PROMPT_USER_CONTINUE:
#if HAS_RESUME_CONTINUE TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
wait_for_user = false;
#endif
msg = PSTR("FILAMENT_RUNOUT_CONTINUE"); msg = PSTR("FILAMENT_RUNOUT_CONTINUE");
break; break;
case PROMPT_PAUSE_RESUME: case PROMPT_PAUSE_RESUME:

View file

@ -154,9 +154,7 @@ Joystick joystick;
// Other non-joystick poll-based jogging could be implemented here // Other non-joystick poll-based jogging could be implemented here
// with "jogging" encapsulated as a more general class. // with "jogging" encapsulated as a more general class.
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::_joystick_update(norm_jog));
ExtUI::_joystick_update(norm_jog);
#endif
// norm_jog values of [-1 .. 1] maps linearly to [-feedrate .. feedrate] // norm_jog values of [-1 .. 1] maps linearly to [-feedrate .. feedrate]
xyz_float_t move_dist{0}; xyz_float_t move_dist{0};

View file

@ -35,19 +35,11 @@
class Joystick { class Joystick {
friend class Temperature; friend class Temperature;
private: private:
#if HAS_JOY_ADC_X TERN_(HAS_JOY_ADC_X, static temp_info_t x);
static temp_info_t x; TERN_(HAS_JOY_ADC_Y, static temp_info_t y);
#endif TERN_(HAS_JOY_ADC_Z, static temp_info_t z);
#if HAS_JOY_ADC_Y
static temp_info_t y;
#endif
#if HAS_JOY_ADC_Z
static temp_info_t z;
#endif
public: public:
#if ENABLED(JOYSTICK_DEBUG) TERN_(JOYSTICK_DEBUG, static void report());
static void report();
#endif
static void calculate(xyz_float_t &norm_jog); static void calculate(xyz_float_t &norm_jog);
static void inject_jog_moves(); static void inject_jog_moves();
}; };

View file

@ -68,15 +68,9 @@ void LEDLights::setup() {
if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN);
#endif #endif
#endif #endif
#if ENABLED(NEOPIXEL_LED) TERN_(NEOPIXEL_LED, neo.init());
neo.init(); TERN_(PCA9533, PCA9533_init());
#endif TERN_(LED_USER_PRESET_STARTUP, set_default());
#if ENABLED(PCA9533)
PCA9533_init();
#endif
#if ENABLED(LED_USER_PRESET_STARTUP)
set_default();
#endif
} }
void LEDLights::set_color(const LEDColor &incol void LEDLights::set_color(const LEDColor &incol
@ -140,9 +134,7 @@ void LEDLights::set_color(const LEDColor &incol
pca9632_set_led_color(incol); pca9632_set_led_color(incol);
#endif #endif
#if ENABLED(PCA9533) TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b));
PCA9533_setColor(incol.r, incol.g, incol.b);
#endif
#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS) #if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
// Don't update the color when OFF // Don't update the color when OFF

View file

@ -34,7 +34,9 @@
#endif #endif
// A white component can be passed // A white component can be passed
#define HAS_WHITE_LED EITHER(RGBW_LED, NEOPIXEL_LED) #if EITHER(RGBW_LED, NEOPIXEL_LED)
#define HAS_WHITE_LED 1
#endif
/** /**
* LEDcolor type for use with leds.set_color * LEDcolor type for use with leds.set_color
@ -85,9 +87,7 @@ typedef struct LEDColor {
LEDColor& operator=(const uint8_t (&rgbw)[4]) { LEDColor& operator=(const uint8_t (&rgbw)[4]) {
r = rgbw[0]; g = rgbw[1]; b = rgbw[2]; r = rgbw[0]; g = rgbw[1]; b = rgbw[2];
#if HAS_WHITE_LED TERN_(HAS_WHITE_LED, w = rgbw[3]);
w = rgbw[3];
#endif
return *this; return *this;
} }

View file

@ -38,10 +38,15 @@
// Defines // Defines
// ------------------------ // ------------------------
#define MULTIPLE_NEOPIXEL_TYPES (defined(NEOPIXEL2_TYPE) && (NEOPIXEL2_TYPE != NEOPIXEL_TYPE)) #if defined(NEOPIXEL2_TYPE) && NEOPIXEL2_TYPE != NEOPIXEL_TYPE
#define MULTIPLE_NEOPIXEL_TYPES 1
#endif
#define NEOPIXEL_IS_RGB (NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR) #if NEOPIXEL_TYPE == NEO_RGB || NEOPIXEL_TYPE == NEO_RBG || NEOPIXEL_TYPE == NEO_GRB || NEOPIXEL_TYPE == NEO_GBR || NEOPIXEL_TYPE == NEO_BRG || NEOPIXEL_TYPE == NEO_BGR
#define NEOPIXEL_IS_RGBW !NEOPIXEL_IS_RGB #define NEOPIXEL_IS_RGB 1
#else
#define NEOPIXEL_IS_RGBW 1
#endif
#if NEOPIXEL_IS_RGB #if NEOPIXEL_IS_RGB
#define NEO_WHITE 255, 255, 255, 0 #define NEO_WHITE 255, 255, 255, 0
@ -73,23 +78,17 @@ public:
static inline void begin() { static inline void begin() {
adaneo1.begin(); adaneo1.begin();
#if MULTIPLE_NEOPIXEL_TYPES TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin());
adaneo2.begin();
#endif
} }
static inline void set_pixel_color(const uint16_t n, const uint32_t c) { static inline void set_pixel_color(const uint16_t n, const uint32_t c) {
adaneo1.setPixelColor(n, c); adaneo1.setPixelColor(n, c);
#if MULTIPLE_NEOPIXEL_TYPES TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c));
adaneo2.setPixelColor(n, c);
#endif
} }
static inline void set_brightness(const uint8_t b) { static inline void set_brightness(const uint8_t b) {
adaneo1.setBrightness(b); adaneo1.setBrightness(b);
#if MULTIPLE_NEOPIXEL_TYPES TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b));
adaneo2.setBrightness(b);
#endif
} }
static inline void show() { static inline void show() {

View file

@ -36,10 +36,7 @@ void handle_status_leds() {
static millis_t next_status_led_update_ms = 0; static millis_t next_status_led_update_ms = 0;
if (ELAPSED(millis(), next_status_led_update_ms)) { if (ELAPSED(millis(), next_status_led_update_ms)) {
next_status_led_update_ms += 500; // Update every 0.5s next_status_led_update_ms += 500; // Update every 0.5s
float max_temp = 0.0; float max_temp = TERN0(HAS_HEATED_BED, _MAX(thermalManager.degTargetBed(), thermalManager.degBed()));
#if HAS_HEATED_BED
max_temp = _MAX(thermalManager.degTargetBed(), thermalManager.degBed());
#endif
HOTEND_LOOP() HOTEND_LOOP()
max_temp = _MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e)); max_temp = _MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red; const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red;

View file

@ -44,7 +44,7 @@ int_fast8_t Mixer::runner = 0;
mixer_comp_t Mixer::s_color[MIXING_STEPPERS]; mixer_comp_t Mixer::s_color[MIXING_STEPPERS];
mixer_accu_t Mixer::accu[MIXING_STEPPERS] = { 0 }; mixer_accu_t Mixer::accu[MIXING_STEPPERS] = { 0 };
#if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX) #if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
mixer_perc_t Mixer::mix[MIXING_STEPPERS]; mixer_perc_t Mixer::mix[MIXING_STEPPERS];
#endif #endif
@ -90,9 +90,7 @@ void Mixer::normalize(const uint8_t tool_index) {
SERIAL_ECHOLNPGM("]"); SERIAL_ECHOLNPGM("]");
#endif #endif
#if ENABLED(GRADIENT_MIX) TERN_(GRADIENT_MIX, refresh_gradient());
refresh_gradient();
#endif
} }
void Mixer::reset_vtools() { void Mixer::reset_vtools() {
@ -123,13 +121,11 @@ void Mixer::init() {
ZERO(collector); ZERO(collector);
#if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX) #if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
update_mix_from_vtool(); update_mix_from_vtool();
#endif #endif
#if ENABLED(GRADIENT_MIX) TERN_(GRADIENT_MIX, update_gradient_for_planner_z());
update_gradient_for_planner_z();
#endif
} }
void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=selected_vtool*/, float (&c)[MIXING_STEPPERS]/*=collector*/) { void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=selected_vtool*/, float (&c)[MIXING_STEPPERS]/*=collector*/) {

View file

@ -25,7 +25,7 @@
//#define MIXER_NORMALIZER_DEBUG //#define MIXER_NORMALIZER_DEBUG
#ifndef __AVR__ // || DUAL_MIXING_EXTRUDER #ifndef __AVR__ // || HAS_DUAL_MIXING
// Use 16-bit (or fastest) data for the integer mix factors // Use 16-bit (or fastest) data for the integer mix factors
typedef uint_fast16_t mixer_comp_t; typedef uint_fast16_t mixer_comp_t;
typedef uint_fast16_t mixer_accu_t; typedef uint_fast16_t mixer_accu_t;
@ -48,14 +48,14 @@ typedef int8_t mixer_perc_t;
#endif #endif
enum MixTool { enum MixTool {
FIRST_USER_VIRTUAL_TOOL = 0, FIRST_USER_VIRTUAL_TOOL = 0
LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1, , LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1
NR_USER_VIRTUAL_TOOLS, , NR_USER_VIRTUAL_TOOLS
MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS, , MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS
#if HAS_MIXER_SYNC_CHANNEL #if HAS_MIXER_SYNC_CHANNEL
MIXER_AUTORETRACT_TOOL, , MIXER_AUTORETRACT_TOOL
#endif #endif
NR_MIXING_VIRTUAL_TOOLS , NR_MIXING_VIRTUAL_TOOLS
}; };
#define MAX_VTOOLS TERN(HAS_MIXER_SYNC_CHANNEL, 254, 255) #define MAX_VTOOLS TERN(HAS_MIXER_SYNC_CHANNEL, 254, 255)
@ -75,9 +75,7 @@ static_assert(NR_MIXING_VIRTUAL_TOOLS <= MAX_VTOOLS, "MIXING_VIRTUAL_TOOLS must
int8_t start_vtool, end_vtool; // Start and end virtual tools int8_t start_vtool, end_vtool; // Start and end virtual tools
mixer_perc_t start_mix[MIXING_STEPPERS], // Start and end mixes from those tools mixer_perc_t start_mix[MIXING_STEPPERS], // Start and end mixes from those tools
end_mix[MIXING_STEPPERS]; end_mix[MIXING_STEPPERS];
#if ENABLED(GRADIENT_VTOOL) TERN_(GRADIENT_VTOOL, int8_t vtool_index); // Use this virtual tool number as index
int8_t vtool_index; // Use this virtual tool number as index
#endif
} gradient_t; } gradient_t;
#endif #endif
@ -106,12 +104,8 @@ class Mixer {
FORCE_INLINE static void T(const uint_fast8_t c) { FORCE_INLINE static void T(const uint_fast8_t c) {
selected_vtool = c; selected_vtool = c;
#if ENABLED(GRADIENT_VTOOL) TERN_(GRADIENT_VTOOL, refresh_gradient());
refresh_gradient(); TERN_(HAS_DUAL_MIXING, update_mix_from_vtool());
#endif
#if DUAL_MIXING_EXTRUDER
update_mix_from_vtool();
#endif
} }
// Used when dealing with blocks // Used when dealing with blocks
@ -129,7 +123,7 @@ class Mixer {
MIXER_STEPPER_LOOP(i) s_color[i] = b_color[i]; MIXER_STEPPER_LOOP(i) s_color[i] = b_color[i];
} }
#if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX) #if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
static mixer_perc_t mix[MIXING_STEPPERS]; // Scratch array for the Mix in proportion to 100 static mixer_perc_t mix[MIXING_STEPPERS]; // Scratch array for the Mix in proportion to 100
@ -167,21 +161,19 @@ class Mixer {
#endif #endif
} }
#endif // DUAL_MIXING_EXTRUDER || GRADIENT_MIX #endif // HAS_DUAL_MIXING || GRADIENT_MIX
#if DUAL_MIXING_EXTRUDER #if HAS_DUAL_MIXING
// Update the virtual tool from an edited mix // Update the virtual tool from an edited mix
static inline void update_vtool_from_mix() { static inline void update_vtool_from_mix() {
copy_mix_to_color(color[selected_vtool]); copy_mix_to_color(color[selected_vtool]);
#if ENABLED(GRADIENT_MIX) TERN_(GRADIENT_MIX, refresh_gradient());
refresh_gradient();
#endif
// MIXER_STEPPER_LOOP(i) collector[i] = mix[i]; // MIXER_STEPPER_LOOP(i) collector[i] = mix[i];
// normalize(); // normalize();
} }
#endif // DUAL_MIXING_EXTRUDER #endif // HAS_DUAL_MIXING
#if ENABLED(GRADIENT_MIX) #if ENABLED(GRADIENT_MIX)

View file

@ -707,12 +707,8 @@ void MMU2::filament_runout() {
if (recover) { if (recover) {
LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER); LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER);
BUZZ(200, 404); BUZZ(200, 404);
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR));
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("MMU2 Eject Recover"), CONTINUE_STR); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover")));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("MMU2 Eject Recover"));
#endif
wait_for_user_response(); wait_for_user_response();
BUZZ(200, 404); BUZZ(200, 404);
BUZZ(200, 404); BUZZ(200, 404);

View file

@ -86,9 +86,7 @@ fil_change_settings_t fc_settings[EXTRUDERS];
#if HAS_BUZZER #if HAS_BUZZER
static void filament_change_beep(const int8_t max_beep_count, const bool init=false) { static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
#if HAS_LCD_MENU if (TERN0(HAS_LCD_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return;
if (pause_mode == PAUSE_MODE_PAUSE_PRINT) return;
#endif
static millis_t next_buzz = 0; static millis_t next_buzz = 0;
static int8_t runout_beep = 0; static int8_t runout_beep = 0;
@ -184,13 +182,9 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
host_action_prompt_button(CONTINUE_STR); host_action_prompt_button(CONTINUE_STR);
host_action_prompt_show(); host_action_prompt_show();
#endif #endif
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament")));
ExtUI::onUserConfirmRequired_P(PSTR("Load Filament"));
#endif
while (wait_for_user) { while (wait_for_user) {
#if HAS_BUZZER TERN_(HAS_BUZZER, filament_change_beep(max_beep_count));
filament_change_beep(max_beep_count);
#endif
idle_no_sleep(); idle_no_sleep();
} }
} }
@ -235,12 +229,8 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE); if (show_lcd) lcd_pause_show_message(PAUSE_MESSAGE_PURGE);
#endif #endif
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR));
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging...")));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging..."));
#endif
wait_for_user = true; // A click or M108 breaks the purge_length loop wait_for_user = true; // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count) for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE); unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
@ -259,9 +249,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
unscaled_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE); unscaled_e_move(purge_length, ADVANCED_PAUSE_PURGE_FEEDRATE);
} }
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, filament_load_host_prompt()); // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
filament_load_host_prompt(); // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
#endif
#if HAS_LCD_MENU #if HAS_LCD_MENU
if (show_lcd) { if (show_lcd) {
@ -274,11 +262,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
#endif #endif
// Keep looping if "Purge More" was selected // Keep looping if "Purge More" was selected
} while (false } while (TERN0(HAS_LCD_MENU, show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE));
#if HAS_LCD_MENU
|| (show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)
#endif
);
#endif #endif
@ -384,9 +368,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
#endif #endif
#endif #endif
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR));
host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR);
#endif
if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) { if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD); SERIAL_ECHO_MSG(STR_ERR_HOTEND_TOO_COLD);
@ -465,9 +447,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
*/ */
void show_continue_prompt(const bool is_reload) { void show_continue_prompt(const bool is_reload) {
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING));
lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
#endif
SERIAL_ECHO_START(); SERIAL_ECHO_START();
serialprintPGM(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n")); serialprintPGM(is_reload ? PSTR(_PMSG(STR_FILAMENT_CHANGE_INSERT) "\n") : PSTR(_PMSG(STR_FILAMENT_CHANGE_WAIT) "\n"));
} }
@ -497,17 +477,11 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
// Wait for filament insert by user and press button // Wait for filament insert by user and press button
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR));
host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED)));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED));
#endif
wait_for_user = true; // LCD click or M108 will clear this wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user) { while (wait_for_user) {
#if HAS_BUZZER TERN_(HAS_BUZZER, filament_change_beep(max_beep_count));
filament_change_beep(max_beep_count);
#endif
// If the nozzle has timed out... // If the nozzle has timed out...
if (!nozzle_timed_out) if (!nozzle_timed_out)
@ -516,27 +490,18 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
// Wait for the user to press the button to re-heat the nozzle, then // Wait for the user to press the button to re-heat the nozzle, then
// re-heat the nozzle, re-show the continue prompt, restart idle timers, start over // re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
if (nozzle_timed_out) { if (nozzle_timed_out) {
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_HEAT));
lcd_pause_show_message(PAUSE_MESSAGE_HEAT);
#endif
SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_HEAT)); SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_HEAT));
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT)));
host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT));
#endif
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT)));
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT));
#endif
wait_for_user_response(0, true); // Wait for LCD click or M108 wait_for_user_response(0, true); // Wait for LCD click or M108
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING)));
host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING));
#endif TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING)));
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING));
#endif
// Re-enable the heaters if they timed out // Re-enable the heaters if they timed out
HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e); HOTEND_LOOP() thermalManager.reset_hotend_idle_timer(e);
@ -551,18 +516,12 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT); const millis_t nozzle_timeout = SEC_TO_MS(PAUSE_PARK_NOZZLE_TIMEOUT);
HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout); HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR));
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished.")));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished."));
#endif
wait_for_user = true; wait_for_user = true;
nozzle_timed_out = false; nozzle_timed_out = false;
#if HAS_BUZZER TERN_(HAS_BUZZER, filament_change_beep(max_beep_count, true));
filament_change_beep(max_beep_count, true);
#endif
} }
idle_no_sleep(); idle_no_sleep();
} }
@ -613,9 +572,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament if (nozzle_timed_out || thermalManager.hotEnoughToExtrude(active_extruder)) // Load the new filament
load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS); load_filament(slow_load_length, fast_load_length, purge_length, max_beep_count, true, nozzle_timed_out, PAUSE_MODE_SAME DXC_PASS);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_RESUME));
lcd_pause_show_message(PAUSE_MESSAGE_RESUME);
#endif
// Intelligent resuming // Intelligent resuming
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
@ -641,9 +598,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
// Set extruder to saved position // Set extruder to saved position
planner.set_e_position_mm((destination.e = current_position.e = resume_position.e)); planner.set_e_position_mm((destination.e = current_position.e = resume_position.e));
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
#endif
#ifdef ACTION_ON_RESUMED #ifdef ACTION_ON_RESUMED
host_action_resumed(); host_action_resumed();
@ -653,9 +608,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
--did_pause_print; --did_pause_print;
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR));
host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR);
#endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (did_pause_print) { if (did_pause_print) {
@ -668,19 +621,13 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le
thermalManager.set_fans_paused(false); thermalManager.set_fans_paused(false);
#endif #endif
#if HAS_FILAMENT_SENSOR TERN_(HAS_FILAMENT_SENSOR, runout.reset());
runout.reset();
#endif
// Resume the print job timer if it was running // Resume the print job timer if it was running
if (print_job_timer.isPaused()) print_job_timer.start(); if (print_job_timer.isPaused()) print_job_timer.start();
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.reset_status());
ui.reset_status(); TERN_(HAS_LCD_MENU, ui.return_to_status());
#if HAS_LCD_MENU
ui.return_to_status();
#endif
#endif
} }
#endif // ADVANCED_PAUSE_FEATURE #endif // ADVANCED_PAUSE_FEATURE

View file

@ -50,15 +50,12 @@ bool Power::is_power_needed() {
if (controllerFan.state()) return true; if (controllerFan.state()) return true;
#endif #endif
#if ENABLED(AUTO_POWER_CHAMBER_FAN) if (TERN0(AUTO_POWER_CHAMBER_FAN, thermalManager.chamberfan_speed))
if (thermalManager.chamberfan_speed) return true; return true;
#endif
// If any of the drivers or the bed are enabled... // If any of the drivers or the bed are enabled...
if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON
#if HAS_HEATED_BED || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)
|| thermalManager.temp_bed.soft_pwm_amount > 0
#endif
#if HAS_X2_ENABLE #if HAS_X2_ENABLE
|| X2_ENABLE_READ() == X_ENABLE_ON || X2_ENABLE_READ() == X_ENABLE_ON
#endif #endif
@ -75,10 +72,7 @@ bool Power::is_power_needed() {
) return true; ) return true;
HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true; HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true;
if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0)) return true;
#if HAS_HEATED_BED
if (thermalManager.degTargetBed() > 0) return true;
#endif
#if HOTENDS && AUTO_POWER_E_TEMP #if HOTENDS && AUTO_POWER_E_TEMP
HOTEND_LOOP() if (thermalManager.degHotend(e) >= AUTO_POWER_E_TEMP) return true; HOTEND_LOOP() if (thermalManager.degHotend(e) >= AUTO_POWER_E_TEMP) return true;

View file

@ -172,12 +172,8 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
// Machine state // Machine state
info.current_position = current_position; info.current_position = current_position;
#if HAS_HOME_OFFSET TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
info.home_offset = home_offset; TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
#endif
#if HAS_POSITION_SHIFT
info.position_shift = position_shift;
#endif
info.feedrate = uint16_t(feedrate_mm_s * 60.0f); info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
@ -197,9 +193,7 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target; HOTEND_LOOP() info.target_temperature[e] = thermalManager.temp_hotend[e].target;
#endif #endif
#if HAS_HEATED_BED TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.temp_bed.target);
info.target_temperature_bed = thermalManager.temp_bed.target;
#endif
#if FAN_COUNT #if FAN_COUNT
COPY(info.fan_speed, thermalManager.fan_speed); COPY(info.fan_speed, thermalManager.fan_speed);
@ -207,18 +201,10 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
#if HAS_LEVELING #if HAS_LEVELING
info.leveling = planner.leveling_active; info.leveling = planner.leveling_active;
info.fade = ( info.fade = TERN0(ENABLE_LEVELING_FADE_HEIGHT, planner.z_fade_height);
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
planner.z_fade_height
#else
0
#endif
);
#endif #endif
#if ENABLED(GRADIENT_MIX) TERN_(GRADIENT_MIX, memcpy(&info.gradient, &mixer.gradient, sizeof(info.gradient)));
memcpy(&info.gradient, &mixer.gradient, sizeof(info.gradient));
#endif
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
COPY(info.retract, fwretract.current_retract); COPY(info.retract, fwretract.current_retract);
@ -244,9 +230,7 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
lock = true; lock = true;
#endif #endif
if (IS_SD_PRINTING()) save(true); if (IS_SD_PRINTING()) save(true);
#if ENABLED(BACKUP_POWER_SUPPLY) TERN_(BACKUP_POWER_SUPPLY, raise_z());
raise_z();
#endif
kill(GET_TEXT(MSG_OUTAGE_RECOVERY)); kill(GET_TEXT(MSG_OUTAGE_RECOVERY));
} }
@ -299,9 +283,7 @@ void PrintJobRecovery::resume() {
// If Z homing goes to max, just reset E and home all // If Z homing goes to max, just reset E and home all
"\n" "\n"
"G28R0" "G28R0"
#if ENABLED(MARLIN_DEV_MODE) TERN_(MARLIN_DEV_MODE, "S")
"S"
#endif
#else // "G92.9 E0 ..." #else // "G92.9 E0 ..."
@ -460,12 +442,8 @@ void PrintJobRecovery::resume() {
// Relative axis modes // Relative axis modes
gcode.axis_relative = info.axis_relative; gcode.axis_relative = info.axis_relative;
#if HAS_HOME_OFFSET TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
home_offset = info.home_offset; TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
#endif
#if HAS_POSITION_SHIFT
position_shift = info.position_shift;
#endif
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT #if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
LOOP_XYZ(i) update_workspace_offset((AxisEnum)i); LOOP_XYZ(i) update_workspace_offset((AxisEnum)i);
#endif #endif

View file

@ -82,9 +82,7 @@ class ProbeTempComp {
static inline void clear_all_offsets() { static inline void clear_all_offsets() {
clear_offsets(TSI_BED); clear_offsets(TSI_BED);
clear_offsets(TSI_PROBE); clear_offsets(TSI_PROBE);
#if ENABLED(USE_TEMP_EXT_COMPENSATION) TERN_(USE_TEMP_EXT_COMPENSATION, clear_offsets(TSI_EXT));
clear_offsets(TSI_EXT);
#endif
} }
static bool set_offset(const TempSensorID tsi, const uint8_t idx, const int16_t offset); static bool set_offset(const TempSensorID tsi, const uint8_t idx, const int16_t offset);
static void print_offsets(); static void print_offsets();

View file

@ -74,13 +74,9 @@ void FilamentSensorBase::filament_present(const uint8_t extruder) {
void event_filament_runout() { void event_filament_runout() {
#if ENABLED(ADVANCED_PAUSE_FEATURE) if (TERN0(ADVANCED_PAUSE_FEATURE, did_pause_print)) return; // Action already in progress. Purge triggered repeated runout.
if (did_pause_print) return; // Action already in progress. Purge triggered repeated runout.
#endif
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getActiveTool()));
ExtUI::onFilamentRunout(ExtUI::getActiveTool());
#endif
#if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS) #if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
const char tool = '0' const char tool = '0'

View file

@ -54,9 +54,7 @@ void SpindleLaser::init() {
#endif #endif
#if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY) #if ENABLED(HAL_CAN_SET_PWM_FREQ) && defined(SPINDLE_LASER_FREQUENCY)
set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY); set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY);
#if ENABLED(MARLIN_DEV_MODE) TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY);
frequency = SPINDLE_LASER_FREQUENCY;
#endif
#endif #endif
} }
@ -99,9 +97,7 @@ void SpindleLaser::apply_power(const cutter_power_t inpow) {
// //
void SpindleLaser::set_direction(const bool reverse) { void SpindleLaser::set_direction(const bool reverse) {
const bool dir_state = (reverse == SPINDLE_INVERT_DIR); // Forward (M3) HIGH when not inverted const bool dir_state = (reverse == SPINDLE_INVERT_DIR); // Forward (M3) HIGH when not inverted
#if ENABLED(SPINDLE_STOP_ON_DIR_CHANGE) if (TERN0(SPINDLE_STOP_ON_DIR_CHANGE, enabled()) && READ(SPINDLE_DIR_PIN) != dir_state) disable();
if (enabled() && READ(SPINDLE_DIR_PIN) != dir_state) disable();
#endif
WRITE(SPINDLE_DIR_PIN, dir_state); WRITE(SPINDLE_DIR_PIN, dir_state);
} }

View file

@ -162,9 +162,7 @@ public:
#endif #endif
static inline void kill() { static inline void kill() {
#if ENABLED(LASER_POWER_INLINE) TERN_(LASER_POWER_INLINE, inline_disable());
inline_disable();
#endif
disable(); disable();
} }
}; };

View file

@ -169,9 +169,7 @@
data.is_stealth = TEST(ds, STEALTH_bp); data.is_stealth = TEST(ds, STEALTH_bp);
data.is_standstill = TEST(ds, STST_bp); data.is_standstill = TEST(ds, STST_bp);
#endif #endif
#if HAS_STALLGUARD TERN_(HAS_STALLGUARD, data.sg_result_reasonable = false);
data.sg_result_reasonable = false;
#endif
#endif #endif
return data; return data;
} }
@ -213,9 +211,7 @@
SERIAL_PRINTLN(data.drv_status, HEX); SERIAL_PRINTLN(data.drv_status, HEX);
if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature"); if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature");
if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit"); if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit");
#if ENABLED(TMC_DEBUG) TERN_(TMC_DEBUG, tmc_report_all(true, true, true, true));
tmc_report_all(true, true, true, true);
#endif
kill(PSTR("Driver error")); kill(PSTR("Driver error"));
} }
#endif #endif
@ -446,9 +442,7 @@
(void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting); (void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting);
#endif #endif
#if ENABLED(TMC_DEBUG) if (TERN0(TMC_DEBUG, need_debug_reporting)) SERIAL_EOL();
if (need_debug_reporting) SERIAL_EOL();
#endif
} }
} }

View file

@ -69,15 +69,9 @@ class TMCStorage {
} }
struct { struct {
#if HAS_STEALTHCHOP TERN_(HAS_STEALTHCHOP, bool stealthChop_enabled = false);
bool stealthChop_enabled = false; TERN_(HYBRID_THRESHOLD, uint8_t hybrid_thrs = 0);
#endif TERN_(USE_SENSORLESS, int16_t homing_thrs = 0);
#if ENABLED(HYBRID_THRESHOLD)
uint8_t hybrid_thrs = 0;
#endif
#if USE_SENSORLESS
int16_t homing_thrs = 0;
#endif
} stored; } stored;
}; };
@ -118,9 +112,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
} }
void set_pwm_thrs(const uint32_t thrs) { void set_pwm_thrs(const uint32_t thrs) {
TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); TMC::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
this->stored.hybrid_thrs = thrs;
#endif
} }
#endif #endif
@ -129,9 +121,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
TMC::sgt(sgt_val); TMC::sgt(sgt_val);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val);
this->stored.homing_thrs = sgt_val;
#endif
} }
#if ENABLED(SPI_ENDSTOPS) #if ENABLED(SPI_ENDSTOPS)
bool test_stall_status(); bool test_stall_status();
@ -184,9 +174,7 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
} }
void set_pwm_thrs(const uint32_t thrs) { void set_pwm_thrs(const uint32_t thrs) {
TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); TMC2208Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
this->stored.hybrid_thrs = thrs;
#endif
} }
#endif #endif
@ -231,9 +219,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
} }
void set_pwm_thrs(const uint32_t thrs) { void set_pwm_thrs(const uint32_t thrs) {
TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID])); TMC2209Stepper::TPWMTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, this->stored.hybrid_thrs = thrs);
this->stored.hybrid_thrs = thrs;
#endif
} }
#endif #endif
#if USE_SENSORLESS #if USE_SENSORLESS
@ -241,9 +227,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
TMC2209Stepper::SGTHRS(sgt_val); TMC2209Stepper::SGTHRS(sgt_val);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val);
this->stored.homing_thrs = sgt_val;
#endif
} }
#endif #endif
@ -283,9 +267,7 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max); sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
TMC2660Stepper::sgt(sgt_val); TMC2660Stepper::sgt(sgt_val);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, this->stored.homing_thrs = sgt_val);
this->stored.homing_thrs = sgt_val;
#endif
} }
#endif #endif
@ -367,9 +349,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
struct slow_homing_t { struct slow_homing_t {
xy_ulong_t acceleration; xy_ulong_t acceleration;
#if HAS_CLASSIC_JERK TERN_(HAS_CLASSIC_JERK, xy_float_t jerk_xy);
xy_float_t jerk_xy;
#endif
}; };
#endif #endif

View file

@ -165,9 +165,7 @@ int8_t g26_prime_flag;
bool user_canceled() { bool user_canceled() {
if (!ui.button_pressed()) return false; // Return if the button isn't pressed if (!ui.button_pressed()) return false; // Return if the button isn't pressed
ui.set_status_P(GET_TEXT(MSG_G26_CANCELED), 99); ui.set_status_P(GET_TEXT(MSG_G26_CANCELED), 99);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.quick_feedback());
ui.quick_feedback();
#endif
ui.wait_for_release(); ui.wait_for_release();
return true; return true;
} }
@ -301,9 +299,7 @@ inline bool look_for_lines_to_connect() {
GRID_LOOP(i, j) { GRID_LOOP(i, j) {
#if HAS_LCD_MENU if (TERN0(HAS_LCD_MENU, user_canceled())) return true;
if (user_canceled()) return true;
#endif
if (i < (GRID_MAX_POINTS_X)) { // Can't connect to anything farther to the right than GRID_MAX_POINTS_X. if (i < (GRID_MAX_POINTS_X)) { // Can't connect to anything farther to the right than GRID_MAX_POINTS_X.
// Already a half circle at the edge of the bed. // Already a half circle at the edge of the bed.
@ -364,9 +360,7 @@ inline bool turn_on_heaters() {
#if HAS_SPI_LCD #if HAS_SPI_LCD
ui.set_status_P(GET_TEXT(MSG_G26_HEATING_BED), 99); ui.set_status_P(GET_TEXT(MSG_G26_HEATING_BED), 99);
ui.quick_feedback(); ui.quick_feedback();
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.capture());
ui.capture();
#endif
#endif #endif
thermalManager.setTargetBed(g26_bed_temp); thermalManager.setTargetBed(g26_bed_temp);
@ -393,8 +387,7 @@ inline bool turn_on_heaters() {
#if G26_CLICK_CAN_CANCEL #if G26_CLICK_CAN_CANCEL
, true , true
#endif #endif
) )) return G26_ERR;
) return G26_ERR;
#if HAS_SPI_LCD #if HAS_SPI_LCD
ui.reset_status(); ui.reset_status();
@ -665,9 +658,7 @@ void GcodeSuite::G26() {
move_to(destination, 0.0); move_to(destination, 0.0);
move_to(destination, g26_ooze_amount); move_to(destination, g26_ooze_amount);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.capture());
ui.capture();
#endif
#if DISABLED(ARC_SUPPORT) #if DISABLED(ARC_SUPPORT)
@ -762,9 +753,7 @@ void GcodeSuite::G26() {
feedrate_mm_s = old_feedrate; feedrate_mm_s = old_feedrate;
destination = current_position; destination = current_position;
#if HAS_LCD_MENU if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation
if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
#endif
#else // !ARC_SUPPORT #else // !ARC_SUPPORT
@ -788,9 +777,7 @@ void GcodeSuite::G26() {
for (int8_t ind = start_ind; ind <= end_ind; ind++) { for (int8_t ind = start_ind; ind <= end_ind; ind++) {
#if HAS_LCD_MENU if (TERN0(HAS_LCD_MENU, user_canceled())) goto LEAVE; // Check if the user wants to stop the Mesh Validation
if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
#endif
xyz_float_t p = { circle.x + _COS(ind ), circle.y + _SIN(ind ), g26_layer_height }, xyz_float_t p = { circle.x + _COS(ind ), circle.y + _SIN(ind ), g26_layer_height },
q = { circle.x + _COS(ind + 1), circle.y + _SIN(ind + 1), g26_layer_height }; q = { circle.x + _COS(ind + 1), circle.y + _SIN(ind + 1), g26_layer_height };
@ -833,14 +820,10 @@ void GcodeSuite::G26() {
planner.calculate_volumetric_multipliers(); planner.calculate_volumetric_multipliers();
#endif #endif
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.release()); // Give back control of the LCD
ui.release(); // Give back control of the LCD
#endif
if (!g26_keep_heaters_on) { if (!g26_keep_heaters_on) {
#if HAS_HEATED_BED TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0));
thermalManager.setTargetBed(0);
#endif
thermalManager.setTargetHotend(active_extruder, 0); thermalManager.setTargetHotend(active_extruder, 0);
} }
} }

View file

@ -73,9 +73,7 @@ void GcodeSuite::M420() {
#endif #endif
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
Z_VALUES(x, y) = 0.001 * random(-200, 200); Z_VALUES(x, y) = 0.001 * random(-200, 200);
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
#endif
} }
SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh "); SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh ");
SERIAL_ECHOPAIR(" (", x_min); SERIAL_ECHOPAIR(" (", x_min);
@ -178,13 +176,9 @@ void GcodeSuite::M420() {
// Subtract the mean from all values // Subtract the mean from all values
GRID_LOOP(x, y) { GRID_LOOP(x, y) {
Z_VALUES(x, y) -= zmean; Z_VALUES(x, y) -= zmean;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
#endif
} }
#if ENABLED(ABL_BILINEAR_SUBDIVISION) TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
bed_level_virt_interpolate();
#endif
} }
#endif #endif
@ -206,9 +200,7 @@ void GcodeSuite::M420() {
if (leveling_is_valid()) { if (leveling_is_valid()) {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
print_bilinear_leveling_grid(); print_bilinear_leveling_grid();
#if ENABLED(ABL_BILINEAR_SUBDIVISION) TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt());
print_bilinear_leveling_grid_virt();
#endif
#elif ENABLED(MESH_BED_LEVELING) #elif ENABLED(MESH_BED_LEVELING)
SERIAL_ECHOLNPGM("Mesh Bed Level data:"); SERIAL_ECHOLNPGM("Mesh Bed Level data:");
mbl.report_mesh(); mbl.report_mesh();

View file

@ -283,9 +283,7 @@ G29_TYPE GcodeSuite::G29() {
*/ */
if (!g29_in_progress) { if (!g29_in_progress) {
#if HAS_MULTI_HOTEND TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
if (active_extruder != 0) tool_change(0);
#endif
#if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR) #if EITHER(PROBE_MANUALLY, AUTO_BED_LEVELING_LINEAR)
abl_probe_index = -1; abl_probe_index = -1;
@ -322,12 +320,8 @@ G29_TYPE GcodeSuite::G29() {
if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) { if (WITHIN(i, 0, GRID_MAX_POINTS_X - 1) && WITHIN(j, 0, GRID_MAX_POINTS_Y)) {
set_bed_leveling_enabled(false); set_bed_leveling_enabled(false);
z_values[i][j] = rz; z_values[i][j] = rz;
#if ENABLED(ABL_BILINEAR_SUBDIVISION) TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
bed_level_virt_interpolate(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(i, j, rz);
#endif
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
if (abl_should_enable) report_current_position(); if (abl_should_enable) report_current_position();
} }
@ -492,14 +486,10 @@ G29_TYPE GcodeSuite::G29() {
// Abort current G29 procedure, go back to idle state // Abort current G29 procedure, go back to idle state
if (seenA && g29_in_progress) { if (seenA && g29_in_progress) {
SERIAL_ECHOLNPGM("Manual G29 aborted"); SERIAL_ECHOLNPGM("Manual G29 aborted");
#if HAS_SOFTWARE_ENDSTOPS TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
soft_endstops_enabled = saved_soft_endstops_state;
#endif
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
g29_in_progress = false; g29_in_progress = false;
#if ENABLED(LCD_BED_LEVELING) TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
ui.wait_for_move = false;
#endif
} }
// Query G29 status // Query G29 status
@ -517,9 +507,7 @@ G29_TYPE GcodeSuite::G29() {
if (abl_probe_index == 0) { if (abl_probe_index == 0) {
// For the initial G29 S2 save software endstop state // For the initial G29 S2 save software endstop state
#if HAS_SOFTWARE_ENDSTOPS TERN_(HAS_SOFTWARE_ENDSTOPS, saved_soft_endstops_state = soft_endstops_enabled);
saved_soft_endstops_state = soft_endstops_enabled;
#endif
// Move close to the bed before the first point // Move close to the bed before the first point
do_blocking_move_to_z(0); do_blocking_move_to_z(0);
} }
@ -551,9 +539,7 @@ G29_TYPE GcodeSuite::G29() {
const float newz = measured_z + zoffset; const float newz = measured_z + zoffset;
z_values[meshCount.x][meshCount.y] = newz; z_values[meshCount.x][meshCount.y] = newz;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, newz));
ExtUI::onMeshUpdate(meshCount, newz);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_P(PSTR("Save X"), meshCount.x, SP_Y_STR, meshCount.y, SP_Z_STR, measured_z + zoffset); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_P(PSTR("Save X"), meshCount.x, SP_Y_STR, meshCount.y, SP_Z_STR, measured_z + zoffset);
@ -580,9 +566,7 @@ G29_TYPE GcodeSuite::G29() {
probePos = probe_position_lf + gridSpacing * meshCount.asFloat(); probePos = probe_position_lf + gridSpacing * meshCount.asFloat();
#if ENABLED(AUTO_BED_LEVELING_LINEAR) TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = abl_probe_index);
indexIntoAB[meshCount.x][meshCount.y] = abl_probe_index;
#endif
// Keep looping till a reachable point is found // Keep looping till a reachable point is found
if (position_is_reachable(probePos)) break; if (position_is_reachable(probePos)) break;
@ -606,9 +590,7 @@ G29_TYPE GcodeSuite::G29() {
SERIAL_ECHOLNPGM("Grid probing done."); SERIAL_ECHOLNPGM("Grid probing done.");
// Re-enable software endstops, if needed // Re-enable software endstops, if needed
#if HAS_SOFTWARE_ENDSTOPS TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
soft_endstops_enabled = saved_soft_endstops_state;
#endif
} }
#elif ENABLED(AUTO_BED_LEVELING_3POINT) #elif ENABLED(AUTO_BED_LEVELING_3POINT)
@ -629,9 +611,7 @@ G29_TYPE GcodeSuite::G29() {
SERIAL_ECHOLNPGM("3-point probing done."); SERIAL_ECHOLNPGM("3-point probing done.");
// Re-enable software endstops, if needed // Re-enable software endstops, if needed
#if HAS_SOFTWARE_ENDSTOPS TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
soft_endstops_enabled = saved_soft_endstops_state;
#endif
if (!dryrun) { if (!dryrun) {
vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal(); vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal();
@ -688,9 +668,7 @@ G29_TYPE GcodeSuite::G29() {
probePos = probe_position_lf + gridSpacing * meshCount.asFloat(); probePos = probe_position_lf + gridSpacing * meshCount.asFloat();
#if ENABLED(AUTO_BED_LEVELING_LINEAR) TERN_(AUTO_BED_LEVELING_LINEAR, indexIntoAB[meshCount.x][meshCount.y] = ++abl_probe_index); // 0...
indexIntoAB[meshCount.x][meshCount.y] = ++abl_probe_index; // 0...
#endif
#if IS_KINEMATIC #if IS_KINEMATIC
// Avoid probing outside the round or hexagonal area // Avoid probing outside the round or hexagonal area
@ -698,9 +676,7 @@ G29_TYPE GcodeSuite::G29() {
#endif #endif
if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), "."); if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), ".");
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS)));
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS));
#endif
measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level); measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);
@ -712,9 +688,7 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(PROBE_TEMP_COMPENSATION) #if ENABLED(PROBE_TEMP_COMPENSATION)
temp_comp.compensate_measurement(TSI_BED, thermalManager.degBed(), measured_z); temp_comp.compensate_measurement(TSI_BED, thermalManager.degBed(), measured_z);
temp_comp.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), measured_z); temp_comp.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), measured_z);
#if ENABLED(USE_TEMP_EXT_COMPENSATION) TERN_(USE_TEMP_EXT_COMPENSATION, temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(), measured_z));
temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(), measured_z);
#endif
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_LINEAR) #if ENABLED(AUTO_BED_LEVELING_LINEAR)
@ -730,9 +704,7 @@ G29_TYPE GcodeSuite::G29() {
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
z_values[meshCount.x][meshCount.y] = measured_z + zoffset; z_values[meshCount.x][meshCount.y] = measured_z + zoffset;
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(meshCount, z_values[meshCount.x][meshCount.y]));
ExtUI::onMeshUpdate(meshCount, z_values[meshCount.x][meshCount.y]);
#endif
#endif #endif
@ -748,9 +720,7 @@ G29_TYPE GcodeSuite::G29() {
LOOP_L_N(i, 3) { LOOP_L_N(i, 3) {
if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", int(i), "/3."); if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", int(i), "/3.");
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i)));
ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i));
#endif
// Retain the last probe position // Retain the last probe position
probePos = points[i]; probePos = points[i];
@ -773,9 +743,7 @@ G29_TYPE GcodeSuite::G29() {
#endif // AUTO_BED_LEVELING_3POINT #endif // AUTO_BED_LEVELING_3POINT
#if HAS_DISPLAY TERN_(HAS_DISPLAY, ui.reset_status());
ui.reset_status();
#endif
// Stow the probe. No raise for FIX_MOUNTED_PROBE. // Stow the probe. No raise for FIX_MOUNTED_PROBE.
if (probe.stow()) { if (probe.stow()) {
@ -799,9 +767,7 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
g29_in_progress = false; g29_in_progress = false;
#if ENABLED(LCD_BED_LEVELING) TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
ui.wait_for_move = false;
#endif
#endif #endif
// Calculate leveling, print reports, correct the position // Calculate leveling, print reports, correct the position
@ -813,9 +779,7 @@ G29_TYPE GcodeSuite::G29() {
refresh_bed_level(); refresh_bed_level();
#if ENABLED(ABL_BILINEAR_SUBDIVISION) TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt());
print_bilinear_leveling_grid_virt();
#endif
#elif ENABLED(AUTO_BED_LEVELING_LINEAR) #elif ENABLED(AUTO_BED_LEVELING_LINEAR)

View file

@ -55,12 +55,8 @@ void GcodeSuite::M421() {
SERIAL_ERROR_MSG(STR_ERR_MESH_XY); SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
else { else {
z_values[ix][iy] = parser.value_linear_units() + (hasQ ? z_values[ix][iy] : 0); z_values[ix][iy] = parser.value_linear_units() + (hasQ ? z_values[ix][iy] : 0);
#if ENABLED(ABL_BILINEAR_SUBDIVISION) TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
bed_level_virt_interpolate(); TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
#endif
} }
} }

View file

@ -62,9 +62,7 @@ inline void echo_not_entered(const char c) { SERIAL_CHAR(c); SERIAL_ECHOLNPGM("
void GcodeSuite::G29() { void GcodeSuite::G29() {
static int mbl_probe_index = -1; static int mbl_probe_index = -1;
#if HAS_SOFTWARE_ENDSTOPS TERN_(HAS_SOFTWARE_ENDSTOPS, static bool saved_soft_endstops_state);
static bool saved_soft_endstops_state;
#endif
MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport); MeshLevelingState state = (MeshLevelingState)parser.byteval('S', (int8_t)MeshReport);
if (!WITHIN(state, 0, 5)) { if (!WITHIN(state, 0, 5)) {
@ -111,9 +109,7 @@ void GcodeSuite::G29() {
else { else {
// Save Z for the previous mesh position // Save Z for the previous mesh position
mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z); mbl.set_zigzag_z(mbl_probe_index - 1, current_position.z);
#if HAS_SOFTWARE_ENDSTOPS TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = saved_soft_endstops_state);
soft_endstops_enabled = saved_soft_endstops_state;
#endif
} }
// If there's another point to sample, move there with optional lift. // If there's another point to sample, move there with optional lift.
if (mbl_probe_index < GRID_MAX_POINTS) { if (mbl_probe_index < GRID_MAX_POINTS) {
@ -147,9 +143,7 @@ void GcodeSuite::G29() {
planner.synchronize(); planner.synchronize();
#endif #endif
#if ENABLED(LCD_BED_LEVELING) TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
ui.wait_for_move = false;
#endif
} }
break; break;
@ -178,9 +172,7 @@ void GcodeSuite::G29() {
if (parser.seenval('Z')) { if (parser.seenval('Z')) {
mbl.z_values[ix][iy] = parser.value_linear_units(); mbl.z_values[ix][iy] = parser.value_linear_units();
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy]));
ExtUI::onMeshUpdate(ix, iy, mbl.z_values[ix][iy]);
#endif
} }
else else
return echo_not_entered('Z'); return echo_not_entered('Z');

View file

@ -63,9 +63,7 @@ void GcodeSuite::M421() {
else { else {
float &zval = ubl.z_values[ij.x][ij.y]; float &zval = ubl.z_values[ij.x][ij.y];
zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0); zval = hasN ? NAN : parser.value_linear_units() + (hasQ ? zval : 0);
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ij.x, ij.y, zval));
ExtUI::onMeshUpdate(ij.x, ij.y, zval);
#endif
} }
} }

View file

@ -126,22 +126,16 @@
*/ */
destination.set(safe_homing_xy, current_position.z); destination.set(safe_homing_xy, current_position.z);
#if HOMING_Z_WITH_PROBE TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy);
destination -= probe.offset_xy;
#endif
if (position_is_reachable(destination)) { if (position_is_reachable(destination)) {
if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination); if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination);
// This causes the carriage on Dual X to unpark // This causes the carriage on Dual X to unpark
#if ENABLED(DUAL_X_CARRIAGE) TERN_(DUAL_X_CARRIAGE, active_extruder_parked = false);
active_extruder_parked = false;
#endif
#if ENABLED(SENSORLESS_HOMING) TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle
safe_delay(500); // Short delay needed to settle
#endif
do_blocking_move_to_xy(destination); do_blocking_move_to_xy(destination);
homeaxis(Z_AXIS); homeaxis(Z_AXIS);
@ -175,9 +169,7 @@
void end_slow_homing(const slow_homing_t &slow_homing) { void end_slow_homing(const slow_homing_t &slow_homing) {
planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x; planner.settings.max_acceleration_mm_per_s2[X_AXIS] = slow_homing.acceleration.x;
planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y; planner.settings.max_acceleration_mm_per_s2[Y_AXIS] = slow_homing.acceleration.y;
#if HAS_CLASSIC_JERK TERN_(HAS_CLASSIC_JERK, planner.max_jerk = slow_homing.jerk_xy);
planner.max_jerk = slow_homing.jerk_xy;
#endif
planner.reset_acceleration_rates(); planner.reset_acceleration_rates();
} }
@ -237,22 +229,18 @@ void GcodeSuite::G28() {
#if HAS_LEVELING #if HAS_LEVELING
// Cancel the active G29 session // Cancel the active G29 session
#if ENABLED(PROBE_MANUALLY) TERN_(PROBE_MANUALLY, g29_in_progress = false);
g29_in_progress = false;
#endif
#if ENABLED(RESTORE_LEVELING_AFTER_G28) TERN_(RESTORE_LEVELING_AFTER_G28, const bool leveling_was_active = planner.leveling_active);
const bool leveling_was_active = planner.leveling_active;
#endif
set_bed_leveling_enabled(false); set_bed_leveling_enabled(false);
#endif #endif
#if ENABLED(CNC_WORKSPACE_PLANES) TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
workspace_plane = PLANE_XY;
#endif
#define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
#define HAS_HOMING_CURRENT (HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2)) #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2)
#define HAS_HOMING_CURRENT 1
#endif
#if HAS_HOMING_CURRENT #if HAS_HOMING_CURRENT
auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b){ auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b){
@ -280,9 +268,7 @@ void GcodeSuite::G28() {
#endif #endif
#endif #endif
#if ENABLED(IMPROVE_HOMING_RELIABILITY) TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing_t slow_homing = begin_slow_homing());
slow_homing_t slow_homing = begin_slow_homing();
#endif
// Always home with tool 0 active // Always home with tool 0 active
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
@ -292,9 +278,7 @@ void GcodeSuite::G28() {
tool_change(0, true); tool_change(0, true);
#endif #endif
#if HAS_DUPLICATION_MODE TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
extruder_duplication_enabled = false;
#endif
remember_feedrate_scaling_off(); remember_feedrate_scaling_off();
@ -306,9 +290,7 @@ void GcodeSuite::G28() {
home_delta(); home_delta();
#if ENABLED(IMPROVE_HOMING_RELIABILITY) TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
end_slow_homing(slow_homing);
#endif
#else // NOT DELTA #else // NOT DELTA
@ -380,17 +362,13 @@ void GcodeSuite::G28() {
if (DISABLED(HOME_Y_BEFORE_X) && doY) if (DISABLED(HOME_Y_BEFORE_X) && doY)
homeaxis(Y_AXIS); homeaxis(Y_AXIS);
#if ENABLED(IMPROVE_HOMING_RELIABILITY) TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
end_slow_homing(slow_homing);
#endif
// Home Z last if homing towards the bed // Home Z last if homing towards the bed
#if Z_HOME_DIR < 0 #if Z_HOME_DIR < 0
if (doZ) { if (doZ) {
#if ENABLED(BLTOUCH) TERN_(BLTOUCH, bltouch.init());
bltouch.init();
#endif
#if ENABLED(Z_SAFE_HOMING) #if ENABLED(Z_SAFE_HOMING)
home_z_safely(); home_z_safely();
#else #else
@ -425,9 +403,7 @@ void GcodeSuite::G28() {
if (dxc_is_duplicating()) { if (dxc_is_duplicating()) {
#if ENABLED(IMPROVE_HOMING_RELIABILITY) TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing());
slow_homing = begin_slow_homing();
#endif
// Always home the 2nd (right) extruder first // Always home the 2nd (right) extruder first
active_extruder = 1; active_extruder = 1;
@ -448,9 +424,7 @@ void GcodeSuite::G28() {
dual_x_carriage_mode = IDEX_saved_mode; dual_x_carriage_mode = IDEX_saved_mode;
stepper.set_directions(); stepper.set_directions();
#if ENABLED(IMPROVE_HOMING_RELIABILITY) TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
end_slow_homing(slow_homing);
#endif
} }
#endif // DUAL_X_CARRIAGE #endif // DUAL_X_CARRIAGE
@ -458,18 +432,14 @@ void GcodeSuite::G28() {
endstops.not_homing(); endstops.not_homing();
// Clear endstop state for polled stallGuard endstops // Clear endstop state for polled stallGuard endstops
#if ENABLED(SPI_ENDSTOPS) TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());
endstops.clear_endstop_state();
#endif
#if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE) #if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
// move to a height where we can use the full xy-area // move to a height where we can use the full xy-area
do_blocking_move_to_z(delta_clip_start_height); do_blocking_move_to_z(delta_clip_start_height);
#endif #endif
#if ENABLED(RESTORE_LEVELING_AFTER_G28) TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active));
set_bed_leveling_enabled(leveling_was_active);
#endif
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();

View file

@ -63,12 +63,7 @@ enum CalEnum : char { // the 7 main calibration points -
#define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP) #define LOOP_CAL_RAD(VAR) LOOP_CAL_PT(VAR, __A, _7P_STEP)
#define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP) #define LOOP_CAL_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP)
#if HOTENDS > 1 TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder);
const uint8_t old_tool_index = active_extruder;
#define AC_CLEANUP() ac_cleanup(old_tool_index)
#else
#define AC_CLEANUP() ac_cleanup()
#endif
float lcd_probe_pt(const xy_pos_t &xy); float lcd_probe_pt(const xy_pos_t &xy);
@ -79,9 +74,7 @@ void ac_home() {
} }
void ac_setup(const bool reset_bed) { void ac_setup(const bool reset_bed) {
#if HOTENDS > 1 TERN_(HAS_MULTI_HOTEND, tool_change(0, true));
tool_change(0, true);
#endif
planner.synchronize(); planner.synchronize();
remember_feedrate_scaling_off(); remember_feedrate_scaling_off();
@ -91,21 +84,11 @@ void ac_setup(const bool reset_bed) {
#endif #endif
} }
void ac_cleanup( void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) {
#if HOTENDS > 1 TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));
const uint8_t old_tool_index TERN_(HAS_BED_PROBE, probe.stow());
#endif
) {
#if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
do_blocking_move_to_z(delta_clip_start_height);
#endif
#if HAS_BED_PROBE
probe.stow();
#endif
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();
#if HOTENDS > 1 TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, true));
tool_change(old_tool_index, true);
#endif
} }
void print_signed_float(PGM_P const prefix, const float &f) { void print_signed_float(PGM_P const prefix, const float &f) {
@ -488,7 +471,7 @@ void GcodeSuite::G33() {
zero_std_dev_old = zero_std_dev; zero_std_dev_old = zero_std_dev;
if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each)) { if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each)) {
SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666"); SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666");
return AC_CLEANUP(); return ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
} }
zero_std_dev = std_dev_points(z_at_pt, _0p_calibration, _1p_calibration, _4p_calibration, _4p_opposite_points); zero_std_dev = std_dev_points(z_at_pt, _0p_calibration, _1p_calibration, _4p_calibration, _4p_opposite_points);
@ -659,7 +642,7 @@ void GcodeSuite::G33() {
} }
while (((zero_std_dev < test_precision && iterations < 31) || iterations <= force_iterations) && zero_std_dev > calibration_precision); while (((zero_std_dev < test_precision && iterations < 31) || iterations <= force_iterations) && zero_std_dev > calibration_precision);
AC_CLEANUP(); ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
} }
#endif // DELTA_AUTO_CALIBRATION #endif // DELTA_AUTO_CALIBRATION

View file

@ -113,15 +113,11 @@ void GcodeSuite::G34() {
// Disable the leveling matrix before auto-aligning // Disable the leveling matrix before auto-aligning
#if HAS_LEVELING #if HAS_LEVELING
#if ENABLED(RESTORE_LEVELING_AFTER_G34) TERN_(RESTORE_LEVELING_AFTER_G34, const bool leveling_was_active = planner.leveling_active);
const bool leveling_was_active = planner.leveling_active;
#endif
set_bed_leveling_enabled(false); set_bed_leveling_enabled(false);
#endif #endif
#if ENABLED(CNC_WORKSPACE_PLANES) TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
workspace_plane = PLANE_XY;
#endif
// Always home with tool 0 active // Always home with tool 0 active
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND
@ -129,18 +125,12 @@ void GcodeSuite::G34() {
tool_change(0, true); tool_change(0, true);
#endif #endif
#if HAS_DUPLICATION_MODE TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
extruder_duplication_enabled = false;
#endif
#if BOTH(BLTOUCH, BLTOUCH_HS_MODE)
// In BLTOUCH HS mode, the probe travels in a deployed state. // In BLTOUCH HS mode, the probe travels in a deployed state.
// Users of G34 might have a badly misaligned bed, so raise Z by the // Users of G34 might have a badly misaligned bed, so raise Z by the
// length of the deployed pin (BLTOUCH stroke < 7mm) // length of the deployed pin (BLTOUCH stroke < 7mm)
#define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f #define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)
#else
#define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES
#endif
// Compute a worst-case clearance height to probe from. After the first // Compute a worst-case clearance height to probe from. After the first
// iteration this will be re-calculated based on the actual bed position // iteration this will be re-calculated based on the actual bed position
@ -386,9 +376,7 @@ void GcodeSuite::G34() {
#endif #endif
// Restore the active tool after homing // Restore the active tool after homing
#if HAS_MULTI_HOTEND TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER))); // Fetch previous tool for parking extruder
tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous tool for parking extruder
#endif
#if HAS_LEVELING && ENABLED(RESTORE_LEVELING_AFTER_G34) #if HAS_LEVELING && ENABLED(RESTORE_LEVELING_AFTER_G34)
set_bed_leveling_enabled(leveling_was_active); set_bed_leveling_enabled(leveling_was_active);

View file

@ -285,37 +285,19 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
probe_side(m, uncertainty, TOP); probe_side(m, uncertainty, TOP);
#endif #endif
#if ENABLED(CALIBRATION_MEASURE_RIGHT) TERN_(CALIBRATION_MEASURE_RIGHT, probe_side(m, uncertainty, RIGHT, probe_top_at_edge));
probe_side(m, uncertainty, RIGHT, probe_top_at_edge); TERN_(CALIBRATION_MEASURE_FRONT, probe_side(m, uncertainty, FRONT, probe_top_at_edge));
#endif TERN_(CALIBRATION_MEASURE_LEFT, probe_side(m, uncertainty, LEFT, probe_top_at_edge));
TERN_(CALIBRATION_MEASURE_BACK, probe_side(m, uncertainty, BACK, probe_top_at_edge));
#if ENABLED(CALIBRATION_MEASURE_FRONT)
probe_side(m, uncertainty, FRONT, probe_top_at_edge);
#endif
#if ENABLED(CALIBRATION_MEASURE_LEFT)
probe_side(m, uncertainty, LEFT, probe_top_at_edge);
#endif
#if ENABLED(CALIBRATION_MEASURE_BACK)
probe_side(m, uncertainty, BACK, probe_top_at_edge);
#endif
// Compute the measured center of the calibration object. // Compute the measured center of the calibration object.
#if HAS_X_CENTER TERN_(HAS_X_CENTER, m.obj_center.x = (m.obj_side[LEFT] + m.obj_side[RIGHT]) / 2);
m.obj_center.x = (m.obj_side[LEFT] + m.obj_side[RIGHT]) / 2; TERN_(HAS_Y_CENTER, m.obj_center.y = (m.obj_side[FRONT] + m.obj_side[BACK]) / 2);
#endif
#if HAS_Y_CENTER
m.obj_center.y = (m.obj_side[FRONT] + m.obj_side[BACK]) / 2;
#endif
// Compute the outside diameter of the nozzle at the height // Compute the outside diameter of the nozzle at the height
// at which it makes contact with the calibration object // at which it makes contact with the calibration object
#if HAS_X_CENTER TERN_(HAS_X_CENTER, m.nozzle_outer_dimension.x = m.obj_side[RIGHT] - m.obj_side[LEFT] - dimensions.x);
m.nozzle_outer_dimension.x = m.obj_side[RIGHT] - m.obj_side[LEFT] - dimensions.x; TERN_(HAS_Y_CENTER, m.nozzle_outer_dimension.y = m.obj_side[BACK] - m.obj_side[FRONT] - dimensions.y);
#endif
#if HAS_Y_CENTER
m.nozzle_outer_dimension.y = m.obj_side[BACK] - m.obj_side[FRONT] - dimensions.y;
#endif
park_above_object(m, uncertainty); park_above_object(m, uncertainty);
@ -544,13 +526,9 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty)
HOTEND_LOOP() calibrate_toolhead(m, uncertainty, e); HOTEND_LOOP() calibrate_toolhead(m, uncertainty, e);
#if HAS_HOTEND_OFFSET TERN_(HAS_HOTEND_OFFSET, normalize_hotend_offsets());
normalize_hotend_offsets();
#endif
#if HAS_MULTI_HOTEND TERN_(HAS_MULTI_HOTEND, set_nozzle(m, 0));
set_nozzle(m, 0);
#endif
} }
/** /**
@ -567,9 +545,7 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty)
inline void calibrate_all() { inline void calibrate_all() {
measurements_t m; measurements_t m;
#if HAS_HOTEND_OFFSET TERN_(HAS_HOTEND_OFFSET, reset_hotend_offsets());
reset_hotend_offsets();
#endif
TEMPORARY_BACKLASH_CORRECTION(all_on); TEMPORARY_BACKLASH_CORRECTION(all_on);
TEMPORARY_BACKLASH_SMOOTHING(0.0f); TEMPORARY_BACKLASH_SMOOTHING(0.0f);
@ -577,9 +553,7 @@ inline void calibrate_all() {
// Do a fast and rough calibration of the toolheads // Do a fast and rough calibration of the toolheads
calibrate_all_toolheads(m, CALIBRATION_MEASUREMENT_UNKNOWN); calibrate_all_toolheads(m, CALIBRATION_MEASUREMENT_UNKNOWN);
#if ENABLED(BACKLASH_GCODE) TERN_(BACKLASH_GCODE, calibrate_backlash(m, CALIBRATION_MEASUREMENT_UNCERTAIN));
calibrate_backlash(m, CALIBRATION_MEASUREMENT_UNCERTAIN);
#endif
// Cycle the toolheads so the servos settle into their "natural" positions // Cycle the toolheads so the servos settle into their "natural" positions
#if HAS_MULTI_HOTEND #if HAS_MULTI_HOTEND

View file

@ -178,9 +178,7 @@ void GcodeSuite::G76() {
report_temps(next_temp_report); report_temps(next_temp_report);
// Disable leveling so it won't mess with us // Disable leveling so it won't mess with us
#if HAS_LEVELING TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
set_bed_leveling_enabled(false);
#endif
for (;;) { for (;;) {
thermalManager.setTargetBed(target_bed); thermalManager.setTargetBed(target_bed);
@ -214,9 +212,7 @@ void GcodeSuite::G76() {
// Cleanup // Cleanup
thermalManager.setTargetBed(0); thermalManager.setTargetBed(0);
#if HAS_LEVELING TERN_(HAS_LEVELING, set_bed_leveling_enabled(true));
set_bed_leveling_enabled(true);
#endif
} // do_bed_cal } // do_bed_cal
/******************************************** /********************************************
@ -240,9 +236,7 @@ void GcodeSuite::G76() {
wait_for_temps(target_bed, target_probe, next_temp_report); wait_for_temps(target_bed, target_probe, next_temp_report);
// Disable leveling so it won't mess with us // Disable leveling so it won't mess with us
#if HAS_LEVELING TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
set_bed_leveling_enabled(false);
#endif
bool timeout = false; bool timeout = false;
for (;;) { for (;;) {
@ -273,9 +267,7 @@ void GcodeSuite::G76() {
// Cleanup // Cleanup
thermalManager.setTargetBed(0); thermalManager.setTargetBed(0);
#if HAS_LEVELING TERN_(HAS_LEVELING, set_bed_leveling_enabled(true));
set_bed_leveling_enabled(true);
#endif
SERIAL_ECHOLNPGM("Final compensation values:"); SERIAL_ECHOLNPGM("Final compensation values:");
temp_comp.print_offsets(); temp_comp.print_offsets();

View file

@ -263,9 +263,7 @@ void GcodeSuite::M48() {
restore_feedrate_and_scaling(); restore_feedrate_and_scaling();
// Re-enable bed level correction if it had been on // Re-enable bed level correction if it had been on
#if HAS_LEVELING TERN_(HAS_LEVELING, set_bed_leveling_enabled(was_enabled));
set_bed_leveling_enabled(was_enabled);
#endif
report_current_position(); report_current_position();
} }

View file

@ -142,9 +142,7 @@ void GcodeSuite::M205() {
const float junc_dev = parser.value_linear_units(); const float junc_dev = parser.value_linear_units();
if (WITHIN(junc_dev, 0.01f, 0.3f)) { if (WITHIN(junc_dev, 0.01f, 0.3f)) {
planner.junction_deviation_mm = junc_dev; planner.junction_deviation_mm = junc_dev;
#if ENABLED(LIN_ADVANCE) TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk());
planner.recalculate_max_e_jerk();
#endif
} }
else else
SERIAL_ERROR_MSG("?J out of range (0.01 to 0.3)"); SERIAL_ERROR_MSG("?J out of range (0.01 to 0.3)");

View file

@ -340,12 +340,8 @@ void GcodeSuite::M43() {
#if HAS_RESUME_CONTINUE #if HAS_RESUME_CONTINUE
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; wait_for_user = true;
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), CONTINUE_STR));
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), CONTINUE_STR); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called")));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called"));
#endif
#endif #endif
for (;;) { for (;;) {
@ -366,9 +362,7 @@ void GcodeSuite::M43() {
} }
} }
#if HAS_RESUME_CONTINUE if (TERN0(HAS_RESUME_CONTINUE, !wait_for_user)) break;
if (!wait_for_user) break;
#endif
safe_delay(200); safe_delay(200);
} }

View file

@ -31,9 +31,7 @@
* M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature. * M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
*/ */
void GcodeSuite::M108() { void GcodeSuite::M108() {
#if HAS_RESUME_CONTINUE TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
wait_for_user = false;
#endif
wait_for_heatup = false; wait_for_heatup = false;
} }

View file

@ -37,9 +37,7 @@ void GcodeSuite::M17() {
if (parser.seen('X')) ENABLE_AXIS_X(); if (parser.seen('X')) ENABLE_AXIS_X();
if (parser.seen('Y')) ENABLE_AXIS_Y(); if (parser.seen('Y')) ENABLE_AXIS_Y();
if (parser.seen('Z')) ENABLE_AXIS_Z(); if (parser.seen('Z')) ENABLE_AXIS_Z();
#if HAS_E_STEPPER_ENABLE if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) enable_e_steppers();
if (parser.seen('E')) enable_e_steppers();
#endif
} }
else { else {
LCD_MESSAGEPGM(MSG_NO_MOVE); LCD_MESSAGEPGM(MSG_NO_MOVE);
@ -60,9 +58,7 @@ void GcodeSuite::M18_M84() {
if (parser.seen('X')) DISABLE_AXIS_X(); if (parser.seen('X')) DISABLE_AXIS_X();
if (parser.seen('Y')) DISABLE_AXIS_Y(); if (parser.seen('Y')) DISABLE_AXIS_Y();
if (parser.seen('Z')) DISABLE_AXIS_Z(); if (parser.seen('Z')) DISABLE_AXIS_Z();
#if HAS_E_STEPPER_ENABLE if (TERN0(HAS_E_STEPPER_ENABLE, parser.seen('E'))) disable_e_steppers();
if (parser.seen('E')) disable_e_steppers();
#endif
} }
else else
planner.finish_and_disable(); planner.finish_and_disable();

View file

@ -86,12 +86,8 @@ void GcodeSuite::M907() {
* M908: Control digital trimpot directly (M908 P<pin> S<current>) * M908: Control digital trimpot directly (M908 P<pin> S<current>)
*/ */
void GcodeSuite::M908() { void GcodeSuite::M908() {
#if HAS_DIGIPOTSS TERN_(HAS_DIGIPOTSS, stepper.digitalPotWrite(parser.intval('P'), parser.intval('S')));
stepper.digitalPotWrite(parser.intval('P'), parser.intval('S')); TERN_(DAC_STEPPER_CURRENT, dac_current_raw(parser.byteval('P', -1), parser.ushortval('S', 0)));
#endif
#if ENABLED(DAC_STEPPER_CURRENT)
dac_current_raw(parser.byteval('P', -1), parser.ushortval('S', 0));
#endif
} }
#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT #endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT

View file

@ -56,11 +56,7 @@
*/ */
void GcodeSuite::M125() { void GcodeSuite::M125() {
// Initial retract before move to filament change position // Initial retract before move to filament change position
const float retract = -ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : 0 const float retract = -ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) : (PAUSE_PARK_RETRACT_LENGTH));
#ifdef PAUSE_PARK_RETRACT_LENGTH
+ (PAUSE_PARK_RETRACT_LENGTH)
#endif
);
xyz_pos_t park_point = NOZZLE_PARK_POINT; xyz_pos_t park_point = NOZZLE_PARK_POINT;
@ -75,23 +71,14 @@ void GcodeSuite::M125() {
park_point += hotend_offset[active_extruder]; park_point += hotend_offset[active_extruder];
#endif #endif
#if ENABLED(SDSUPPORT) const bool sd_printing = TERN0(SDSUPPORT, IS_SD_PRINTING());
const bool sd_printing = IS_SD_PRINTING();
#else
constexpr bool sd_printing = false;
#endif
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT));
lcd_pause_show_message(PAUSE_MESSAGE_PARKING, PAUSE_MODE_PAUSE_PRINT);
const bool show_lcd = parser.seenval('P'); const bool show_lcd = TERN0(HAS_LCD_MENU, parser.seenval('P'));
#else
constexpr bool show_lcd = false;
#endif
if (pause_print(retract, park_point, 0, show_lcd)) { if (pause_print(retract, park_point, 0, show_lcd)) {
#if ENABLED(POWER_LOSS_RECOVERY) TERN_(POWER_LOSS_RECOVERY, if (recovery.enabled) recovery.save(true));
if (recovery.enabled) recovery.save(true);
#endif
if (!sd_printing || show_lcd) { if (!sd_printing || show_lcd) {
wait_for_confirmation(false, 0); wait_for_confirmation(false, 0);
resume_print(0, 0, -retract, 0); resume_print(0, 0, -retract, 0);

View file

@ -112,11 +112,7 @@ void GcodeSuite::M600() {
#endif #endif
// Initial retract before move to filament change position // Initial retract before move to filament change position
const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : 0 const float retract = -ABS(parser.seen('E') ? parser.value_axis_units(E_AXIS) : (PAUSE_PARK_RETRACT_LENGTH));
#ifdef PAUSE_PARK_RETRACT_LENGTH
+ (PAUSE_PARK_RETRACT_LENGTH)
#endif
);
xyz_pos_t park_point NOZZLE_PARK_POINT; xyz_pos_t park_point NOZZLE_PARK_POINT;
@ -149,11 +145,9 @@ void GcodeSuite::M600() {
: fc_settings[active_extruder].load_length); : fc_settings[active_extruder].load_length);
#endif #endif
const int beep_count = parser.intval('B', const int beep_count = parser.intval('B', -1
#ifdef FILAMENT_CHANGE_ALERT_BEEPS #ifdef FILAMENT_CHANGE_ALERT_BEEPS
FILAMENT_CHANGE_ALERT_BEEPS + 1 + FILAMENT_CHANGE_ALERT_BEEPS
#else
-1
#endif #endif
); );
@ -173,9 +167,7 @@ void GcodeSuite::M600() {
tool_change(active_extruder_before_filament_change, false); tool_change(active_extruder_before_filament_change, false);
#endif #endif
#if ENABLED(MIXING_EXTRUDER) TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
mixer.T(old_mixing_tool); // Restore original mixing tool
#endif
} }
#endif // ADVANCED_PAUSE_FEATURE #endif // ADVANCED_PAUSE_FEATURE

View file

@ -84,9 +84,7 @@ void GcodeSuite::M701() {
if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
// Show initial "wait for load" message // Show initial "wait for load" message
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder));
lcd_pause_show_message(PAUSE_MESSAGE_LOAD, PAUSE_MODE_LOAD_FILAMENT, target_extruder);
#endif
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Change toolhead if specified // Change toolhead if specified
@ -129,14 +127,10 @@ void GcodeSuite::M701() {
tool_change(active_extruder_before_filament_change, false); tool_change(active_extruder_before_filament_change, false);
#endif #endif
#if ENABLED(MIXING_EXTRUDER) TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
mixer.T(old_mixing_tool); // Restore original mixing tool
#endif
// Show status screen // Show status screen
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
#endif
} }
/** /**
@ -190,9 +184,7 @@ void GcodeSuite::M702() {
if (parser.seenval('Z')) park_point.z = parser.linearval('Z'); if (parser.seenval('Z')) park_point.z = parser.linearval('Z');
// Show initial "wait for unload" message // Show initial "wait for unload" message
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder));
lcd_pause_show_message(PAUSE_MESSAGE_UNLOAD, PAUSE_MODE_UNLOAD_FILAMENT, target_extruder);
#endif
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2) #if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Change toolhead if specified // Change toolhead if specified
@ -241,14 +233,10 @@ void GcodeSuite::M702() {
tool_change(active_extruder_before_filament_change, false); tool_change(active_extruder_before_filament_change, false);
#endif #endif
#if ENABLED(MIXING_EXTRUDER) TERN_(MIXING_EXTRUDER, mixer.T(old_mixing_tool)); // Restore original mixing tool
mixer.T(old_mixing_tool); // Restore original mixing tool
#endif
// Show status screen // Show status screen
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
#endif
} }
#endif // ADVANCED_PAUSE_FEATURE #endif // ADVANCED_PAUSE_FEATURE

View file

@ -74,9 +74,7 @@ void GcodeSuite::M1000() {
#else #else
recovery.cancel(); recovery.cancel();
#endif #endif
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerStopped());
ExtUI::onPrintTimerStopped();
#endif
} }
else else
recovery.resume(); recovery.resume();

View file

@ -218,9 +218,7 @@ void GcodeSuite::dwell(millis_t time) {
} }
} }
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_action_prompt_end());
host_action_prompt_end();
#endif
#ifdef G29_SUCCESS_COMMANDS #ifdef G29_SUCCESS_COMMANDS
process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS)); process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS));

View file

@ -396,24 +396,18 @@ private:
#endif #endif
); );
#if ENABLED(ARC_SUPPORT) TERN_(ARC_SUPPORT, static void G2_G3(const bool clockwise));
static void G2_G3(const bool clockwise);
#endif
static void G4(); static void G4();
#if ENABLED(BEZIER_CURVE_SUPPORT) TERN_(BEZIER_CURVE_SUPPORT, static void G5());
static void G5();
#endif
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
static void G10(); static void G10();
static void G11(); static void G11();
#endif #endif
#if ENABLED(NOZZLE_CLEAN_FEATURE) TERN_(NOZZLE_CLEAN_FEATURE, static void G12());
static void G12();
#endif
#if ENABLED(CNC_WORKSPACE_PLANES) #if ENABLED(CNC_WORKSPACE_PLANES)
static void G17(); static void G17();
@ -426,13 +420,9 @@ private:
static void G21(); static void G21();
#endif #endif
#if ENABLED(G26_MESH_VALIDATION) TERN_(G26_MESH_VALIDATION, static void G26());
static void G26();
#endif
#if ENABLED(NOZZLE_PARK_FEATURE) TERN_(NOZZLE_PARK_FEATURE, static void G27());
static void G27();
#endif
static void G28(); static void G28();
@ -454,22 +444,16 @@ private:
#endif #endif
#endif #endif
#if ENABLED(DELTA_AUTO_CALIBRATION) TERN_(DELTA_AUTO_CALIBRATION, static void G33());
static void G33();
#endif
#if ENABLED(Z_STEPPER_AUTO_ALIGN) #if ENABLED(Z_STEPPER_AUTO_ALIGN)
static void G34(); static void G34();
static void M422(); static void M422();
#endif #endif
#if ENABLED(G38_PROBE_TARGET) TERN_(G38_PROBE_TARGET, static void G38(const int8_t subcode));
static void G38(const int8_t subcode);
#endif
#if HAS_MESH TERN_(HAS_MESH, static void G42());
static void G42();
#endif
#if ENABLED(CNC_COORDINATE_SYSTEMS) #if ENABLED(CNC_COORDINATE_SYSTEMS)
static void G53(); static void G53();
@ -481,28 +465,20 @@ private:
static void G59(); static void G59();
#endif #endif
#if ENABLED(PROBE_TEMP_COMPENSATION) TERN_(PROBE_TEMP_COMPENSATION, static void G76());
static void G76();
#endif
#if SAVED_POSITIONS #if SAVED_POSITIONS
static void G60(); static void G60();
static void G61(); static void G61();
#endif #endif
#if ENABLED(GCODE_MOTION_MODES) TERN_(GCODE_MOTION_MODES, static void G80());
static void G80();
#endif
static void G92(); static void G92();
#if ENABLED(CALIBRATION_GCODE) TERN_(CALIBRATION_GCODE, static void G425());
static void G425();
#endif
#if HAS_RESUME_CONTINUE TERN_(HAS_RESUME_CONTINUE, static void M0_M1());
static void M0_M1();
#endif
#if HAS_CUTTER #if HAS_CUTTER
static void M3_M4(const bool is_M4); static void M3_M4(const bool is_M4);
@ -510,22 +486,14 @@ private:
#endif #endif
#if ENABLED(COOLANT_CONTROL) #if ENABLED(COOLANT_CONTROL)
#if ENABLED(COOLANT_MIST) TERN_(COOLANT_MIST, static void M7());
static void M7(); TERN_(COOLANT_FLOOD, static void M8());
#endif
#if ENABLED(COOLANT_FLOOD)
static void M8();
#endif
static void M9(); static void M9();
#endif #endif
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) TERN_(EXTERNAL_CLOSED_LOOP_CONTROLLER, static void M12());
static void M12();
#endif
#if ENABLED(EXPECTED_PRINTER_CHECK) TERN_(EXPECTED_PRINTER_CHECK, static void M16());
static void M16();
#endif
static void M17(); static void M17();
@ -549,9 +517,7 @@ private:
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
static void M32(); static void M32();
#if ENABLED(LONG_FILENAME_HOST_SUPPORT) TERN_(LONG_FILENAME_HOST_SUPPORT, static void M33());
static void M33();
#endif
#if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE) #if BOTH(SDCARD_SORT_ALPHA, SDSORT_GCODE)
static void M34(); static void M34();
#endif #endif
@ -559,29 +525,19 @@ private:
static void M42(); static void M42();
#if ENABLED(PINS_DEBUGGING) TERN_(PINS_DEBUGGING, static void M43());
static void M43();
#endif
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) TERN_(Z_MIN_PROBE_REPEATABILITY_TEST, static void M48());
static void M48();
#endif
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) TERN_(LCD_SET_PROGRESS_MANUALLY, static void M73());
static void M73();
#endif
static void M75(); static void M75();
static void M76(); static void M76();
static void M77(); static void M77();
#if ENABLED(PRINTCOUNTER) TERN_(PRINTCOUNTER, static void M78());
static void M78();
#endif
#if ENABLED(PSU_CONTROL) TERN_(PSU_CONTROL, static void M80());
static void M80();
#endif
static void M81(); static void M81();
static void M82(); static void M82();
@ -589,9 +545,7 @@ private:
static void M85(); static void M85();
static void M92(); static void M92();
#if ENABLED(M100_FREE_MEMORY_WATCHER) TERN_(M100_FREE_MEMORY_WATCHER, static void M100());
static void M100();
#endif
#if EXTRUDERS #if EXTRUDERS
static void M104(); static void M104();
@ -609,17 +563,13 @@ private:
static void M108(); static void M108();
static void M112(); static void M112();
static void M410(); static void M410();
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, static void M876());
static void M876();
#endif
#endif #endif
static void M110(); static void M110();
static void M111(); static void M111();
#if ENABLED(HOST_KEEPALIVE_FEATURE) TERN_(HOST_KEEPALIVE_FEATURE, static void M113());
static void M113();
#endif
static void M114(); static void M114();
static void M115(); static void M115();
@ -629,9 +579,7 @@ private:
static void M120(); static void M120();
static void M121(); static void M121();
#if ENABLED(PARK_HEAD_ON_PAUSE) TERN_(PARK_HEAD_ON_PAUSE, static void M125());
static void M125();
#endif
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)
#if HAS_HEATER_1 #if HAS_HEATER_1
@ -658,13 +606,9 @@ private:
static void M145(); static void M145();
#endif #endif
#if ENABLED(TEMPERATURE_UNITS_SUPPORT) TERN_(TEMPERATURE_UNITS_SUPPORT, static void M149());
static void M149();
#endif
#if HAS_COLOR_LEDS TERN_(HAS_COLOR_LEDS, static void M150());
static void M150();
#endif
#if ENABLED(AUTO_REPORT_TEMPERATURES) && HAS_TEMP_SENSOR #if ENABLED(AUTO_REPORT_TEMPERATURES) && HAS_TEMP_SENSOR
static void M155(); static void M155();
@ -673,12 +617,8 @@ private:
#if ENABLED(MIXING_EXTRUDER) #if ENABLED(MIXING_EXTRUDER)
static void M163(); static void M163();
static void M164(); static void M164();
#if ENABLED(DIRECT_MIXING_IN_G1) TERN_(DIRECT_MIXING_IN_G1, static void M165());
static void M165(); TERN_(GRADIENT_MIX, static void M166());
#endif
#if ENABLED(GRADIENT_MIX)
static void M166();
#endif
#endif #endif
static void M200(); static void M200();
@ -692,16 +632,12 @@ private:
static void M204(); static void M204();
static void M205(); static void M205();
#if HAS_M206_COMMAND TERN_(HAS_M206_COMMAND, static void M206());
static void M206();
#endif
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
static void M207(); static void M207();
static void M208(); static void M208();
#if ENABLED(FWRETRACT_AUTORETRACT) TERN_(FWRETRACT_AUTORETRACT, static void M209());
static void M209();
#endif
#endif #endif
static void M211(); static void M211();
@ -710,9 +646,7 @@ private:
static void M217(); static void M217();
#endif #endif
#if HAS_HOTEND_OFFSET TERN_(HAS_HOTEND_OFFSET, static void M218());
static void M218();
#endif
static void M220(); static void M220();
@ -722,13 +656,9 @@ private:
static void M226(); static void M226();
#if ENABLED(PHOTO_GCODE) TERN_(PHOTO_GCODE, static void M240());
static void M240();
#endif
#if HAS_LCD_CONTRAST TERN_(HAS_LCD_CONTRAST, static void M250());
static void M250();
#endif
#if ENABLED(EXPERIMENTAL_I2CBUS) #if ENABLED(EXPERIMENTAL_I2CBUS)
static void M260(); static void M260();
@ -737,47 +667,29 @@ private:
#if HAS_SERVOS #if HAS_SERVOS
static void M280(); static void M280();
#if ENABLED(EDITABLE_SERVO_ANGLES) TERN_(EDITABLE_SERVO_ANGLES, static void M281());
static void M281();
#endif
#endif #endif
#if ENABLED(BABYSTEPPING) TERN_(BABYSTEPPING, static void M290());
static void M290();
#endif
#if HAS_BUZZER TERN_(HAS_BUZZER, static void M300());
static void M300();
#endif
#if ENABLED(PIDTEMP) TERN_(PIDTEMP, static void M301());
static void M301();
#endif
#if ENABLED(PREVENT_COLD_EXTRUSION) TERN_(PREVENT_COLD_EXTRUSION, static void M302());
static void M302();
#endif
#if HAS_PID_HEATING TERN_(HAS_PID_HEATING, static void M303());
static void M303();
#endif
#if ENABLED(PIDTEMPBED) TERN_(PIDTEMPBED, static void M304());
static void M304();
#endif
#if HAS_USER_THERMISTORS TERN_(HAS_USER_THERMISTORS, static void M305());
static void M305();
#endif
#if HAS_MICROSTEPS #if HAS_MICROSTEPS
static void M350(); static void M350();
static void M351(); static void M351();
#endif #endif
#if HAS_CASE_LIGHT TERN_(HAS_CASE_LIGHT, static void M355());
static void M355();
#endif
#if ENABLED(MORGAN_SCARA) #if ENABLED(MORGAN_SCARA)
static bool M360(); static bool M360();
@ -799,9 +711,7 @@ private:
static void M402(); static void M402();
#endif #endif
#if ENABLED(PRUSA_MMU2) TERN_(PRUSA_MMU2, static void M403());
static void M403();
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR) #if ENABLED(FILAMENT_WIDTH_SENSOR)
static void M404(); static void M404();
@ -810,26 +720,18 @@ private:
static void M407(); static void M407();
#endif #endif
#if HAS_FILAMENT_SENSOR TERN_(HAS_FILAMENT_SENSOR, static void M412());
static void M412();
#endif
#if HAS_LEVELING #if HAS_LEVELING
static void M420(); static void M420();
static void M421(); static void M421();
#endif #endif
#if ENABLED(BACKLASH_GCODE) TERN_(BACKLASH_GCODE, static void M425());
static void M425();
#endif
#if HAS_M206_COMMAND TERN_(HAS_M206_COMMAND, static void M428());
static void M428();
#endif
#if ENABLED(CANCEL_OBJECTS) TERN_(CANCEL_OBJECTS, static void M486());
static void M486();
#endif
static void M500(); static void M500();
static void M501(); static void M501();
@ -837,34 +739,22 @@ private:
#if DISABLED(DISABLE_M503) #if DISABLED(DISABLE_M503)
static void M503(); static void M503();
#endif #endif
#if ENABLED(EEPROM_SETTINGS) TERN_(EEPROM_SETTINGS, static void M504());
static void M504();
#endif
#if ENABLED(SDSUPPORT) TERN_(SDSUPPORT, static void M524());
static void M524();
#endif
#if ENABLED(SD_ABORT_ON_ENDSTOP_HIT) TERN_(SD_ABORT_ON_ENDSTOP_HIT, static void M540());
static void M540();
#endif
#if ENABLED(BAUD_RATE_GCODE) TERN_(BAUD_RATE_GCODE, static void M575());
static void M575();
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE) #if ENABLED(ADVANCED_PAUSE_FEATURE)
static void M600(); static void M600();
static void M603(); static void M603();
#endif #endif
#if HAS_DUPLICATION_MODE TERN_(HAS_DUPLICATION_MODE, static void M605());
static void M605();
#endif
#if IS_KINEMATIC TERN_(IS_KINEMATIC, static void M665());
static void M665();
#endif
#if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS #if ENABLED(DELTA) || HAS_EXTRA_ENDSTOPS
static void M666(); static void M666();
@ -879,17 +769,11 @@ private:
static void M702(); static void M702();
#endif #endif
#if ENABLED(GCODE_MACROS) TERN_(GCODE_MACROS, static void M810_819());
static void M810_819();
#endif
#if HAS_BED_PROBE TERN_(HAS_BED_PROBE, static void M851());
static void M851();
#endif
#if ENABLED(SKEW_CORRECTION_GCODE) TERN_(SKEW_CORRECTION_GCODE, static void M852());
static void M852();
#endif
#if ENABLED(I2C_POSITION_ENCODERS) #if ENABLED(I2C_POSITION_ENCODERS)
FORCE_INLINE static void M860() { I2CPEM.M860(); } FORCE_INLINE static void M860() { I2CPEM.M860(); }
@ -904,30 +788,20 @@ private:
FORCE_INLINE static void M869() { I2CPEM.M869(); } FORCE_INLINE static void M869() { I2CPEM.M869(); }
#endif #endif
#if ENABLED(PROBE_TEMP_COMPENSATION) TERN_(PROBE_TEMP_COMPENSATION, static void M871());
static void M871();
#endif
#if ENABLED(LIN_ADVANCE) TERN_(LIN_ADVANCE, static void M900());
static void M900();
#endif
#if HAS_TRINAMIC_CONFIG #if HAS_TRINAMIC_CONFIG
static void M122(); static void M122();
static void M906(); static void M906();
#if HAS_STEALTHCHOP TERN_(HAS_STEALTHCHOP, static void M569());
static void M569();
#endif
#if ENABLED(MONITOR_DRIVER_STATUS) #if ENABLED(MONITOR_DRIVER_STATUS)
static void M911(); static void M911();
static void M912(); static void M912();
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) TERN_(HYBRID_THRESHOLD, static void M913());
static void M913(); TERN_(USE_SENSORLESS, static void M914());
#endif
#if USE_SENSORLESS
static void M914();
#endif
#endif #endif
#if HAS_L64XX #if HAS_L64XX
@ -949,17 +823,11 @@ private:
#endif #endif
#endif #endif
#if ENABLED(SDSUPPORT) TERN_(SDSUPPORT, static void M928());
static void M928();
#endif
#if ENABLED(MAGNETIC_PARKING_EXTRUDER) TERN_(MAGNETIC_PARKING_EXTRUDER, static void M951());
static void M951();
#endif
#if ENABLED(PLATFORM_M997_SUPPORT) TERN_(PLATFORM_M997_SUPPORT, static void M997());
static void M997();
#endif
static void M999(); static void M999();
@ -968,17 +836,11 @@ private:
static void M1000(); static void M1000();
#endif #endif
#if ENABLED(SDSUPPORT) TERN_(SDSUPPORT, static void M1001());
static void M1001();
#endif
#if ENABLED(MAX7219_GCODE) TERN_(MAX7219_GCODE, static void M7219());
static void M7219();
#endif
#if ENABLED(CONTROLLER_FAN_EDITABLE) TERN_(CONTROLLER_FAN_EDITABLE, static void M710());
static void M710();
#endif
static void T(const uint8_t tool_index); static void T(const uint8_t tool_index);

View file

@ -213,8 +213,6 @@ void GcodeSuite::M114() {
if (parser.seen('R')) { report_real_position(); return; } if (parser.seen('R')) { report_real_position(); return; }
#endif #endif
#if ENABLED(M114_LEGACY) TERN_(M114_LEGACY, planner.synchronize());
planner.synchronize();
#endif
report_current_position_projected(); report_current_position_projected();
} }

View file

@ -44,14 +44,10 @@ void GcodeSuite::M115() {
#if ENABLED(EXTENDED_CAPABILITIES_REPORT) #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
// PAREN_COMMENTS // PAREN_COMMENTS
#if ENABLED(PAREN_COMMENTS) TERN_(PAREN_COMMENTS, cap_line(PSTR("PAREN_COMMENTS"), true));
cap_line(PSTR("PAREN_COMMENTS"), true);
#endif
// QUOTED_STRINGS // QUOTED_STRINGS
#if ENABLED(GCODE_QUOTED_STRINGS) TERN_(GCODE_QUOTED_STRINGS, cap_line(PSTR("QUOTED_STRINGS"), true));
cap_line(PSTR("QUOTED_STRINGS"), true);
#endif
// SERIAL_XON_XOFF // SERIAL_XON_XOFF
cap_line(PSTR("SERIAL_XON_XOFF"), ENABLED(SERIAL_XON_XOFF)); cap_line(PSTR("SERIAL_XON_XOFF"), ENABLED(SERIAL_XON_XOFF));
@ -92,7 +88,7 @@ void GcodeSuite::M115() {
// CASE LIGHTS (M355) // CASE LIGHTS (M355)
cap_line(PSTR("TOGGLE_LIGHTS"), ENABLED(HAS_CASE_LIGHT)); cap_line(PSTR("TOGGLE_LIGHTS"), ENABLED(HAS_CASE_LIGHT));
cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN(HAS_CASE_LIGHT, PWM_PIN(CASE_LIGHT_PIN), 0)); cap_line(PSTR("CASE_LIGHT_BRIGHTNESS"), TERN0(HAS_CASE_LIGHT, PWM_PIN(CASE_LIGHT_PIN)));
// EMERGENCY_PARSER (M108, M112, M410, M876) // EMERGENCY_PARSER (M108, M112, M410, M876)
cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER)); cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER));

View file

@ -77,15 +77,11 @@ void GcodeSuite::M0_M1() {
#endif #endif
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR));
host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR);
#endif
wait_for_user_response(ms); wait_for_user_response(ms);
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, ui.reset_status());
ui.reset_status();
#endif
} }
#endif // HAS_RESUME_CONTINUE #endif // HAS_RESUME_CONTINUE

View file

@ -70,14 +70,12 @@ void plan_arc(
ab_float_t rvec = -offset; ab_float_t rvec = -offset;
const float radius = HYPOT(rvec.a, rvec.b), const float radius = HYPOT(rvec.a, rvec.b),
#if ENABLED(AUTO_BED_LEVELING_UBL)
start_L = current_position[l_axis],
#endif
center_P = current_position[p_axis] - rvec.a, center_P = current_position[p_axis] - rvec.a,
center_Q = current_position[q_axis] - rvec.b, center_Q = current_position[q_axis] - rvec.b,
rt_X = cart[p_axis] - center_P, rt_X = cart[p_axis] - center_P,
rt_Y = cart[q_axis] - center_Q, rt_Y = cart[q_axis] - center_Q,
linear_travel = cart[l_axis] - current_position[l_axis], start_L = current_position[l_axis],
linear_travel = cart[l_axis] - start_L,
extruder_travel = cart.e - current_position.e; extruder_travel = cart.e - current_position.e;
// CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required. // CCW angle of rotation between position and target from the circle center. Only one atan2() trig computation required.
@ -157,7 +155,6 @@ void plan_arc(
// Initialize the extruder axis // Initialize the extruder axis
raw.e = current_position.e; raw.e = current_position.e;
#if ENABLED(SCARA_FEEDRATE_SCALING) #if ENABLED(SCARA_FEEDRATE_SCALING)
const float inv_duration = scaled_fr_mm_s / seg_length; const float inv_duration = scaled_fr_mm_s / seg_length;
#endif #endif
@ -220,15 +217,12 @@ void plan_arc(
#if ENABLED(SCARA_FEEDRATE_SCALING) #if ENABLED(SCARA_FEEDRATE_SCALING)
, inv_duration , inv_duration
#endif #endif
)) )) break;
break;
} }
// Ensure last segment arrives at target location. // Ensure last segment arrives at target location.
raw = cart; raw = cart;
#if ENABLED(AUTO_BED_LEVELING_UBL) TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);
raw[l_axis] = start_L;
#endif
apply_motion_limits(raw); apply_motion_limits(raw);
@ -242,10 +236,9 @@ void plan_arc(
#endif #endif
); );
#if ENABLED(AUTO_BED_LEVELING_UBL) TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);
raw[l_axis] = start_L;
#endif
current_position = raw; current_position = raw;
} // plan_arc } // plan_arc
/** /**
@ -285,9 +278,7 @@ void GcodeSuite::G2_G3(const bool clockwise) {
get_destination_from_command(); // Get X Y Z E F (and set cutter power) get_destination_from_command(); // Get X Y Z E F (and set cutter power)
#if ENABLED(SF_ARC_FIX) TERN_(SF_ARC_FIX, relative_mode = relative_mode_backup);
relative_mode = relative_mode_backup;
#endif
ab_float_t arc_offset = { 0, 0 }; ab_float_t arc_offset = { 0, 0 };
if (parser.seenval('R')) { if (parser.seenval('R')) {

View file

@ -83,9 +83,7 @@ void GCodeParser::reset() {
string_arg = nullptr; // No whole line argument string_arg = nullptr; // No whole line argument
command_letter = '?'; // No command letter command_letter = '?'; // No command letter
codenum = 0; // No command code codenum = 0; // No command code
#if ENABLED(USE_GCODE_SUBCODES) TERN_(USE_GCODE_SUBCODES, subcode = 0); // No command sub-code
subcode = 0; // No command sub-code
#endif
#if ENABLED(FASTER_GCODE_PARSER) #if ENABLED(FASTER_GCODE_PARSER)
codebits = 0; // No codes yet codebits = 0; // No codes yet
//ZERO(param); // No parameters (should be safe to comment out this line) //ZERO(param); // No parameters (should be safe to comment out this line)
@ -119,9 +117,8 @@ void GCodeParser::parse(char *p) {
reset(); // No codes to report reset(); // No codes to report
auto uppercase = [](char c) { auto uppercase = [](char c) {
#if ENABLED(GCODE_CASE_INSENSITIVE) if (TERN0(GCODE_CASE_INSENSITIVE, WITHIN(c, 'a', 'z')))
if (WITHIN(c, 'a', 'z')) c += 'A' - 'a'; c += 'A' - 'a';
#endif
return c; return c;
}; };
@ -130,9 +127,7 @@ void GCodeParser::parse(char *p) {
// Skip N[-0-9] if included in the command line // Skip N[-0-9] if included in the command line
if (uppercase(*p) == 'N' && NUMERIC_SIGNED(p[1])) { if (uppercase(*p) == 'N' && NUMERIC_SIGNED(p[1])) {
#if ENABLED(FASTER_GCODE_PARSER) //TERN_(FASTER_GCODE_PARSER, set('N', p + 1)); // (optional) Set the 'N' parameter value
//set('N', p + 1); // (optional) Set the 'N' parameter value
#endif
p += 2; // skip N[-0-9] p += 2; // skip N[-0-9]
while (NUMERIC(*p)) ++p; // skip [0-9]* while (NUMERIC(*p)) ++p; // skip [0-9]*
while (*p == ' ') ++p; // skip [ ]* while (*p == ' ') ++p; // skip [ ]*
@ -213,9 +208,7 @@ void GCodeParser::parse(char *p) {
) )
) { ) {
motion_mode_codenum = codenum; motion_mode_codenum = codenum;
#if ENABLED(USE_GCODE_SUBCODES) TERN_(USE_GCODE_SUBCODES, motion_mode_subcode = subcode);
motion_mode_subcode = subcode;
#endif
} }
#endif #endif
@ -232,9 +225,7 @@ void GCodeParser::parse(char *p) {
if (motion_mode_codenum < 0) return; if (motion_mode_codenum < 0) return;
command_letter = 'G'; command_letter = 'G';
codenum = motion_mode_codenum; codenum = motion_mode_codenum;
#if ENABLED(USE_GCODE_SUBCODES) TERN_(USE_GCODE_SUBCODES, subcode = motion_mode_subcode);
subcode = motion_mode_subcode;
#endif
p--; // Back up one character to use the current parameter p--; // Back up one character to use the current parameter
break; break;
#endif // GCODE_MOTION_MODES #endif // GCODE_MOTION_MODES
@ -331,13 +322,9 @@ void GCodeParser::parse(char *p) {
#endif #endif
} }
#if ENABLED(DEBUG_GCODE_PARSER) if (TERN0(DEBUG_GCODE_PARSER, debug)) SERIAL_EOL();
if (debug) SERIAL_EOL();
#endif
#if ENABLED(FASTER_GCODE_PARSER) TERN_(FASTER_GCODE_PARSER, set(param, valptr)); // Set parameter exists and pointer (nullptr for no value)
set(param, valptr); // Set parameter exists and pointer (nullptr for no value)
#endif
} }
else if (!string_arg) { // Not A-Z? First time, keep as the string_arg else if (!string_arg) { // Not A-Z? First time, keep as the string_arg
string_arg = p - 1; string_arg = p - 1;

View file

@ -46,9 +46,7 @@ void GcodeSuite::G30() {
if (!probe.can_reach(pos)) return; if (!probe.can_reach(pos)) return;
// Disable leveling so the planner won't mess with us // Disable leveling so the planner won't mess with us
#if HAS_LEVELING TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
set_bed_leveling_enabled(false);
#endif
remember_feedrate_scaling_off(); remember_feedrate_scaling_off();

View file

@ -46,9 +46,7 @@ void mpe_settings_init() {
mpe_settings.parking_xpos[0] = pex[0]; // M951 L mpe_settings.parking_xpos[0] = pex[0]; // M951 L
mpe_settings.parking_xpos[1] = pex[1]; // M951 R mpe_settings.parking_xpos[1] = pex[1]; // M951 R
mpe_settings.grab_distance = PARKING_EXTRUDER_GRAB_DISTANCE; // M951 I mpe_settings.grab_distance = PARKING_EXTRUDER_GRAB_DISTANCE; // M951 I
#if HAS_HOME_OFFSET TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
#endif
mpe_settings.slow_feedrate = MMM_TO_MMS(MPE_SLOW_SPEED); // M951 J mpe_settings.slow_feedrate = MMM_TO_MMS(MPE_SLOW_SPEED); // M951 J
mpe_settings.fast_feedrate = MMM_TO_MMS(MPE_FAST_SPEED); // M951 H mpe_settings.fast_feedrate = MMM_TO_MMS(MPE_FAST_SPEED); // M951 H
mpe_settings.travel_distance = MPE_TRAVEL_DISTANCE; // M951 D mpe_settings.travel_distance = MPE_TRAVEL_DISTANCE; // M951 D
@ -61,9 +59,7 @@ void GcodeSuite::M951() {
if (parser.seenval('R')) mpe_settings.parking_xpos[1] = parser.value_linear_units(); if (parser.seenval('R')) mpe_settings.parking_xpos[1] = parser.value_linear_units();
if (parser.seenval('I')) { if (parser.seenval('I')) {
mpe_settings.grab_distance = parser.value_linear_units(); mpe_settings.grab_distance = parser.value_linear_units();
#if HAS_HOME_OFFSET TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
#endif
} }
if (parser.seenval('J')) mpe_settings.slow_feedrate = MMM_TO_MMS(parser.value_linear_units()); if (parser.seenval('J')) mpe_settings.slow_feedrate = MMM_TO_MMS(parser.value_linear_units());
if (parser.seenval('H')) mpe_settings.fast_feedrate = MMM_TO_MMS(parser.value_linear_units()); if (parser.seenval('H')) mpe_settings.fast_feedrate = MMM_TO_MMS(parser.value_linear_units());

View file

@ -127,9 +127,7 @@ void GCodeQueue::_commit_command(bool say_ok
#if NUM_SERIAL > 1 #if NUM_SERIAL > 1
port[index_w] = p; port[index_w] = p;
#endif #endif
#if ENABLED(POWER_LOSS_RECOVERY) TERN_(POWER_LOSS_RECOVERY, recovery.commit_sdpos(index_w));
recovery.commit_sdpos(index_w);
#endif
if (++index_w >= BUFSIZE) index_w = 0; if (++index_w >= BUFSIZE) index_w = 0;
length++; length++;
} }
@ -522,9 +520,7 @@ void GCodeQueue::get_serial_commands() {
// Process critical commands early // Process critical commands early
if (strcmp(command, "M108") == 0) { if (strcmp(command, "M108") == 0) {
wait_for_heatup = false; wait_for_heatup = false;
#if HAS_LCD_MENU TERN_(HAS_LCD_MENU, wait_for_user = false);
wait_for_user = false;
#endif
} }
if (strcmp(command, "M112") == 0) kill(M112_KILL_STR, nullptr, true); if (strcmp(command, "M112") == 0) kill(M112_KILL_STR, nullptr, true);
if (strcmp(command, "M410") == 0) quickstop_stepper(); if (strcmp(command, "M410") == 0) quickstop_stepper();
@ -601,9 +597,7 @@ void GCodeQueue::get_available_commands() {
get_serial_commands(); get_serial_commands();
#if ENABLED(SDSUPPORT) TERN_(SDSUPPORT, get_sdcard_commands());
get_sdcard_commands();
#endif
} }
/** /**

View file

@ -72,14 +72,10 @@ void GcodeSuite::M1001() {
gcode.process_subcommands_now_P(PSTR("M77")); gcode.process_subcommands_now_P(PSTR("M77"));
// Set the progress bar "done" state // Set the progress bar "done" state
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done());
ui.set_progress_done();
#endif
// Purge the recovery file // Purge the recovery file
#if ENABLED(POWER_LOSS_RECOVERY) TERN_(POWER_LOSS_RECOVERY, recovery.purge());
recovery.purge();
#endif
// Announce SD file completion // Announce SD file completion
SERIAL_ECHOLNPGM(STR_FILE_PRINTED); SERIAL_ECHOLNPGM(STR_FILE_PRINTED);
@ -88,12 +84,8 @@ void GcodeSuite::M1001() {
#if HAS_LEDS_OFF_FLAG #if HAS_LEDS_OFF_FLAG
if (long_print) { if (long_print) {
printerEventLEDs.onPrintCompleted(); printerEventLEDs.onPrintCompleted();
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE)));
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_PRINT_DONE)); TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_PRINT_DONE), CONTINUE_STR));
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_PRINT_DONE), CONTINUE_STR);
#endif
wait_for_user_response(1000UL * TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30)); wait_for_user_response(1000UL * TERN(HAS_LCD_MENU, PE_LEDS_COMPLETED_TIME, 30));
printerEventLEDs.onResumeAfterWait(); printerEventLEDs.onResumeAfterWait();
} }
@ -105,9 +97,7 @@ void GcodeSuite::M1001() {
#endif #endif
// Re-select the last printed file in the UI // Re-select the last printed file in the UI
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) TERN_(SD_REPRINT_LAST_SELECTED_FILE, ui.reselect_last_file());
ui.reselect_last_file();
#endif
} }
#endif // SDSUPPORT #endif // SDSUPPORT

View file

@ -38,9 +38,7 @@ void GcodeSuite::M23() {
for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0'; for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
card.openFileRead(parser.string_arg); card.openFileRead(parser.string_arg);
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0));
ui.set_progress(0);
#endif
} }
#endif // SDSUPPORT #endif // SDSUPPORT

View file

@ -64,18 +64,14 @@ void GcodeSuite::M24() {
if (card.isFileOpen()) { if (card.isFileOpen()) {
card.startFileprint(); // SD card will now be read for commands card.startFileprint(); // SD card will now be read for commands
startOrResumeJob(); // Start (or resume) the print job timer startOrResumeJob(); // Start (or resume) the print job timer
#if ENABLED(POWER_LOSS_RECOVERY) TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
recovery.prepare();
#endif
} }
#if ENABLED(HOST_ACTION_COMMANDS) #if ENABLED(HOST_ACTION_COMMANDS)
#ifdef ACTION_ON_RESUME #ifdef ACTION_ON_RESUME
host_action_resume(); host_action_resume();
#endif #endif
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming SD"), DISMISS_STR));
host_prompt_open(PROMPT_INFO, PSTR("Resuming SD"), DISMISS_STR);
#endif
#endif #endif
ui.reset_status(); ui.reset_status();
@ -105,9 +101,7 @@ void GcodeSuite::M25() {
ui.reset_status(); ui.reset_status();
#if ENABLED(HOST_ACTION_COMMANDS) #if ENABLED(HOST_ACTION_COMMANDS)
#if ENABLED(HOST_PROMPT_SUPPORT) TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume")));
host_prompt_open(PROMPT_PAUSE_RESUME, PSTR("Pause SD"), PSTR("Resume"));
#endif
#ifdef ACTION_ON_PAUSE #ifdef ACTION_ON_PAUSE
host_action_pause(); host_action_pause();
#endif #endif

View file

@ -87,9 +87,7 @@ void GcodeSuite::M104() {
#endif #endif
} }
#if ENABLED(AUTOTEMP) TERN_(AUTOTEMP, planner.autotemp_M104_M109());
planner.autotemp_M104_M109();
#endif
} }
/** /**
@ -139,9 +137,7 @@ void GcodeSuite::M109() {
#endif #endif
} }
#if ENABLED(AUTOTEMP) TERN_(AUTOTEMP, planner.autotemp_M104_M109());
planner.autotemp_M104_M109();
#endif
if (set_temp) if (set_temp)
(void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling); (void)thermalManager.wait_for_hotend(target_extruder, no_wait_for_cooling);

View file

@ -76,9 +76,7 @@ void GcodeSuite::M190() {
const bool no_wait_for_cooling = parser.seenval('S'); const bool no_wait_for_cooling = parser.seenval('S');
if (no_wait_for_cooling || parser.seenval('R')) { if (no_wait_for_cooling || parser.seenval('R')) {
thermalManager.setTargetBed(parser.value_celsius()); thermalManager.setTargetBed(parser.value_celsius());
#if ENABLED(PRINTJOB_TIMER_AUTOSTART) TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.check_timer_autostart(true, false));
thermalManager.check_timer_autostart(true, false);
#endif
} }
else return; else return;

View file

@ -75,9 +75,7 @@ void GcodeSuite::M191() {
const bool no_wait_for_cooling = parser.seenval('S'); const bool no_wait_for_cooling = parser.seenval('S');
if (no_wait_for_cooling || parser.seenval('R')) { if (no_wait_for_cooling || parser.seenval('R')) {
thermalManager.setTargetChamber(parser.value_celsius()); thermalManager.setTargetChamber(parser.value_celsius());
#if ENABLED(PRINTJOB_TIMER_AUTOSTART) TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.check_timer_autostart(true, false));
thermalManager.check_timer_autostart(true, false);
#endif
} }
else return; else return;

View file

@ -72,9 +72,7 @@ void GcodeSuite::M303() {
const heater_ind_t e = (heater_ind_t)parser.intval('E'); const heater_ind_t e = (heater_ind_t)parser.intval('E');
if (!WITHIN(e, SI, EI)) { if (!WITHIN(e, SI, EI)) {
SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM); SERIAL_ECHOLNPGM(STR_PID_BAD_EXTRUDER_NUM);
#if ENABLED(EXTENSIBLE_UI) TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM));
ExtUI::onPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM);
#endif
return; return;
} }

View file

@ -431,7 +431,9 @@
#elif ENABLED(MIXING_EXTRUDER) #elif ENABLED(MIXING_EXTRUDER)
#define E_STEPPERS MIXING_STEPPERS #define E_STEPPERS MIXING_STEPPERS
#define E_MANUAL 1 #define E_MANUAL 1
#define DUAL_MIXING_EXTRUDER (MIXING_STEPPERS == 2) #if MIXING_STEPPERS == 2
#define HAS_DUAL_MIXING 1
#endif
#elif ENABLED(SWITCHING_TOOLHEAD) #elif ENABLED(SWITCHING_TOOLHEAD)
#define E_STEPPERS EXTRUDERS #define E_STEPPERS EXTRUDERS
#define E_MANUAL EXTRUDERS #define E_MANUAL EXTRUDERS

View file

@ -399,7 +399,9 @@
#define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n)) #define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n))
#define HAS_USER_THERMISTORS ANY_TEMP_SENSOR_IS(1000) #if ANY_TEMP_SENSOR_IS(1000)
#define HAS_USER_THERMISTORS 1
#endif
#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2 #if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2
#define HEATER_0_USES_MAX6675 #define HEATER_0_USES_MAX6675
@ -1269,7 +1271,7 @@
#define HAS_X_STEP 1 #define HAS_X_STEP 1
#endif #endif
#if PIN_EXISTS(X_MS1) #if PIN_EXISTS(X_MS1)
#define HAS_X_MICROSTEPS 1 #define HAS_X_MS_PINS 1
#endif #endif
#if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2)) #if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2))
@ -1282,7 +1284,7 @@
#define HAS_X2_STEP 1 #define HAS_X2_STEP 1
#endif #endif
#if PIN_EXISTS(X2_MS1) #if PIN_EXISTS(X2_MS1)
#define HAS_X2_MICROSTEPS 1 #define HAS_X2_MS_PINS 1
#endif #endif
#if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y)) #if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y))
@ -1295,7 +1297,7 @@
#define HAS_Y_STEP 1 #define HAS_Y_STEP 1
#endif #endif
#if PIN_EXISTS(Y_MS1) #if PIN_EXISTS(Y_MS1)
#define HAS_Y_MICROSTEPS 1 #define HAS_Y_MS_PINS 1
#endif #endif
#if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2)) #if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2))
@ -1308,7 +1310,7 @@
#define HAS_Y2_STEP 1 #define HAS_Y2_STEP 1
#endif #endif
#if PIN_EXISTS(Y2_MS1) #if PIN_EXISTS(Y2_MS1)
#define HAS_Y2_MICROSTEPS 1 #define HAS_Y2_MS_PINS 1
#endif #endif
#if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z)) #if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z))
@ -1321,7 +1323,7 @@
#define HAS_Z_STEP 1 #define HAS_Z_STEP 1
#endif #endif
#if PIN_EXISTS(Z_MS1) #if PIN_EXISTS(Z_MS1)
#define HAS_Z_MICROSTEPS 1 #define HAS_Z_MS_PINS 1
#endif #endif
#if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)) #if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2))
@ -1334,7 +1336,7 @@
#define HAS_Z2_STEP 1 #define HAS_Z2_STEP 1
#endif #endif
#if PIN_EXISTS(Z2_MS1) #if PIN_EXISTS(Z2_MS1)
#define HAS_Z2_MICROSTEPS 1 #define HAS_Z2_MS_PINS 1
#endif #endif
#if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3)) #if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3))
@ -1347,7 +1349,7 @@
#define HAS_Z3_STEP 1 #define HAS_Z3_STEP 1
#endif #endif
#if PIN_EXISTS(Z3_MS1) #if PIN_EXISTS(Z3_MS1)
#define HAS_Z3_MICROSTEPS 1 #define HAS_Z3_MS_PINS 1
#endif #endif
#if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4)) #if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4))
@ -1360,7 +1362,7 @@
#define HAS_Z4_STEP 1 #define HAS_Z4_STEP 1
#endif #endif
#if PIN_EXISTS(Z4_MS1) #if PIN_EXISTS(Z4_MS1)
#define HAS_Z4_MICROSTEPS 1 #define HAS_Z4_MS_PINS 1
#endif #endif
// Extruder steppers and solenoids // Extruder steppers and solenoids
@ -1374,7 +1376,7 @@
#define HAS_E0_STEP 1 #define HAS_E0_STEP 1
#endif #endif
#if PIN_EXISTS(E0_MS1) #if PIN_EXISTS(E0_MS1)
#define HAS_E0_MICROSTEPS 1 #define HAS_E0_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL0) #if PIN_EXISTS(SOL0)
#define HAS_SOLENOID_0 1 #define HAS_SOLENOID_0 1
@ -1390,7 +1392,7 @@
#define HAS_E1_STEP 1 #define HAS_E1_STEP 1
#endif #endif
#if PIN_EXISTS(E1_MS1) #if PIN_EXISTS(E1_MS1)
#define HAS_E1_MICROSTEPS 1 #define HAS_E1_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL1) #if PIN_EXISTS(SOL1)
#define HAS_SOLENOID_1 1 #define HAS_SOLENOID_1 1
@ -1406,7 +1408,7 @@
#define HAS_E2_STEP 1 #define HAS_E2_STEP 1
#endif #endif
#if PIN_EXISTS(E2_MS1) #if PIN_EXISTS(E2_MS1)
#define HAS_E2_MICROSTEPS 1 #define HAS_E2_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL2) #if PIN_EXISTS(SOL2)
#define HAS_SOLENOID_2 1 #define HAS_SOLENOID_2 1
@ -1422,7 +1424,7 @@
#define HAS_E3_STEP 1 #define HAS_E3_STEP 1
#endif #endif
#if PIN_EXISTS(E3_MS1) #if PIN_EXISTS(E3_MS1)
#define HAS_E3_MICROSTEPS 1 #define HAS_E3_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL3) #if PIN_EXISTS(SOL3)
#define HAS_SOLENOID_3 1 #define HAS_SOLENOID_3 1
@ -1438,7 +1440,7 @@
#define HAS_E4_STEP 1 #define HAS_E4_STEP 1
#endif #endif
#if PIN_EXISTS(E4_MS1) #if PIN_EXISTS(E4_MS1)
#define HAS_E4_MICROSTEPS 1 #define HAS_E4_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL4) #if PIN_EXISTS(SOL4)
#define HAS_SOLENOID_4 1 #define HAS_SOLENOID_4 1
@ -1454,7 +1456,7 @@
#define HAS_E5_STEP 1 #define HAS_E5_STEP 1
#endif #endif
#if PIN_EXISTS(E5_MS1) #if PIN_EXISTS(E5_MS1)
#define HAS_E5_MICROSTEPS 1 #define HAS_E5_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL5) #if PIN_EXISTS(SOL5)
#define HAS_SOLENOID_5 1 #define HAS_SOLENOID_5 1
@ -1470,7 +1472,7 @@
#define HAS_E6_STEP 1 #define HAS_E6_STEP 1
#endif #endif
#if PIN_EXISTS(E6_MS1) #if PIN_EXISTS(E6_MS1)
#define HAS_E6_MICROSTEPS 1 #define HAS_E6_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL6) #if PIN_EXISTS(SOL6)
#define HAS_SOLENOID_6 1 #define HAS_SOLENOID_6 1
@ -1486,13 +1488,16 @@
#define HAS_E7_STEP 1 #define HAS_E7_STEP 1
#endif #endif
#if PIN_EXISTS(E7_MS1) #if PIN_EXISTS(E7_MS1)
#define HAS_E7_MICROSTEPS 1 #define HAS_E7_MS_PINS 1
#endif #endif
#if PIN_EXISTS(SOL7) #if PIN_EXISTS(SOL7)
#define HAS_SOLENOID_7 1 #define HAS_SOLENOID_7 1
#endif #endif
//
// Trinamic Stepper Drivers // Trinamic Stepper Drivers
//
#if HAS_TRINAMIC_CONFIG #if HAS_TRINAMIC_CONFIG
#if ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E) #if ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E)
#define STEALTHCHOP_ENABLED 1 #define STEALTHCHOP_ENABLED 1
@ -1535,10 +1540,15 @@
#endif #endif
#endif #endif
#define HAS_E_STEPPER_ENABLE (HAS_E_DRIVER(TMC2660) \ #if (HAS_E_DRIVER(TMC2660) \
|| ( E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != X_ENABLE_PIN \ || ( E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != X_ENABLE_PIN \
&& E0_ENABLE_PIN != Y_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN ) \ && E0_ENABLE_PIN != Y_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN ) )
) #define HAS_E_STEPPER_ENABLE 1
#endif
#if ANY_AXIS_HAS(SW_SERIAL)
#define HAS_TMC_SW_SERIAL 1
#endif
// //
// Endstops and bed probe // Endstops and bed probe
@ -1767,24 +1777,31 @@
#define HAS_AUTO_CHAMBER_FAN 1 #define HAS_AUTO_CHAMBER_FAN 1
#endif #endif
#define HAS_AUTO_FAN (HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3 || HAS_AUTO_FAN_4 || HAS_AUTO_FAN_5 || HAS_AUTO_FAN_6 || HAS_AUTO_FAN_7 || HAS_AUTO_CHAMBER_FAN) #if HAS_AUTO_FAN_0 || HAS_AUTO_FAN_1 || HAS_AUTO_FAN_2 || HAS_AUTO_FAN_3 || HAS_AUTO_FAN_4 || HAS_AUTO_FAN_5 || HAS_AUTO_FAN_6 || HAS_AUTO_FAN_7 || HAS_AUTO_CHAMBER_FAN
#define HAS_AUTO_FAN 1
#endif
#define _FANOVERLAP(A,B) (A##_AUTO_FAN_PIN == E##B##_AUTO_FAN_PIN) #define _FANOVERLAP(A,B) (A##_AUTO_FAN_PIN == E##B##_AUTO_FAN_PIN)
#if HAS_AUTO_FAN #if HAS_AUTO_FAN && (_FANOVERLAP(CHAMBER,0) || _FANOVERLAP(CHAMBER,1) || _FANOVERLAP(CHAMBER,2) || _FANOVERLAP(CHAMBER,3) || _FANOVERLAP(CHAMBER,4) || _FANOVERLAP(CHAMBER,5) || _FANOVERLAP(CHAMBER,6) || _FANOVERLAP(CHAMBER,7))
#define AUTO_CHAMBER_IS_E (_FANOVERLAP(CHAMBER,0) || _FANOVERLAP(CHAMBER,1) || _FANOVERLAP(CHAMBER,2) || _FANOVERLAP(CHAMBER,3) || _FANOVERLAP(CHAMBER,4) || _FANOVERLAP(CHAMBER,5) || _FANOVERLAP(CHAMBER,6) || _FANOVERLAP(CHAMBER,7)) #define AUTO_CHAMBER_IS_E 1
#endif #endif
#if !HAS_TEMP_SENSOR #if !HAS_TEMP_SENSOR
#undef AUTO_REPORT_TEMPERATURES #undef AUTO_REPORT_TEMPERATURES
#endif #endif
#define HAS_AUTO_REPORTING EITHER(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS) #if EITHER(AUTO_REPORT_TEMPERATURES, AUTO_REPORT_SD_STATUS)
#define HAS_AUTO_REPORTING 1
#endif
#if !HAS_AUTO_CHAMBER_FAN || AUTO_CHAMBER_IS_E #if !HAS_AUTO_CHAMBER_FAN || AUTO_CHAMBER_IS_E
#undef AUTO_POWER_CHAMBER_FAN #undef AUTO_POWER_CHAMBER_FAN
#endif #endif
// Other fans // Other fans
#define HAS_FAN0 (PIN_EXISTS(FAN)) #if PIN_EXISTS(FAN)
#define _HAS_FAN(P) (PIN_EXISTS(FAN##P) && CONTROLLER_FAN_PIN != FAN##P##_PIN && E0_AUTO_FAN_PIN != FAN##P##_PIN && E1_AUTO_FAN_PIN != FAN##P##_PIN && E2_AUTO_FAN_PIN != FAN##P##_PIN && E3_AUTO_FAN_PIN != FAN##P##_PIN && E4_AUTO_FAN_PIN != FAN##P##_PIN && E5_AUTO_FAN_PIN != FAN##P##_PIN && E6_AUTO_FAN_PIN != FAN##P##_PIN && E7_AUTO_FAN_PIN != FAN##P##_PIN) #define HAS_FAN0 1
#endif
#define _NOT_E_AUTO(N,F) (E##N##_AUTO_FAN_PIN != FAN##F##_PIN)
#define _HAS_FAN(F) (PIN_EXISTS(FAN##F) && CONTROLLER_FAN_PIN != FAN##F##_PIN && _NOT_E_AUTO(0,F) && _NOT_E_AUTO(1,F) && _NOT_E_AUTO(2,F) && _NOT_E_AUTO(3,F) && _NOT_E_AUTO(4,F) && _NOT_E_AUTO(5,F) && _NOT_E_AUTO(6,F) && _NOT_E_AUTO(7,F))
#if _HAS_FAN(1) #if _HAS_FAN(1)
#define HAS_FAN1 1 #define HAS_FAN1 1
#endif #endif
@ -1806,6 +1823,8 @@
#if _HAS_FAN(7) #if _HAS_FAN(7)
#define HAS_FAN7 1 #define HAS_FAN7 1
#endif #endif
#undef _NOT_E_AUTO
#undef _HAS_FAN
#if PIN_EXISTS(CONTROLLER_FAN) #if PIN_EXISTS(CONTROLLER_FAN)
#define HAS_CONTROLLER_FAN 1 #define HAS_CONTROLLER_FAN 1
#endif #endif
@ -1866,13 +1885,13 @@
#define HAS_MOTOR_CURRENT_PWM 1 #define HAS_MOTOR_CURRENT_PWM 1
#endif #endif
#if HAS_Z_MICROSTEPS || HAS_Z2_MICROSTEPS || HAS_Z3_MICROSTEPS || HAS_Z4_MICROSTEPS #if HAS_Z_MS_PINS || HAS_Z2_MS_PINS || HAS_Z3_MS_PINS || HAS_Z4_MS_PINS
#define HAS_SOME_Z_MICROSTEPS 1 #define HAS_SOME_Z_MS_PINS 1
#endif #endif
#if HAS_E0_MICROSTEPS || HAS_E1_MICROSTEPS || HAS_E2_MICROSTEPS || HAS_E3_MICROSTEPS || HAS_E4_MICROSTEPS || HAS_E5_MICROSTEPS || HAS_E6_MICROSTEPS || HAS_E7_MICROSTEPS #if HAS_E0_MS_PINS || HAS_E1_MS_PINS || HAS_E2_MS_PINS || HAS_E3_MS_PINS || HAS_E4_MS_PINS || HAS_E5_MS_PINS || HAS_E6_MS_PINS || HAS_E7_MS_PINS
#define HAS_SOME_E_MICROSTEPS 1 #define HAS_SOME_E_MS_PINS 1
#endif #endif
#if HAS_X_MICROSTEPS || HAS_X2_MICROSTEPS || HAS_Y_MICROSTEPS || HAS_Y2_MICROSTEPS || HAS_SOME_Z_MICROSTEPS || HAS_SOME_E_MICROSTEPS #if HAS_X_MS_PINS || HAS_X2_MS_PINS || HAS_Y_MS_PINS || HAS_Y2_MS_PINS || HAS_SOME_Z_MICROSTEPS || HAS_SOME_E_MS_PINS
#define HAS_MICROSTEPS 1 #define HAS_MICROSTEPS 1
#endif #endif
@ -2071,7 +2090,9 @@
/** /**
* Part Cooling fan multipliexer * Part Cooling fan multipliexer
*/ */
#define HAS_FANMUX PIN_EXISTS(FANMUX0) #if PIN_EXISTS(FANMUX0)
#define HAS_FANMUX 1
#endif
/** /**
* MIN/MAX fan PWM scaling * MIN/MAX fan PWM scaling

Some files were not shown because too many files have changed in this diff Show more