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

View file

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

View file

@ -174,7 +174,7 @@
#define IS_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
// 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
#define extDigitalRead(IO) digitalRead(IO)

View file

@ -97,9 +97,7 @@ void HAL_init_board() {
esp3dlib.init();
#elif ENABLED(WIFISUPPORT)
wifi_init();
#if ENABLED(OTASUPPORT)
OTA_init();
#endif
TERN_(OTASUPPORT, OTA_init());
#if ENABLED(WEBSUPPORT)
spiffs_init();
web_init();
@ -133,9 +131,7 @@ void HAL_idletask() {
#if BOTH(WIFISUPPORT, OTASUPPORT)
OTA_handle();
#endif
#if ENABLED(ESP3D_WIFISUPPORT)
esp3dlib.idletask();
#endif
TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask());
}
void HAL_clear_reset_source() { }
@ -176,39 +172,17 @@ void HAL_adc_init() {
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
#if HAS_TEMP_ADC_0
adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_1
adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_2
adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db);
#endif
#if HAS_TEMP_ADC_3
adc1_set_attenuation(get_channel(TEMP_3_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
TERN_(HAS_TEMP_ADC_0, 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));
TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
// 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.

View file

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

View file

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

View file

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

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
for (;;) {
#if ENABLED(USE_WATCHDOG)
watchdog_init();
#endif
}
for (;;) { TERN_(USE_WATCHDOG, watchdog_init()); }
}
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 HAL_clear_reset_source(void) {
#if ENABLED(USE_WATCHDOG)
watchdog_clear_timeout_flag();
#endif
TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
}
uint8_t HAL_get_reset_source(void) {

View file

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

View file

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

View file

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

View file

@ -76,20 +76,18 @@ void HAL_init() {
#endif
#if ENABLED(SRAM_EEPROM_EMULATION)
// Enable access to backup SRAM
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWR_EnableBkUpAccess();
HAL_PWR_EnableBkUpAccess(); // Enable access to backup SRAM
__HAL_RCC_BKPSRAM_CLK_ENABLE();
// Enable backup regulator
LL_PWR_EnableBkUpRegulator();
// Wait until backup regulator is initialized
while (!LL_PWR_IsActiveFlag_BRR());
LL_PWR_EnableBkUpRegulator(); // Enable backup regulator
while (!LL_PWR_IsActiveFlag_BRR()); // Wait until backup regulator is initialized
#endif
#if HAS_TMC_SW_SERIAL
SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
#endif
TERN_(HAS_TMC_SW_SERIAL, SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0));
}
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
}
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() {
//init SDIO and get SD card info

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -57,21 +57,21 @@ void safe_delay(millis_t ms) {
void log_machine_info() {
SERIAL_ECHOLNPGM("Machine Type: "
TERN(DELTA, "Delta", "")
TERN(IS_SCARA, "SCARA", "")
TERN(IS_CORE, "Core", "")
TERN(IS_CARTESIAN, "Cartesian", "")
TERN_(DELTA, "Delta")
TERN_(IS_SCARA, "SCARA")
TERN_(IS_CORE, "Core")
TERN_(IS_CARTESIAN, "Cartesian")
);
SERIAL_ECHOLNPGM("Probe: "
TERN(PROBE_MANUALLY, "PROBE_MANUALLY", "")
TERN(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE", "")
TERN(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE", "")
TERN(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"), "")
TERN(TOUCH_MI_PROBE, "TOUCH_MI_PROBE", "")
TERN(Z_PROBE_SLED, "Z_PROBE_SLED", "")
TERN(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY", "")
TERN(SOLENOID_PROBE, "SOLENOID_PROBE", "")
TERN_(PROBE_MANUALLY, "PROBE_MANUALLY")
TERN_(NOZZLE_AS_PROBE, "NOZZLE_AS_PROBE")
TERN_(FIX_MOUNTED_PROBE, "FIX_MOUNTED_PROBE")
TERN_(HAS_Z_SERVO_PROBE, TERN(BLTOUCH, "BLTOUCH", "SERVO PROBE"))
TERN_(TOUCH_MI_PROBE, "TOUCH_MI_PROBE")
TERN_(Z_PROBE_SLED, "Z_PROBE_SLED")
TERN_(Z_PROBE_ALLEN_KEY, "Z_PROBE_ALLEN_KEY")
TERN_(SOLENOID_PROBE, "SOLENOID_PROBE")
TERN(PROBE_SELECTED, "", "NONE")
);
@ -108,10 +108,10 @@ void safe_delay(millis_t ms) {
#if HAS_ABL_OR_UBL
SERIAL_ECHOPGM("Auto Bed Leveling: "
TERN(AUTO_BED_LEVELING_LINEAR, "LINEAR", "")
TERN(AUTO_BED_LEVELING_BILINEAR, "BILINEAR", "")
TERN(AUTO_BED_LEVELING_3POINT, "3POINT", "")
TERN(AUTO_BED_LEVELING_UBL, "UBL", "")
TERN_(AUTO_BED_LEVELING_LINEAR, "LINEAR")
TERN_(AUTO_BED_LEVELING_BILINEAR, "BILINEAR")
TERN_(AUTO_BED_LEVELING_3POINT, "3POINT")
TERN_(AUTO_BED_LEVELING_UBL, "UBL")
);
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;
accum += distance; // Count up babysteps for the UI
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
axis_total[BS_TOTAL_IND(axis)] += distance;
#endif
TERN_(BABYSTEP_DISPLAY_TOTAL, axis_total[BS_TOTAL_IND(axis)] += distance);
#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)
@ -107,13 +105,10 @@ void Babystep::add_steps(const AxisEnum axis, const int16_t distance) {
#endif
steps[BS_AXIS_IND(axis)] += distance;
#endif
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
gcode.reset_stepper_timeout();
#endif
#if ENABLED(INTEGRATED_BABYSTEPPING)
if (has_steps()) stepper.initiateBabystepping();
#endif
TERN_(BABYSTEP_ALWAYS_AVAILABLE, gcode.reset_stepper_timeout());
TERN_(INTEGRATED_BABYSTEPPING, if (has_steps()) stepper.initiateBabystepping());
}
#endif // BABYSTEPPING

View file

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

View file

@ -55,26 +55,16 @@ public:
static inline float get_measurement(const AxisEnum a) {
// Return the measurement averaged over all readings
return (
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
measured_count[a] > 0 ? measured_mm[a] / measured_count[a] :
#endif
0
return TERN(MEASURE_BACKLASH_WHEN_PROBING
, measured_count[a] > 0 ? measured_mm[a] / measured_count[a] : 0
, 0
);
#if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
UNUSED(a);
#endif
TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
}
static inline bool has_measurement(const AxisEnum a) {
return (false
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|| (measured_count[a] > 0)
#endif
);
#if DISABLED(MEASURE_BACKLASH_WHEN_PROBING)
UNUSED(a);
#endif
return TERN0(MEASURE_BACKLASH_WHEN_PROBING, measured_count[a] > 0);
TERN(MEASURE_BACKLASH_WHEN_PROBING,,UNUSED(a));
}
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
z_values[x][y] = (a + b + c) / 3.0;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
// Median is robust (ignores outliers).
// 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
void refresh_bed_level() {
bilinear_grid_factor = bilinear_grid_spacing.reciprocal();
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
bed_level_virt_interpolate();
#endif
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
}
#if ENABLED(ABL_BILINEAR_SUBDIVISION)

View file

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

View file

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

View file

@ -305,17 +305,13 @@
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');
#if HOTENDS > 1
const uint8_t old_tool_index = active_extruder;
#endif
TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder);
// Check for commands that require the printer to be homed
if (may_move) {
planner.synchronize();
if (axes_need_homing()) gcode.home_all_axes();
#if HOTENDS > 1
if (active_extruder != 0) tool_change(0);
#endif
TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
}
// Invalidate Mesh Points. This command is a little bit asymmetrical because
@ -340,9 +336,7 @@
break; // No more invalid Mesh Points to populate
}
z_values[cpos.x][cpos.y] = NAN;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(cpos, 0.0f);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, 0.0f));
cnt++;
}
}
@ -369,9 +363,7 @@
const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
z_values[x][y] += 2.0f * HYPOT(p1, p2);
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
}
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 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;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
}
break;
}
@ -540,9 +530,7 @@
}
else {
z_values[cpos.x][cpos.y] = g29_constant;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(cpos, g29_constant);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(cpos, g29_constant));
}
}
}
@ -683,9 +671,7 @@
UNUSED(probe_deployed);
#endif
#if HOTENDS > 1
tool_change(old_tool_index);
#endif
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
return;
}
@ -718,9 +704,7 @@
GRID_LOOP(x, y)
if (!isnan(z_values[x][y])) {
z_values[x][y] -= mean + value;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
}
}
@ -728,9 +712,7 @@
GRID_LOOP(x, y)
if (!isnan(z_values[x][y])) {
z_values[x][y] += g29_constant;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
}
}
@ -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) {
probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
#if HAS_LCD_MENU
ui.capture();
#endif
TERN_(HAS_LCD_MENU, ui.capture());
save_ubl_active_state_and_disable(); // No bed level correction so only raw data is obtained
uint8_t count = GRID_MAX_POINTS;
@ -755,9 +735,7 @@
const int point_num = (GRID_MAX_POINTS) - count + 1;
SERIAL_ECHOLNPAIR("\nProbing mesh point ", point_num, "/", int(GRID_MAX_POINTS), ".\n");
#if HAS_DISPLAY
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS));
#endif
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), point_num, int(GRID_MAX_POINTS)));
#if HAS_LCD_MENU
if (ui.button_pressed()) {
@ -776,9 +754,7 @@
: find_closest_mesh_point_of_type(INVALID, near, true);
if (best.pos.x >= 0) { // mesh point found and is reachable by probe
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::PROBE_START));
const float measured_z = probe.probe_at_point(
best.meshpos(),
stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level
@ -793,13 +769,10 @@
} while (best.pos.x >= 0 && --count);
#if HAS_LCD_MENU
ui.release();
#endif
probe.stow(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
#if HAS_LCD_MENU
ui.capture();
#endif
// Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
TERN_(HAS_LCD_MENU, ui.release());
probe.stow();
TERN_(HAS_LCD_MENU, ui.capture());
#ifdef 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."); }
float unified_bed_leveling::measure_business_card_thickness(float in_height) {
#if HAS_LCD_MENU
ui.capture();
#endif
TERN_(HAS_LCD_MENU, ui.capture());
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);
@ -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) {
#if HAS_LCD_MENU
ui.capture();
#endif
TERN_(HAS_LCD_MENU, ui.capture());
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);
@ -929,9 +898,7 @@
do_blocking_move_to_z(z_clearance);
KEEPALIVE_STATE(PAUSED_FOR_USER);
#if HAS_LCD_MENU
ui.capture();
#endif
TERN_(HAS_LCD_MENU, ui.capture());
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;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(location, z_values[lpos.x][lpos.y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, z_values[lpos.x][lpos.y]));
if (g29_verbose_level > 2)
SERIAL_ECHOLNPAIR_F("Mesh Point Measured at: ", z_values[lpos.x][lpos.y], 6);
@ -998,14 +963,11 @@
save_ubl_active_state_and_disable();
LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
#if HAS_LCD_MENU
ui.capture(); // Take over control of the LCD encoder
#endif
TERN_(HAS_LCD_MENU, ui.capture()); // Take over control of the LCD encoder
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)
do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset
#endif
TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset)); // Move Z to the given 'H' offset
MeshFlags done_flags{0};
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
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
do_blocking_move_to_z(h_offset); // Move Z to the given 'H' offset before editing
#endif
TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset)); // Move Z to the given 'H' offset before editing
KEEPALIVE_STATE(PAUSED_FOR_USER);
@ -1044,9 +1004,7 @@
do {
new_z = lcd_mesh_edit();
#if ENABLED(UBL_MESH_EDIT_MOVES_Z)
do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
#endif
TERN_(UBL_MESH_EDIT_MOVES_Z, do_blocking_move_to_z(h_offset + new_z)); // Move the nozzle as the point is edited
idle();
SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
} while (!ui.button_pressed());
@ -1056,9 +1014,7 @@
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
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(location, new_z);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(location, new_z));
serial_delay(20); // No switch noise
ui.refresh();
@ -1086,9 +1042,7 @@
bool unified_bed_leveling::g29_parameter_parsing() {
bool err_flag = false;
#if HAS_LCD_MENU
set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29));
#endif
TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_DOING_G29)));
g29_constant = 0;
g29_repetition_cnt = 0;
@ -1210,9 +1164,7 @@
ubl_state_recursion_chk++;
if (ubl_state_recursion_chk != 1) {
SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
#if HAS_LCD_MENU
set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR));
#endif
TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_SAVE_ERROR)));
return;
}
#endif
@ -1224,9 +1176,7 @@
#if ENABLED(UBL_DEVEL_DEBUGGING)
if (--ubl_state_recursion_chk) {
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
#if HAS_LCD_MENU
set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR));
#endif
TERN_(HAS_LCD_MENU, set_message_with_feedback(GET_TEXT(MSG_UBL_RESTORE_ERROR)));
return;
}
#endif
@ -1341,9 +1291,7 @@
const float v2 = z_values[dx + xdir][dy + ydir];
if (!isnan(v2)) {
z_values[x][y] = v1 < v2 ? v1 : v1 + v1 - v2;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
return true;
}
}
@ -1407,9 +1355,7 @@
if (do_3_pt_leveling) {
SERIAL_ECHOLNPGM("Tilting mesh (1/3)");
#if HAS_DISPLAY
ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level);
if (isnan(measured_z))
@ -1428,9 +1374,7 @@
if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (2/3)");
#if HAS_DISPLAY
ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level);
#ifdef VALIDATE_MESH_TILT
@ -1450,9 +1394,7 @@
if (!abort_flag) {
SERIAL_ECHOLNPGM("Tilting mesh (3/3)");
#if HAS_DISPLAY
ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
#endif
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH)));
measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level);
#ifdef VALIDATE_MESH_TILT
@ -1495,9 +1437,7 @@
if (!abort_flag) {
SERIAL_ECHOLNPAIR("Tilting mesh point ", point_num, "/", total_points, "\n");
#if HAS_DISPLAY
ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points);
#endif
TERN_(HAS_DISPLAY, ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
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;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(i, j, z_values[i][j]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, z_values[i][j]));
}
if (DEBUGGING(LEVELING)) {
@ -1684,9 +1622,7 @@
}
const float ez = -lsf_results.D - lsf_results.A * ppos.x - lsf_results.B * ppos.y;
z_values[ix][iy] = ez;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(ix, iy, z_values[ix][iy]));
idle(); // housekeeping
}
}
@ -1826,9 +1762,7 @@
GRID_LOOP(x, y) {
z_values[x][y] -= tmp_z_values[x][y];
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
}
}

