From b1543d5799f901734584a7a2bb4ba3c5c7eadc6c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Jul 2023 20:38:17 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Misc.=20fixes=20and=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 4 +--- Marlin/src/core/macros.h | 2 ++ Marlin/src/core/serial.h | 9 ++++++--- Marlin/src/gcode/calibrate/G28.cpp | 14 +++++++++----- Marlin/src/gcode/sd/M24_M25.cpp | 2 +- Marlin/src/pins/ramps/pins_MKS_BASE_16.h | 2 +- Marlin/src/pins/ramps/pins_RAMPS.h | 18 ++++++++++-------- Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h | 2 ++ 8 files changed, 32 insertions(+), 21 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1406aee897ad..6eae5938180b 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -352,9 +352,7 @@ void startOrResumeJob() { TERN_(GCODE_REPEAT_MARKERS, repeat.reset()); TERN_(CANCEL_OBJECTS, cancelable.reset()); TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0); - #if ENABLED(SET_REMAINING_TIME) - ui.reset_remaining_time(); - #endif + TERN_(SET_REMAINING_TIME, ui.reset_remaining_time()); } print_job_timer.start(); } diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index c82a58e0aaf2..1b5738937a2c 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -375,6 +375,8 @@ extern "C++" { // C++11 solution that is standards compliant. Return type is deduced automatically + template static constexpr N _MIN(const N val) { return val; } + template static constexpr N _MAX(const N val) { return val; } template static constexpr auto _MIN(const L lhs, const R rhs) -> decltype(lhs + rhs) { return lhs < rhs ? lhs : rhs; } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 1c2369698597..fceaa0992c29 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -242,11 +242,14 @@ void serialprint_truefalse(const bool tf); void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2) void print_bin(const uint16_t val); + void print_pos(NUM_AXIS_ARGS_(const_float_t) FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr); -inline void print_pos(const xyze_pos_t &xyze, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) { - print_pos(NUM_AXIS_ELEM_(xyze) prefix, suffix); -} +#if LOGICAL_AXES > 1 + inline void print_pos(const xyze_pos_t &xyze, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) { + print_pos(NUM_AXIS_ELEM_(xyze) prefix, suffix); + } +#endif #define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0) #define SERIAL_XYZ(PREFIX,V...) do { print_pos(V, F(PREFIX)); }while(0) diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 6fb062c17003..33a8ed76e606 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -352,7 +352,9 @@ void GcodeSuite::G28() { endstops.enable(true); // Enable endstops for next homing move - bool finalRaiseZ = false; + #if HAS_Z_AXIS + bool finalRaiseZ = false; + #endif #if ENABLED(DELTA) @@ -622,10 +624,12 @@ void GcodeSuite::G28() { // Move to a height where we can use the full xy-area TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height)); - // Move to the configured Z only if Z was homed to MIN, because machines that - // home to MAX historically expect 'G28 Z' to be safe to use at the end of a - // print, and do_move_after_z_homing is not very nuanced. - if (finalRaiseZ) do_move_after_z_homing(); + #if HAS_Z_AXIS + // Move to the configured Z only if Z was homed to MIN, because machines that + // home to MAX historically expect 'G28 Z' to be safe to use at the end of a + // print, and do_move_after_z_homing is not very nuanced. + if (finalRaiseZ) do_move_after_z_homing(); + #endif TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled()); diff --git a/Marlin/src/gcode/sd/M24_M25.cpp b/Marlin/src/gcode/sd/M24_M25.cpp index 45c596ae9922..7bf1ab74d5bb 100644 --- a/Marlin/src/gcode/sd/M24_M25.cpp +++ b/Marlin/src/gcode/sd/M24_M25.cpp @@ -70,7 +70,7 @@ void GcodeSuite::M24() { #endif if (card.isFileOpen()) { - card.startOrResumeFilePrinting(); // SD card will now be read for commands + card.startOrResumeFilePrinting(); // SD card will now be read for commands startOrResumeJob(); // Start (or resume) the print job timer TERN_(POWER_LOSS_RECOVERY, recovery.prepare()); } diff --git a/Marlin/src/pins/ramps/pins_MKS_BASE_16.h b/Marlin/src/pins/ramps/pins_MKS_BASE_16.h index 765a601fd029..bb6def5ca46f 100644 --- a/Marlin/src/pins/ramps/pins_MKS_BASE_16.h +++ b/Marlin/src/pins/ramps/pins_MKS_BASE_16.h @@ -38,7 +38,7 @@ // // Servos // -#define SERVO1_PIN 12 // Digital 12 / Pin 25 +#define SERVO1_PIN 12 // // Omitted RAMPS pins diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 8b15f82736f9..08c059477b05 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -320,14 +320,16 @@ // // TMC software SPI // -#ifndef TMC_SPI_MOSI - #define TMC_SPI_MOSI 66 -#endif -#ifndef TMC_SPI_MISO - #define TMC_SPI_MISO 44 -#endif -#ifndef TMC_SPI_SCK - #define TMC_SPI_SCK 64 +#if HAS_TMC_SPI + #ifndef TMC_SPI_MOSI + #define TMC_SPI_MOSI 66 + #endif + #ifndef TMC_SPI_MISO + #define TMC_SPI_MISO 44 + #endif + #ifndef TMC_SPI_SCK + #define TMC_SPI_SCK 64 + #endif #endif #if HAS_TMC_UART diff --git a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h index 8c65b2e0b41d..49a8c196d0a6 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h +++ b/Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h @@ -57,6 +57,8 @@ #define CASE_LIGHT_PIN 65 #endif +#define SERVO1_PIN 12 + #include "pins_RAMPS.h" #ifndef BEEPER_PIN