View file

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

View file

@ -124,9 +124,7 @@ bool BLTouch::deploy_proc() {
}
// One of the recommended ANTClabs ways to probe, using SW MODE
#if ENABLED(BLTOUCH_FORCE_SW_MODE)
_set_SW_mode();
#endif
TERN_(BLTOUCH_FORCE_SW_MODE, _set_SW_mode());
// 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

View file

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

View file

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

View file

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

View file

@ -60,9 +60,7 @@ float FWRetract::current_retract[EXTRUDERS], // Retract value used by p
FWRetract::current_hop;
void FWRetract::reset() {
#if ENABLED(FWRETRACT_AUTORETRACT)
autoretract_enabled = false;
#endif
TERN_(FWRETRACT_AUTORETRACT, autoretract_enabled = false);
settings.retract_length = RETRACT_LENGTH;
settings.retract_feedrate_mm_s = RETRACT_FEEDRATE;
settings.retract_zraise = RETRACT_ZRAISE;
@ -128,7 +126,7 @@ void FWRetract::retract(const bool retracting
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);
// 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
current_retract[active_extruder] = base_retract;
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?
@ -170,9 +168,11 @@ void FWRetract::retract(const bool retracting
current_retract[active_extruder] = 0;
const feedRate_t fr_mm_s = TERN(RETRACT_SYNC_MIXING, MIXING_STEPPERS, 1)
* (swapping ? settings.swap_retract_recover_feedrate_mm_s : settings.retract_recover_feedrate_mm_s);
prepare_internal_move_to_destination(fr_mm_s); // Recover E, set_current_to_destination
// Recover E, set_current_to_destination
prepare_internal_move_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

View file

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

View file

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

View file

@ -35,19 +35,11 @@
class Joystick {
friend class Temperature;
private:
#if HAS_JOY_ADC_X
static temp_info_t x;
#endif
#if HAS_JOY_ADC_Y
static temp_info_t y;
#endif
#if HAS_JOY_ADC_Z
static temp_info_t z;
#endif
TERN_(HAS_JOY_ADC_X, static temp_info_t x);
TERN_(HAS_JOY_ADC_Y, static temp_info_t y);
TERN_(HAS_JOY_ADC_Z, static temp_info_t z);
public:
#if ENABLED(JOYSTICK_DEBUG)
static void report();
#endif
TERN_(JOYSTICK_DEBUG, static void report());
static void calculate(xyz_float_t &norm_jog);
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);
#endif
#endif
#if ENABLED(NEOPIXEL_LED)
neo.init();
#endif
#if ENABLED(PCA9533)
PCA9533_init();
#endif
#if ENABLED(LED_USER_PRESET_STARTUP)
set_default();
#endif
TERN_(NEOPIXEL_LED, neo.init());
TERN_(PCA9533, PCA9533_init());
TERN_(LED_USER_PRESET_STARTUP, set_default());
}
void LEDLights::set_color(const LEDColor &incol
@ -140,9 +134,7 @@ void LEDLights::set_color(const LEDColor &incol
pca9632_set_led_color(incol);
#endif
#if ENABLED(PCA9533)
PCA9533_setColor(incol.r, incol.g, incol.b);
#endif
TERN_(PCA9533, PCA9533_setColor(incol.r, incol.g, incol.b));
#if EITHER(LED_CONTROL_MENU, PRINTER_EVENT_LEDS)
// Don't update the color when OFF

View file

@ -34,7 +34,9 @@
#endif
// 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
@ -85,9 +87,7 @@ typedef struct LEDColor {
LEDColor& operator=(const uint8_t (&rgbw)[4]) {
r = rgbw[0]; g = rgbw[1]; b = rgbw[2];
#if HAS_WHITE_LED
w = rgbw[3];
#endif
TERN_(HAS_WHITE_LED, w = rgbw[3]);
return *this;
}

View file

@ -38,10 +38,15 @@
// 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)
#define NEOPIXEL_IS_RGBW !NEOPIXEL_IS_RGB
#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_RGB 1
#else
#define NEOPIXEL_IS_RGBW 1
#endif
#if NEOPIXEL_IS_RGB
#define NEO_WHITE 255, 255, 255, 0
@ -73,23 +78,17 @@ public:
static inline void begin() {
adaneo1.begin();
#if MULTIPLE_NEOPIXEL_TYPES
adaneo2.begin();
#endif
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.begin());
}
static inline void set_pixel_color(const uint16_t n, const uint32_t c) {
adaneo1.setPixelColor(n, c);
#if MULTIPLE_NEOPIXEL_TYPES
adaneo2.setPixelColor(n, c);
#endif
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setPixelColor(n, c));
}
static inline void set_brightness(const uint8_t b) {
adaneo1.setBrightness(b);
#if MULTIPLE_NEOPIXEL_TYPES
adaneo2.setBrightness(b);
#endif
TERN_(MULTIPLE_NEOPIXEL_TYPES, adaneo2.setBrightness(b));
}
static inline void show() {

View file

@ -36,10 +36,7 @@ void handle_status_leds() {
static millis_t next_status_led_update_ms = 0;
if (ELAPSED(millis(), next_status_led_update_ms)) {
next_status_led_update_ms += 500; // Update every 0.5s
float max_temp = 0.0;
#if HAS_HEATED_BED
max_temp = _MAX(thermalManager.degTargetBed(), thermalManager.degBed());
#endif
float max_temp = TERN0(HAS_HEATED_BED, _MAX(thermalManager.degTargetBed(), thermalManager.degBed()));
HOTEND_LOOP()
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;

View file

@ -44,7 +44,7 @@ int_fast8_t Mixer::runner = 0;
mixer_comp_t Mixer::s_color[MIXING_STEPPERS];
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];
#endif
@ -90,9 +90,7 @@ void Mixer::normalize(const uint8_t tool_index) {
SERIAL_ECHOLNPGM("]");
#endif
#if ENABLED(GRADIENT_MIX)
refresh_gradient();
#endif
TERN_(GRADIENT_MIX, refresh_gradient());
}
void Mixer::reset_vtools() {
@ -123,13 +121,11 @@ void Mixer::init() {
ZERO(collector);
#if DUAL_MIXING_EXTRUDER || ENABLED(GRADIENT_MIX)
#if EITHER(HAS_DUAL_MIXING, GRADIENT_MIX)
update_mix_from_vtool();
#endif
#if ENABLED(GRADIENT_MIX)
update_gradient_for_planner_z();
#endif
TERN_(GRADIENT_MIX, update_gradient_for_planner_z());
}
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
#ifndef __AVR__ // || DUAL_MIXING_EXTRUDER
#ifndef __AVR__ // || HAS_DUAL_MIXING
// Use 16-bit (or fastest) data for the integer mix factors
typedef uint_fast16_t mixer_comp_t;
typedef uint_fast16_t mixer_accu_t;
@ -48,14 +48,14 @@ typedef int8_t mixer_perc_t;
#endif
enum MixTool {
FIRST_USER_VIRTUAL_TOOL = 0,
LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1,
NR_USER_VIRTUAL_TOOLS,
MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS,
FIRST_USER_VIRTUAL_TOOL = 0
, LAST_USER_VIRTUAL_TOOL = MIXING_VIRTUAL_TOOLS - 1
, NR_USER_VIRTUAL_TOOLS
, MIXER_DIRECT_SET_TOOL = NR_USER_VIRTUAL_TOOLS
#if HAS_MIXER_SYNC_CHANNEL
MIXER_AUTORETRACT_TOOL,
, MIXER_AUTORETRACT_TOOL
#endif
NR_MIXING_VIRTUAL_TOOLS
, NR_MIXING_VIRTUAL_TOOLS
};
#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
mixer_perc_t start_mix[MIXING_STEPPERS], // Start and end mixes from those tools
end_mix[MIXING_STEPPERS];
#if ENABLED(GRADIENT_VTOOL)
int8_t vtool_index; // Use this virtual tool number as index
#endif
TERN_(GRADIENT_VTOOL, int8_t vtool_index); // Use this virtual tool number as index
} gradient_t;
#endif
@ -106,12 +104,8 @@ class Mixer {
FORCE_INLINE static void T(const uint_fast8_t c) {
selected_vtool = c;
#if ENABLED(GRADIENT_VTOOL)
refresh_gradient();
#endif
#if DUAL_MIXING_EXTRUDER
update_mix_from_vtool();
#endif
TERN_(GRADIENT_VTOOL, refresh_gradient());
TERN_(HAS_DUAL_MIXING, update_mix_from_vtool());
}
// Used when dealing with blocks
@ -129,7 +123,7 @@ class Mixer {
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
@ -167,21 +161,19 @@ class Mixer {
#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
static inline void update_vtool_from_mix() {
copy_mix_to_color(color[selected_vtool]);
#if ENABLED(GRADIENT_MIX)
refresh_gradient();
#endif
TERN_(GRADIENT_MIX, refresh_gradient());
// MIXER_STEPPER_LOOP(i) collector[i] = mix[i];
// normalize();
}
#endif // DUAL_MIXING_EXTRUDER
#endif // HAS_DUAL_MIXING
#if ENABLED(GRADIENT_MIX)

View file

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

View file

@ -86,9 +86,7 @@ fil_change_settings_t fc_settings[EXTRUDERS];
#if HAS_BUZZER
static void filament_change_beep(const int8_t max_beep_count, const bool init=false) {
#if HAS_LCD_MENU
if (pause_mode == PAUSE_MODE_PAUSE_PRINT) return;
#endif
if (TERN0(HAS_LCD_MENU, pause_mode == PAUSE_MODE_PAUSE_PRINT)) return;
static millis_t next_buzz = 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_show();
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("Load Filament"));
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament")));
while (wait_for_user) {
#if HAS_BUZZER
filament_change_beep(max_beep_count);
#endif
TERN_(HAS_BUZZER, filament_change_beep(max_beep_count));
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);
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR);
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging..."));
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging...")));
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)
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);
}
#if ENABLED(HOST_PROMPT_SUPPORT)
filament_load_host_prompt(); // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
#endif
TERN_(HOST_PROMPT_SUPPORT, filament_load_host_prompt()); // Initiate another host prompt. (NOTE: host_response_handler may also do this!)
#if HAS_LCD_MENU
if (show_lcd) {
@ -274,11 +262,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
#endif
// Keep looping if "Purge More" was selected
} while (false
#if HAS_LCD_MENU
|| (show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE)
#endif
);
} while (TERN0(HAS_LCD_MENU, show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE));
#endif
@ -384,9 +368,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float
#endif
#endif
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR);
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Pause"), DISMISS_STR));
if (!DEBUGGING(DRYRUN) && unload_length && thermalManager.targetTooColdToExtrude(active_extruder)) {
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) {
#if HAS_LCD_MENU
lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING);
#endif
TERN_(HAS_LCD_MENU, lcd_pause_show_message(is_reload ? PAUSE_MESSAGE_INSERT : PAUSE_MESSAGE_WAITING));
SERIAL_ECHO_START();
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
KEEPALIVE_STATE(PAUSED_FOR_USER);
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR);
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED));
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_NOZZLE_PARKED), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_NOZZLE_PARKED)));
wait_for_user = true; // LCD click or M108 will clear this
while (wait_for_user) {
#if HAS_BUZZER
filament_change_beep(max_beep_count);
#endif
TERN_(HAS_BUZZER, filament_change_beep(max_beep_count));
// If the nozzle has 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
// re-heat the nozzle, re-show the continue prompt, restart idle timers, start over
if (nozzle_timed_out) {
#if HAS_LCD_MENU
lcd_pause_show_message(PAUSE_MESSAGE_HEAT);
#endif
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_HEAT));
SERIAL_ECHO_MSG(_PMSG(STR_FILAMENT_CHANGE_HEAT));
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT));
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, GET_TEXT(MSG_HEATER_TIMEOUT), GET_TEXT(MSG_REHEAT)));
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT));
#endif
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_HEATER_TIMEOUT)));
wait_for_user_response(0, true); // Wait for LCD click or M108
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING));
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING));
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_INFO, GET_TEXT(MSG_REHEATING)));
TERN_(EXTENSIBLE_UI, ExtUI::onStatusChanged_P(GET_TEXT(MSG_REHEATING)));
// Re-enable the heaters if they timed out
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);
HOTEND_LOOP() thermalManager.hotend_idle[e].start(nozzle_timeout);
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR);
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished."));
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Reheat Done"), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Reheat finished.")));
wait_for_user = true;
nozzle_timed_out = false;
#if HAS_BUZZER
filament_change_beep(max_beep_count, true);
#endif
TERN_(HAS_BUZZER, filament_change_beep(max_beep_count, true));
}
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
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
lcd_pause_show_message(PAUSE_MESSAGE_RESUME);
#endif
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_RESUME));
// Intelligent resuming
#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
planner.set_e_position_mm((destination.e = current_position.e = resume_position.e));
#if HAS_LCD_MENU
lcd_pause_show_message(PAUSE_MESSAGE_STATUS);
#endif
TERN_(HAS_LCD_MENU, lcd_pause_show_message(PAUSE_MESSAGE_STATUS));
#ifdef ACTION_ON_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;
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR);
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_open(PROMPT_INFO, PSTR("Resuming"), DISMISS_STR));
#if ENABLED(SDSUPPORT)
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);
#endif
#if HAS_FILAMENT_SENSOR
runout.reset();
#endif
TERN_(HAS_FILAMENT_SENSOR, runout.reset());
// Resume the print job timer if it was running
if (print_job_timer.isPaused()) print_job_timer.start();
#if HAS_DISPLAY
ui.reset_status();
#if HAS_LCD_MENU
ui.return_to_status();
#endif
#endif
TERN_(HAS_DISPLAY, ui.reset_status());
TERN_(HAS_LCD_MENU, ui.return_to_status());
}
#endif // ADVANCED_PAUSE_FEATURE

View file

@ -50,15 +50,12 @@ bool Power::is_power_needed() {
if (controllerFan.state()) return true;
#endif
#if ENABLED(AUTO_POWER_CHAMBER_FAN)
if (thermalManager.chamberfan_speed) return true;
#endif
if (TERN0(AUTO_POWER_CHAMBER_FAN, thermalManager.chamberfan_speed))
return true;
// 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 HAS_HEATED_BED
|| thermalManager.temp_bed.soft_pwm_amount > 0
#endif
|| TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)
#if HAS_X2_ENABLE
|| X2_ENABLE_READ() == X_ENABLE_ON
#endif
@ -75,10 +72,7 @@ bool Power::is_power_needed() {
) return true;
HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true;
#if HAS_HEATED_BED
if (thermalManager.degTargetBed() > 0) return true;
#endif
if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0)) return true;
#if HOTENDS && AUTO_POWER_E_TEMP
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
info.current_position = current_position;
#if HAS_HOME_OFFSET
info.home_offset = home_offset;
#endif
#if HAS_POSITION_SHIFT
info.position_shift = position_shift;
#endif
TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
info.feedrate = uint16_t(feedrate_mm_s * 60.0f);
#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;
#endif
#if HAS_HEATED_BED
info.target_temperature_bed = thermalManager.temp_bed.target;
#endif
TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.temp_bed.target);
#if FAN_COUNT
COPY(info.fan_speed, thermalManager.fan_speed);
@ -207,18 +201,10 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
#if HAS_LEVELING
info.leveling = planner.leveling_active;
info.fade = (
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
planner.z_fade_height
#else
0
#endif
);
info.fade = TERN0(ENABLE_LEVELING_FADE_HEIGHT, planner.z_fade_height);
#endif
#if ENABLED(GRADIENT_MIX)
memcpy(&info.gradient, &mixer.gradient, sizeof(info.gradient));
#endif
TERN_(GRADIENT_MIX, memcpy(&info.gradient, &mixer.gradient, sizeof(info.gradient)));
#if ENABLED(FWRETRACT)
COPY(info.retract, fwretract.current_retract);
@ -244,9 +230,7 @@ void PrintJobRecovery::save(const bool force/*=false*/) {
lock = true;
#endif
if (IS_SD_PRINTING()) save(true);
#if ENABLED(BACKUP_POWER_SUPPLY)
raise_z();
#endif
TERN_(BACKUP_POWER_SUPPLY, raise_z());
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
"\n"
"G28R0"
#if ENABLED(MARLIN_DEV_MODE)
"S"
#endif
TERN_(MARLIN_DEV_MODE, "S")
#else // "G92.9 E0 ..."
@ -460,12 +442,8 @@ void PrintJobRecovery::resume() {
// Relative axis modes
gcode.axis_relative = info.axis_relative;
#if HAS_HOME_OFFSET
home_offset = info.home_offset;
#endif
#if HAS_POSITION_SHIFT
position_shift = info.position_shift;
#endif
TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
LOOP_XYZ(i) update_workspace_offset((AxisEnum)i);
#endif

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -126,22 +126,16 @@
*/
destination.set(safe_homing_xy, current_position.z);
#if HOMING_Z_WITH_PROBE
destination -= probe.offset_xy;
#endif
TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy);
if (position_is_reachable(destination)) {
if (DEBUGGING(LEVELING)) DEBUG_POS("home_z_safely", destination);
// This causes the carriage on Dual X to unpark
#if ENABLED(DUAL_X_CARRIAGE)
active_extruder_parked = false;
#endif
TERN_(DUAL_X_CARRIAGE, active_extruder_parked = false);
#if ENABLED(SENSORLESS_HOMING)
safe_delay(500); // Short delay needed to settle
#endif
TERN_(SENSORLESS_HOMING, safe_delay(500)); // Short delay needed to settle
do_blocking_move_to_xy(destination);
homeaxis(Z_AXIS);
@ -175,9 +169,7 @@
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[Y_AXIS] = slow_homing.acceleration.y;
#if HAS_CLASSIC_JERK
planner.max_jerk = slow_homing.jerk_xy;
#endif
TERN_(HAS_CLASSIC_JERK, planner.max_jerk = slow_homing.jerk_xy);
planner.reset_acceleration_rates();
}
@ -237,22 +229,18 @@ void GcodeSuite::G28() {
#if HAS_LEVELING
// Cancel the active G29 session
#if ENABLED(PROBE_MANUALLY)
g29_in_progress = false;
#endif
TERN_(PROBE_MANUALLY, g29_in_progress = false);
#if ENABLED(RESTORE_LEVELING_AFTER_G28)
const bool leveling_was_active = planner.leveling_active;
#endif
TERN_(RESTORE_LEVELING_AFTER_G28, const bool leveling_was_active = planner.leveling_active);
set_bed_leveling_enabled(false);
#endif
#if ENABLED(CNC_WORKSPACE_PLANES)
workspace_plane = PLANE_XY;
#endif
TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
#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
auto debug_current = [](PGM_P const s, const int16_t a, const int16_t b){
@ -280,9 +268,7 @@ void GcodeSuite::G28() {
#endif
#endif
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
slow_homing_t slow_homing = begin_slow_homing();
#endif
TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing_t slow_homing = begin_slow_homing());
// Always home with tool 0 active
#if HAS_MULTI_HOTEND
@ -292,9 +278,7 @@ void GcodeSuite::G28() {
tool_change(0, true);
#endif
#if HAS_DUPLICATION_MODE
extruder_duplication_enabled = false;
#endif
TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
remember_feedrate_scaling_off();
@ -306,9 +290,7 @@ void GcodeSuite::G28() {
home_delta();
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
end_slow_homing(slow_homing);
#endif
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
#else // NOT DELTA
@ -380,17 +362,13 @@ void GcodeSuite::G28() {
if (DISABLED(HOME_Y_BEFORE_X) && doY)
homeaxis(Y_AXIS);
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
end_slow_homing(slow_homing);
#endif
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
// Home Z last if homing towards the bed
#if Z_HOME_DIR < 0
if (doZ) {
#if ENABLED(BLTOUCH)
bltouch.init();
#endif
TERN_(BLTOUCH, bltouch.init());
#if ENABLED(Z_SAFE_HOMING)
home_z_safely();
#else
@ -425,9 +403,7 @@ void GcodeSuite::G28() {
if (dxc_is_duplicating()) {
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
slow_homing = begin_slow_homing();
#endif
TERN_(IMPROVE_HOMING_RELIABILITY, slow_homing = begin_slow_homing());
// Always home the 2nd (right) extruder first
active_extruder = 1;
@ -448,9 +424,7 @@ void GcodeSuite::G28() {
dual_x_carriage_mode = IDEX_saved_mode;
stepper.set_directions();
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
end_slow_homing(slow_homing);
#endif
TERN_(IMPROVE_HOMING_RELIABILITY, end_slow_homing(slow_homing));
}
#endif // DUAL_X_CARRIAGE
@ -458,18 +432,14 @@ void GcodeSuite::G28() {
endstops.not_homing();
// Clear endstop state for polled stallGuard endstops
#if ENABLED(SPI_ENDSTOPS)
endstops.clear_endstop_state();
#endif
TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());
#if BOTH(DELTA, DELTA_HOME_TO_SAFE_ZONE)
// move to a height where we can use the full xy-area
do_blocking_move_to_z(delta_clip_start_height);
#endif
#if ENABLED(RESTORE_LEVELING_AFTER_G28)
set_bed_leveling_enabled(leveling_was_active);
#endif
TERN_(RESTORE_LEVELING_AFTER_G28, set_bed_leveling_enabled(leveling_was_active));
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_ACT(VAR, _4P, _OP) LOOP_CAL_PT(VAR, _OP ? _AB : __A, _4P ? _4P_STEP : _7P_STEP)
#if HOTENDS > 1
const uint8_t old_tool_index = active_extruder;
#define AC_CLEANUP() ac_cleanup(old_tool_index)
#else
#define AC_CLEANUP() ac_cleanup()
#endif
TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index = active_extruder);
float lcd_probe_pt(const xy_pos_t &xy);
@ -79,9 +74,7 @@ void ac_home() {
}
void ac_setup(const bool reset_bed) {
#if HOTENDS > 1
tool_change(0, true);
#endif
TERN_(HAS_MULTI_HOTEND, tool_change(0, true));
planner.synchronize();
remember_feedrate_scaling_off();
@ -91,21 +84,11 @@ void ac_setup(const bool reset_bed) {
#endif
}
void ac_cleanup(
#if HOTENDS > 1
const uint8_t old_tool_index
#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
void ac_cleanup(TERN_(HAS_MULTI_HOTEND, const uint8_t old_tool_index)) {
TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));
TERN_(HAS_BED_PROBE, probe.stow());
restore_feedrate_and_scaling();
#if HOTENDS > 1
tool_change(old_tool_index, true);
#endif
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, true));
}
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;
if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each)) {
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);
@ -659,7 +642,7 @@ void GcodeSuite::G33() {
}
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

View file

@ -113,15 +113,11 @@ void GcodeSuite::G34() {
// Disable the leveling matrix before auto-aligning
#if HAS_LEVELING
#if ENABLED(RESTORE_LEVELING_AFTER_G34)
const bool leveling_was_active = planner.leveling_active;
#endif
TERN_(RESTORE_LEVELING_AFTER_G34, const bool leveling_was_active = planner.leveling_active);
set_bed_leveling_enabled(false);
#endif
#if ENABLED(CNC_WORKSPACE_PLANES)
workspace_plane = PLANE_XY;
#endif
TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY);
// Always home with tool 0 active
#if HAS_MULTI_HOTEND
@ -129,18 +125,12 @@ void GcodeSuite::G34() {
tool_change(0, true);
#endif
#if HAS_DUPLICATION_MODE
extruder_duplication_enabled = false;
#endif
TERN_(HAS_DUPLICATION_MODE, extruder_duplication_enabled = false);
#if BOTH(BLTOUCH, BLTOUCH_HS_MODE)
// 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
// length of the deployed pin (BLTOUCH stroke < 7mm)
#define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f
#else
#define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES
#endif
#define Z_BASIC_CLEARANCE Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)
// Compute a worst-case clearance height to probe from. After the first
// iteration this will be re-calculated based on the actual bed position
@ -386,9 +376,7 @@ void GcodeSuite::G34() {
#endif
// Restore the active tool after homing
#if HAS_MULTI_HOTEND
tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER)); // Fetch previous tool for parking extruder
#endif
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index, DISABLED(PARKING_EXTRUDER))); // Fetch previous tool for parking extruder
#if HAS_LEVELING && ENABLED(RESTORE_LEVELING_AFTER_G34)
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);
#endif
#if ENABLED(CALIBRATION_MEASURE_RIGHT)
probe_side(m, uncertainty, RIGHT, probe_top_at_edge);
#endif
#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
TERN_(CALIBRATION_MEASURE_RIGHT, probe_side(m, uncertainty, RIGHT, probe_top_at_edge));
TERN_(CALIBRATION_MEASURE_FRONT, probe_side(m, uncertainty, FRONT, probe_top_at_edge));
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));
// Compute the measured center of the calibration object.
#if HAS_X_CENTER
m.obj_center.x = (m.obj_side[LEFT] + m.obj_side[RIGHT]) / 2;
#endif
#if HAS_Y_CENTER
m.obj_center.y = (m.obj_side[FRONT] + m.obj_side[BACK]) / 2;
#endif
TERN_(HAS_X_CENTER, 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);
// Compute the outside diameter of the nozzle at the height
// at which it makes contact with the calibration object
#if HAS_X_CENTER
m.nozzle_outer_dimension.x = m.obj_side[RIGHT] - m.obj_side[LEFT] - dimensions.x;
#endif
#if HAS_Y_CENTER
m.nozzle_outer_dimension.y = m.obj_side[BACK] - m.obj_side[FRONT] - dimensions.y;
#endif
TERN_(HAS_X_CENTER, 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);
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);
#if HAS_HOTEND_OFFSET
normalize_hotend_offsets();
#endif
TERN_(HAS_HOTEND_OFFSET, normalize_hotend_offsets());
#if HAS_MULTI_HOTEND
set_nozzle(m, 0);
#endif
TERN_(HAS_MULTI_HOTEND, set_nozzle(m, 0));
}
/**
@ -567,9 +545,7 @@ inline void calibrate_all_toolheads(measurements_t &m, const float uncertainty)
inline void calibrate_all() {
measurements_t m;
#if HAS_HOTEND_OFFSET
reset_hotend_offsets();
#endif
TERN_(HAS_HOTEND_OFFSET, reset_hotend_offsets());
TEMPORARY_BACKLASH_CORRECTION(all_on);
TEMPORARY_BACKLASH_SMOOTHING(0.0f);
@ -577,9 +553,7 @@ inline void calibrate_all() {
// Do a fast and rough calibration of the toolheads
calibrate_all_toolheads(m, CALIBRATION_MEASUREMENT_UNKNOWN);
#if ENABLED(BACKLASH_GCODE)
calibrate_backlash(m, CALIBRATION_MEASUREMENT_UNCERTAIN);
#endif
TERN_(BACKLASH_GCODE, calibrate_backlash(m, CALIBRATION_MEASUREMENT_UNCERTAIN));
// Cycle the toolheads so the servos settle into their "natural" positions
#if HAS_MULTI_HOTEND

View file

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

View file

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

View file

@ -142,9 +142,7 @@ void GcodeSuite::M205() {
const float junc_dev = parser.value_linear_units();
if (WITHIN(junc_dev, 0.01f, 0.3f)) {
planner.junction_deviation_mm = junc_dev;
#if ENABLED(LIN_ADVANCE)
planner.recalculate_max_e_jerk();
#endif
TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk());
}
else
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
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), CONTINUE_STR);
#endif
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called"));
#endif
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("M43 Wait Called")));
#endif
for (;;) {
@ -366,9 +362,7 @@ void GcodeSuite::M43() {
}
}
#if HAS_RESUME_CONTINUE
if (!wait_for_user) break;
#endif
if (TERN0(HAS_RESUME_CONTINUE, !wait_for_user)) break;
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.
*/
void GcodeSuite::M108() {
#if HAS_RESUME_CONTINUE
wait_for_user = false;
#endif
TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
wait_for_heatup = false;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -44,14 +44,10 @@ void GcodeSuite::M115() {
#if ENABLED(EXTENDED_CAPABILITIES_REPORT)
// PAREN_COMMENTS
#if ENABLED(PAREN_COMMENTS)
cap_line(PSTR("PAREN_COMMENTS"), true);
#endif
TERN_(PAREN_COMMENTS, cap_line(PSTR("PAREN_COMMENTS"), true));
// QUOTED_STRINGS
#if ENABLED(GCODE_QUOTED_STRINGS)
cap_line(PSTR("QUOTED_STRINGS"), true);
#endif
TERN_(GCODE_QUOTED_STRINGS, cap_line(PSTR("QUOTED_STRINGS"), true));
// SERIAL_XON_XOFF
cap_line(PSTR("SERIAL_XON_XOFF"), ENABLED(SERIAL_XON_XOFF));
@ -92,7 +88,7 @@ void GcodeSuite::M115() {
// CASE LIGHTS (M355)
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)
cap_line(PSTR("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER));

View file

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

View file

@ -70,14 +70,12 @@ void plan_arc(
ab_float_t rvec = -offset;
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_Q = current_position[q_axis] - rvec.b,
rt_X = cart[p_axis] - center_P,
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;
// 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
raw.e = current_position.e;
#if ENABLED(SCARA_FEEDRATE_SCALING)
const float inv_duration = scaled_fr_mm_s / seg_length;
#endif
@ -220,15 +217,12 @@ void plan_arc(
#if ENABLED(SCARA_FEEDRATE_SCALING)
, inv_duration
#endif
))
break;
)) break;
}
// Ensure last segment arrives at target location.
raw = cart;
#if ENABLED(AUTO_BED_LEVELING_UBL)
raw[l_axis] = start_L;
#endif
TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);
apply_motion_limits(raw);
@ -242,10 +236,9 @@ void plan_arc(
#endif
);
#if ENABLED(AUTO_BED_LEVELING_UBL)
raw[l_axis] = start_L;
#endif
TERN_(AUTO_BED_LEVELING_UBL, raw[l_axis] = start_L);
current_position = raw;
} // 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)
#if ENABLED(SF_ARC_FIX)
relative_mode = relative_mode_backup;
#endif
TERN_(SF_ARC_FIX, relative_mode = relative_mode_backup);
ab_float_t arc_offset = { 0, 0 };
if (parser.seenval('R')) {

View file

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

View file

@ -46,9 +46,7 @@ void GcodeSuite::G30() {
if (!probe.can_reach(pos)) return;
// Disable leveling so the planner won't mess with us
#if HAS_LEVELING
set_bed_leveling_enabled(false);
#endif
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));
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[1] = pex[1]; // M951 R
mpe_settings.grab_distance = PARKING_EXTRUDER_GRAB_DISTANCE; // M951 I
#if HAS_HOME_OFFSET
set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
#endif
TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
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.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('I')) {
mpe_settings.grab_distance = parser.value_linear_units();
#if HAS_HOME_OFFSET
set_home_offset(X_AXIS, mpe_settings.grab_distance * -1);
#endif
TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1));
}
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());

View file

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

View file

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

View file

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

View file

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

View file

@ -87,9 +87,7 @@ void GcodeSuite::M104() {
#endif
}
#if ENABLED(AUTOTEMP)
planner.autotemp_M104_M109();
#endif
TERN_(AUTOTEMP, planner.autotemp_M104_M109());
}
/**
@ -139,9 +137,7 @@ void GcodeSuite::M109() {
#endif
}
#if ENABLED(AUTOTEMP)
planner.autotemp_M104_M109();
#endif
TERN_(AUTOTEMP, planner.autotemp_M104_M109());
if (set_temp)
(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');
if (no_wait_for_cooling || parser.seenval('R')) {
thermalManager.setTargetBed(parser.value_celsius());
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
thermalManager.check_timer_autostart(true, false);
#endif
TERN_(PRINTJOB_TIMER_AUTOSTART, thermalManager.check_timer_autostart(true, false));
}
else return;

View file

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

View file

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

View file

@ -431,7 +431,9 @@
#elif ENABLED(MIXING_EXTRUDER)
#define E_STEPPERS MIXING_STEPPERS
#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)
#define E_STEPPERS 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 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
#define HEATER_0_USES_MAX6675
@ -1269,7 +1271,7 @@
#define HAS_X_STEP 1
#endif
#if PIN_EXISTS(X_MS1)
#define HAS_X_MICROSTEPS 1
#define HAS_X_MS_PINS 1
#endif
#if PIN_EXISTS(X2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(X2))
@ -1282,7 +1284,7 @@
#define HAS_X2_STEP 1
#endif
#if PIN_EXISTS(X2_MS1)
#define HAS_X2_MICROSTEPS 1
#define HAS_X2_MS_PINS 1
#endif
#if PIN_EXISTS(Y_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y))
@ -1295,7 +1297,7 @@
#define HAS_Y_STEP 1
#endif
#if PIN_EXISTS(Y_MS1)
#define HAS_Y_MICROSTEPS 1
#define HAS_Y_MS_PINS 1
#endif
#if PIN_EXISTS(Y2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Y2))
@ -1308,7 +1310,7 @@
#define HAS_Y2_STEP 1
#endif
#if PIN_EXISTS(Y2_MS1)
#define HAS_Y2_MICROSTEPS 1
#define HAS_Y2_MS_PINS 1
#endif
#if PIN_EXISTS(Z_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z))
@ -1321,7 +1323,7 @@
#define HAS_Z_STEP 1
#endif
#if PIN_EXISTS(Z_MS1)
#define HAS_Z_MICROSTEPS 1
#define HAS_Z_MS_PINS 1
#endif
#if PIN_EXISTS(Z2_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2))
@ -1334,7 +1336,7 @@
#define HAS_Z2_STEP 1
#endif
#if PIN_EXISTS(Z2_MS1)
#define HAS_Z2_MICROSTEPS 1
#define HAS_Z2_MS_PINS 1
#endif
#if PIN_EXISTS(Z3_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z3))
@ -1347,7 +1349,7 @@
#define HAS_Z3_STEP 1
#endif
#if PIN_EXISTS(Z3_MS1)
#define HAS_Z3_MICROSTEPS 1
#define HAS_Z3_MS_PINS 1
#endif
#if PIN_EXISTS(Z4_ENABLE) || (ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z4))
@ -1360,7 +1362,7 @@
#define HAS_Z4_STEP 1
#endif
#if PIN_EXISTS(Z4_MS1)
#define HAS_Z4_MICROSTEPS 1
#define HAS_Z4_MS_PINS 1
#endif
// Extruder steppers and solenoids
@ -1374,7 +1376,7 @@
#define HAS_E0_STEP 1
#endif
#if PIN_EXISTS(E0_MS1)
#define HAS_E0_MICROSTEPS 1
#define HAS_E0_MS_PINS 1
#endif
#if PIN_EXISTS(SOL0)
#define HAS_SOLENOID_0 1
@ -1390,7 +1392,7 @@
#define HAS_E1_STEP 1
#endif
#if PIN_EXISTS(E1_MS1)
#define HAS_E1_MICROSTEPS 1
#define HAS_E1_MS_PINS 1
#endif
#if PIN_EXISTS(SOL1)
#define HAS_SOLENOID_1 1
@ -1406,7 +1408,7 @@
#define HAS_E2_STEP 1
#endif
#if PIN_EXISTS(E2_MS1)
#define HAS_E2_MICROSTEPS 1
#define HAS_E2_MS_PINS 1
#endif
#if PIN_EXISTS(SOL2)
#define HAS_SOLENOID_2 1
@ -1422,7 +1424,7 @@
#define HAS_E3_STEP 1
#endif
#if PIN_EXISTS(E3_MS1)
#define HAS_E3_MICROSTEPS 1
#define HAS_E3_MS_PINS 1
#endif
#if PIN_EXISTS(SOL3)
#define HAS_SOLENOID_3 1
@ -1438,7 +1440,7 @@
#define HAS_E4_STEP 1
#endif
#if PIN_EXISTS(E4_MS1)
#define HAS_E4_MICROSTEPS 1
#define HAS_E4_MS_PINS 1
#endif
#if PIN_EXISTS(SOL4)
#define HAS_SOLENOID_4 1
@ -1454,7 +1456,7 @@
#define HAS_E5_STEP 1
#endif
#if PIN_EXISTS(E5_MS1)
#define HAS_E5_MICROSTEPS 1
#define HAS_E5_MS_PINS 1
#endif
#if PIN_EXISTS(SOL5)
#define HAS_SOLENOID_5 1
@ -1470,7 +1472,7 @@
#define HAS_E6_STEP 1
#endif
#if PIN_EXISTS(E6_MS1)
#define HAS_E6_MICROSTEPS 1
#define HAS_E6_MS_PINS 1
#endif
#if PIN_EXISTS(SOL6)
#define HAS_SOLENOID_6 1
@ -1486,13 +1488,16 @@
#define HAS_E7_STEP 1
#endif
#if PIN_EXISTS(E7_MS1)
#define HAS_E7_MICROSTEPS 1
#define HAS_E7_MS_PINS 1
#endif
#if PIN_EXISTS(SOL7)
#define HAS_SOLENOID_7 1
#endif
//
// Trinamic Stepper Drivers
//
#if HAS_TRINAMIC_CONFIG
#if ANY(STEALTHCHOP_XY, STEALTHCHOP_Z, STEALTHCHOP_E)
#define STEALTHCHOP_ENABLED 1
@ -1535,10 +1540,15 @@
#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 != 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
@ -1767,24 +1777,31 @@
#define HAS_AUTO_CHAMBER_FAN 1
#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)
#if HAS_AUTO_FAN
#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))
#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 1
#endif
#if !HAS_TEMP_SENSOR
#undef AUTO_REPORT_TEMPERATURES
#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
#undef AUTO_POWER_CHAMBER_FAN
#endif
// Other fans
#define HAS_FAN0 (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)
#if PIN_EXISTS(FAN)
#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)
#define HAS_FAN1 1
#endif
@ -1806,6 +1823,8 @@
#if _HAS_FAN(7)
#define HAS_FAN7 1
#endif
#undef _NOT_E_AUTO
#undef _HAS_FAN
#if PIN_EXISTS(CONTROLLER_FAN)
#define HAS_CONTROLLER_FAN 1
#endif
@ -1866,13 +1885,13 @@
#define HAS_MOTOR_CURRENT_PWM 1
#endif
#if HAS_Z_MICROSTEPS || HAS_Z2_MICROSTEPS || HAS_Z3_MICROSTEPS || HAS_Z4_MICROSTEPS
#define HAS_SOME_Z_MICROSTEPS 1
#if HAS_Z_MS_PINS || HAS_Z2_MS_PINS || HAS_Z3_MS_PINS || HAS_Z4_MS_PINS
#define HAS_SOME_Z_MS_PINS 1
#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
#define HAS_SOME_E_MICROSTEPS 1
#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_MS_PINS 1
#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
#endif
@ -2071,7 +2090,9 @@
/**
* Part Cooling fan multipliexer
*/
#define HAS_FANMUX PIN_EXISTS(FANMUX0)
#if PIN_EXISTS(FANMUX0)
#define HAS_FANMUX 1
#endif
/**
* MIN/MAX fan PWM scaling

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