From e3fd0519b323182a3d096eca8209c4eaf56b6802 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 30 Sep 2019 21:44:07 -0500 Subject: [PATCH] Reduce need for UNUSED --- Marlin/src/HAL/HAL_AVR/HAL.h | 3 +- Marlin/src/HAL/HAL_AVR/HAL_SPI.cpp | 9 +-- Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp | 3 +- Marlin/src/HAL/HAL_DUE/MarlinSerialUSB.cpp | 7 +- Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp | 13 +--- Marlin/src/HAL/HAL_ESP32/watchdog.h | 2 +- Marlin/src/HAL/HAL_LINUX/HAL.h | 2 +- Marlin/src/HAL/HAL_LINUX/include/serial.h | 4 +- Marlin/src/HAL/HAL_LPC1768/MarlinSerial.h | 2 +- Marlin/src/HAL/HAL_STM32/HAL.cpp | 14 +--- Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h | 2 +- Marlin/src/HAL/HAL_TEENSY31_32/HAL.h | 2 +- Marlin/src/HAL/HAL_TEENSY35_36/HAL.h | 2 +- Marlin/src/HAL/shared/Delay.h | 2 +- Marlin/src/feature/Max7219_Debug_LEDs.h | 2 +- Marlin/src/feature/leds/pca9632.cpp | 3 +- Marlin/src/feature/power_loss_recovery.h | 2 +- Marlin/src/feature/runout.h | 6 +- Marlin/src/feature/spindle_laser.h | 2 +- Marlin/src/gcode/parser.h | 6 +- Marlin/src/lcd/menu/menu.h | 6 +- Marlin/src/lcd/menu/menu_media.cpp | 1 + Marlin/src/lcd/ultralcd.h | 10 +-- Marlin/src/module/configuration_store.h | 2 +- Marlin/src/module/motion.h | 12 +-- Marlin/src/module/planner.h | 7 +- Marlin/src/module/stepper.h | 2 +- Marlin/src/module/temperature.cpp | 29 +++---- Marlin/src/module/temperature.h | 76 ++++++++----------- .../sd/usb_flashdrive/Sd2Card_FlashDrive.h | 12 +-- .../sd/usb_flashdrive/lib-uhs2/parsetools.h | 2 +- 31 files changed, 104 insertions(+), 143 deletions(-) diff --git a/Marlin/src/HAL/HAL_AVR/HAL.h b/Marlin/src/HAL/HAL_AVR/HAL.h index 9c34dc1f54..246353677f 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL.h +++ b/Marlin/src/HAL/HAL_AVR/HAL.h @@ -146,8 +146,7 @@ extern "C" { #define DISABLE_TEMPERATURE_INTERRUPT() CBI(TIMSK0, OCIE0B) #define TEMPERATURE_ISR_ENABLED() TEST(TIMSK0, OCIE0B) -FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { - UNUSED(frequency); +FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) { switch (timer_num) { case STEP_TIMER_NUM: // waveform generation = 0100 = CTC diff --git a/Marlin/src/HAL/HAL_AVR/HAL_SPI.cpp b/Marlin/src/HAL/HAL_AVR/HAL_SPI.cpp index 68e21aae53..7a0f7246ee 100644 --- a/Marlin/src/HAL/HAL_AVR/HAL_SPI.cpp +++ b/Marlin/src/HAL/HAL_AVR/HAL_SPI.cpp @@ -184,15 +184,10 @@ void spiBegin() { // nop to tune soft SPI timing #define nop asm volatile ("\tnop\n") - // Set SPI rate - void spiInit(uint8_t spiRate) { - UNUSED(spiRate); // nothing to do - } + void spiInit(uint8_t) { /* do nothing */ } // Begin SPI transaction, set clock, bit order, data mode - void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { - UNUSED(spiBeginTransaction); // nothing to do - } + void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode) { /* do nothing */ } // Soft SPI receive byte uint8_t spiRec() { diff --git a/Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp b/Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp index f942ff8082..35763a5ec7 100644 --- a/Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/HAL_DUE/HAL_SPI.cpp @@ -151,13 +151,12 @@ (((uint32_t)(addr) & 0xF0000000) + 0x02000000 + ((uint32_t)(addr)&0xFFFFF)*32 + (bit)*4) // run at ~8 .. ~10Mhz - Rx version (Tx line not altered) - static uint8_t spiTransferRx0(uint8_t bout) { // using Mode 0 + static uint8_t spiTransferRx0(uint8_t) { // using Mode 0 uint32_t bin = 0; uint32_t work = 0; uint32_t BITBAND_MISO_PORT = BITBAND_ADDRESS( ((uint32_t)PORT(MISO_PIN))+0x3C, PIN_SHIFT(MISO_PIN)); /* PDSR of port in bitband area */ uint32_t SCK_PORT_PLUS30 = ((uint32_t) PORT(SCK_PIN)) + 0x30; /* SODR of port */ uint32_t SCK_MASK = PIN_MASK(SCK_PIN); - UNUSED(bout); /* The software SPI routine */ __asm__ __volatile__( diff --git a/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB.cpp b/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB.cpp index 1bce07e53f..f7f48d5f42 100644 --- a/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB.cpp +++ b/Marlin/src/HAL/HAL_DUE/MarlinSerialUSB.cpp @@ -55,12 +55,9 @@ static int pending_char = -1; #endif // Public Methods -void MarlinSerialUSB::begin(const long baud_setting) { - UNUSED(baud_setting); -} +void MarlinSerialUSB::begin(const long) {} -void MarlinSerialUSB::end() { -} +void MarlinSerialUSB::end() {} int MarlinSerialUSB::peek() { if (pending_char >= 0) diff --git a/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp index 7699f2724f..b85a2b09a1 100644 --- a/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp +++ b/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp @@ -33,19 +33,12 @@ Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) { return CTRL_GOOD; } -bool sd_mmc_spi_unload(bool unload) { - UNUSED(unload); - return true; -} +bool sd_mmc_spi_unload(bool) { return true; } -bool sd_mmc_spi_wr_protect() { - return false; -} +bool sd_mmc_spi_wr_protect() { return false; } bool sd_mmc_spi_removal() { - if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted()) - return true; - return false; + return (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.isMounted()); } #if ACCESS_USB == true diff --git a/Marlin/src/HAL/HAL_ESP32/watchdog.h b/Marlin/src/HAL/HAL_ESP32/watchdog.h index e1ec9fbf54..6647ecefe6 100644 --- a/Marlin/src/HAL/HAL_ESP32/watchdog.h +++ b/Marlin/src/HAL/HAL_ESP32/watchdog.h @@ -25,4 +25,4 @@ void watchdog_init(); // Reset watchdog. -inline void HAL_watchdog_refresh() { } +inline void HAL_watchdog_refresh() {} diff --git a/Marlin/src/HAL/HAL_LINUX/HAL.h b/Marlin/src/HAL/HAL_LINUX/HAL.h index 8f368a1507..5bd283e5c1 100644 --- a/Marlin/src/HAL/HAL_LINUX/HAL.h +++ b/Marlin/src/HAL/HAL_LINUX/HAL.h @@ -78,7 +78,7 @@ extern HalSerial usb_serial; #define ENABLE_ISRS() #define DISABLE_ISRS() -inline void HAL_init() { } +inline void HAL_init() {} // Utility functions #pragma GCC diagnostic push diff --git a/Marlin/src/HAL/HAL_LINUX/include/serial.h b/Marlin/src/HAL/HAL_LINUX/include/serial.h index 268bdeeeca..c6da82ad5a 100644 --- a/Marlin/src/HAL/HAL_LINUX/include/serial.h +++ b/Marlin/src/HAL/HAL_LINUX/include/serial.h @@ -83,9 +83,9 @@ public: HalSerial() { host_connected = true; } - void begin(int32_t baud) { } + void begin(int32_t) {} - void end() { } + void end() {} int peek() { uint8_t value; diff --git a/Marlin/src/HAL/HAL_LPC1768/MarlinSerial.h b/Marlin/src/HAL/HAL_LPC1768/MarlinSerial.h index 1f282f64a3..8050685538 100644 --- a/Marlin/src/HAL/HAL_LPC1768/MarlinSerial.h +++ b/Marlin/src/HAL/HAL_LPC1768/MarlinSerial.h @@ -49,7 +49,7 @@ public: { } - void end() { } + void end() {} #if ENABLED(EMERGENCY_PARSER) bool recv_callback(const char c) override { diff --git a/Marlin/src/HAL/HAL_STM32/HAL.cpp b/Marlin/src/HAL/HAL_STM32/HAL.cpp index 6ecde3ef35..edc161a5d3 100644 --- a/Marlin/src/HAL/HAL_STM32/HAL.cpp +++ b/Marlin/src/HAL/HAL_STM32/HAL.cpp @@ -104,17 +104,11 @@ extern "C" { // ADC // ------------------------ -void HAL_adc_start_conversion(const uint8_t adc_pin) { - HAL_adc_result = analogRead(adc_pin); -} +// TODO: Make sure this doesn't cause any delay +void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); } -uint16_t HAL_adc_get_result() { - return HAL_adc_result; -} +uint16_t HAL_adc_get_result() { return HAL_adc_result; } -void flashFirmware(int16_t value) { - UNUSED(value); - NVIC_SystemReset(); -} +void flashFirmware(int16_t) { NVIC_SystemReset(); } #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC diff --git a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h index 1effe2d752..d4ca01e022 100644 --- a/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h +++ b/Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h @@ -150,7 +150,7 @@ extern uint16_t HAL_adc_result; // Memory related #define __bss_end __bss_end__ -inline void HAL_init() { } +inline void HAL_init() {} // Clear reset reason void HAL_clear_reset_source(); diff --git a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h index 4813d60d69..e2df8df86b 100644 --- a/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY31_32/HAL.h @@ -87,7 +87,7 @@ typedef int8_t pin_t; #undef pgm_read_word #define pgm_read_word(addr) (*((uint16_t*)(addr))) -inline void HAL_init() { } +inline void HAL_init() {} // Clear the reset reason void HAL_clear_reset_source(); diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h index e218174ad3..9fc4ff6633 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL.h @@ -93,7 +93,7 @@ typedef int8_t pin_t; #undef pgm_read_word #define pgm_read_word(addr) (*((uint16_t*)(addr))) -inline void HAL_init() { } +inline void HAL_init() {} // Clear reset reason void HAL_clear_reset_source(); diff --git a/Marlin/src/HAL/shared/Delay.h b/Marlin/src/HAL/shared/Delay.h index 1c2ee47c29..b3f8f246fb 100644 --- a/Marlin/src/HAL/shared/Delay.h +++ b/Marlin/src/HAL/shared/Delay.h @@ -53,7 +53,7 @@ FORCE_INLINE static void DELAY_CYCLES(const uint32_t x) { const uint32_t endCycles = getCycleCount() + x; - while (PENDING(getCycleCount(), endCycles)) { } + while (PENDING(getCycleCount(), endCycles)) {} } #else diff --git a/Marlin/src/feature/Max7219_Debug_LEDs.h b/Marlin/src/feature/Max7219_Debug_LEDs.h index 02f7c1888b..9462fb23d9 100644 --- a/Marlin/src/feature/Max7219_Debug_LEDs.h +++ b/Marlin/src/feature/Max7219_Debug_LEDs.h @@ -75,7 +75,7 @@ class Max7219 { public: static uint8_t led_line[MAX7219_LINES]; - Max7219() { } + Max7219() {} static void init(); static void register_setup(); diff --git a/Marlin/src/feature/leds/pca9632.cpp b/Marlin/src/feature/leds/pca9632.cpp index 87589a9bcd..fc0da10f70 100644 --- a/Marlin/src/feature/leds/pca9632.cpp +++ b/Marlin/src/feature/leds/pca9632.cpp @@ -138,8 +138,7 @@ void pca9632_set_led_color(const LEDColor &color) { #if ENABLED(PCA9632_BUZZER) - void pca9632_buzz(const long duration, const uint16_t freq) { - UNUSED(duration); UNUSED(freq); + void pca9632_buzz(const long, const uint16_t) { uint8_t data[] = PCA9632_BUZZER_DATA; Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS)); Wire.write(data, sizeof(data)); diff --git a/Marlin/src/feature/power_loss_recovery.h b/Marlin/src/feature/power_loss_recovery.h index c02d5d34cc..9f947701e3 100644 --- a/Marlin/src/feature/power_loss_recovery.h +++ b/Marlin/src/feature/power_loss_recovery.h @@ -169,7 +169,7 @@ class PrintJobRecovery { #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) static void debug(PGM_P const prefix); #else - static inline void debug(PGM_P const prefix) { UNUSED(prefix); } + static inline void debug(PGM_P const) {} #endif private: diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 0ce2c9af7c..c181c7cb43 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -266,7 +266,7 @@ class FilamentSensorBase { } public: - static inline void block_completed(const block_t* const b) { UNUSED(b); } + static inline void block_completed(const block_t* const) {} static inline void run() { const bool out = poll_runout_state(active_extruder); @@ -353,8 +353,8 @@ class FilamentSensorBase { static inline void reset() { runout_count = runout_threshold; } static inline void run() { if (runout_count >= 0) runout_count--; } static inline bool has_run_out() { return runout_count < 0; } - static inline void block_completed(const block_t* const b) { UNUSED(b); } - static inline void filament_present(const uint8_t extruder) { runout_count = runout_threshold; UNUSED(extruder); } + static inline void block_completed(const block_t* const) { } + static inline void filament_present(const uint8_t) { runout_count = runout_threshold; } }; #endif // !FILAMENT_RUNOUT_DISTANCE_MM diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index ddc89b5add..133152a911 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -70,7 +70,7 @@ public: #if ENABLED(SPINDLE_CHANGE_DIR) static void set_direction(const bool reverse); #else - static inline void set_direction(const bool reverse) { UNUSED(reverse); } + static inline void set_direction(const bool) {} #endif static inline void disable() { set_enabled(false); } diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index a4fd629b16..2e91216a64 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -290,9 +290,9 @@ public: static inline float mm_to_linear_unit(const float mm) { return mm; } static inline float mm_to_volumetric_unit(const float mm) { return mm; } - static inline float linear_value_to_mm(const float v) { return v; } - static inline float axis_value_to_mm(const AxisEnum axis, const float v) { UNUSED(axis); return v; } - static inline float per_axis_value(const AxisEnum axis, const float v) { UNUSED(axis); return v; } + static inline float linear_value_to_mm(const float v) { return v; } + static inline float axis_value_to_mm(const AxisEnum, const float v) { return v; } + static inline float per_axis_value(const AxisEnum, const float v) { return v; } #endif diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index 8229aec203..7f167a7b9c 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -114,8 +114,7 @@ FORCE_INLINE void draw_menu_item_edit_P(const bool sel, const uint8_t row, PGM_P FORCE_INLINE void draw_menu_item_edit_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, TYPE * const data, ...) { \ DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \ } \ - FORCE_INLINE void draw_menu_item_edit_accessor_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const pstr2, TYPE (*pget)(), void (*pset)(TYPE), ...) { \ - UNUSED(pstr2); UNUSED(pset); \ + FORCE_INLINE void draw_menu_item_edit_accessor_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, TYPE (*pget)(), void (*)(TYPE), ...) { \ DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(pget())); \ } \ typedef void NAME##_void @@ -149,13 +148,12 @@ DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(long5_25); // 12345 right-justif class MenuItem_back { public: - static inline void action(PGM_P const dummy=nullptr) { + static inline void action(PGM_P const=nullptr) { ui.goto_previous_screen( #if ENABLED(TURBO_BACK_MENU_ITEM) true #endif ); - UNUSED(dummy); } }; diff --git a/Marlin/src/lcd/menu/menu_media.cpp b/Marlin/src/lcd/menu/menu_media.cpp index 0b97918edb..ac1631660d 100644 --- a/Marlin/src/lcd/menu/menu_media.cpp +++ b/Marlin/src/lcd/menu/menu_media.cpp @@ -108,6 +108,7 @@ class MenuItem_sdfile { MenuItem_submenu::action(pstr, menu_sd_confirm); #else sdcard_start_selected_file(); + UNUSED(pstr); #endif } }; diff --git a/Marlin/src/lcd/ultralcd.h b/Marlin/src/lcd/ultralcd.h index 32c51cd249..c33337df8c 100644 --- a/Marlin/src/lcd/ultralcd.h +++ b/Marlin/src/lcd/ultralcd.h @@ -273,7 +273,7 @@ public: static void init(); static void update(); - static void set_alert_status_P(PGM_P message); + static void set_alert_status_P(PGM_P const message); static char status_message[]; static bool has_status(); @@ -393,10 +393,10 @@ public: static inline void update() {} static inline void refresh() {} static inline void return_to_status() {} - static inline void set_alert_status_P(PGM_P message) { UNUSED(message); } - static inline void set_status(const char* const message, const bool persist=false) { UNUSED(message); UNUSED(persist); } - static inline void set_status_P(PGM_P const message, const int8_t level=0) { UNUSED(message); UNUSED(level); } - static inline void status_printf_P(const uint8_t level, PGM_P const fmt, ...) { UNUSED(level); UNUSED(fmt); } + static inline void set_alert_status_P(PGM_P const) {} + static inline void set_status(const char* const, const bool=false) {} + static inline void set_status_P(PGM_P const, const int8_t=0) {} + static inline void status_printf_P(const uint8_t, PGM_P const, ...) {} static inline void reset_status() {} static inline void reset_alert_level() {} static constexpr bool has_status() { return false; } diff --git a/Marlin/src/module/configuration_store.h b/Marlin/src/module/configuration_store.h index 9e95e47525..b8a64c5c68 100644 --- a/Marlin/src/module/configuration_store.h +++ b/Marlin/src/module/configuration_store.h @@ -85,7 +85,7 @@ class MarlinSettings { static void report(const bool forReplay=false); #else FORCE_INLINE - static void report(const bool forReplay=false) { UNUSED(forReplay); } + static void report(const bool=false) {} #endif private: diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 0da481e4e5..ba37bebd46 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -279,12 +279,12 @@ void homeaxis(const AxisEnum axis); #else #define NATIVE_TO_LOGICAL(POS, AXIS) (POS) #define LOGICAL_TO_NATIVE(POS, AXIS) (POS) - FORCE_INLINE void toLogical(xy_pos_t &raw) { UNUSED(raw); } - FORCE_INLINE void toLogical(xyz_pos_t &raw) { UNUSED(raw); } - FORCE_INLINE void toLogical(xyze_pos_t &raw) { UNUSED(raw); } - FORCE_INLINE void toNative(xy_pos_t &raw) { UNUSED(raw); } - FORCE_INLINE void toNative(xyz_pos_t &raw) { UNUSED(raw); } - FORCE_INLINE void toNative(xyze_pos_t &raw) { UNUSED(raw); } + FORCE_INLINE void toLogical(xy_pos_t&) {} + FORCE_INLINE void toLogical(xyz_pos_t&) {} + FORCE_INLINE void toLogical(xyze_pos_t&) {} + FORCE_INLINE void toNative(xy_pos_t&) {} + FORCE_INLINE void toNative(xyz_pos_t&) {} + FORCE_INLINE void toNative(xyze_pos_t&) {} #endif #define LOGICAL_X_POSITION(POS) NATIVE_TO_LOGICAL(POS, X_AXIS) #define LOGICAL_Y_POSITION(POS) NATIVE_TO_LOGICAL(POS, Y_AXIS) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index c18b7753e6..55ccae85a3 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -431,12 +431,9 @@ class Planner { #else - FORCE_INLINE static float fade_scaling_factor_for_z(const float &rz) { - UNUSED(rz); - return 1; - } + FORCE_INLINE static float fade_scaling_factor_for_z(const float&) { return 1; } - FORCE_INLINE static bool leveling_active_at_z(const float &rz) { UNUSED(rz); return true; } + FORCE_INLINE static bool leveling_active_at_z(const float&) { return true; } #endif diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 839a9a9d5e..1ab455bd06 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -337,7 +337,7 @@ class Stepper { // // Constructor / initializer // - Stepper() { }; + Stepper() {}; // Initialize stepper hardware static void init(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 79825ec518..eb37325da2 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -813,13 +813,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { #if HOTENDS - float Temperature::get_pid_output_hotend(const uint8_t e) { - #if HOTENDS == 1 - #define _HOTEND_TEST true - #else - #define _HOTEND_TEST (e == active_extruder) - #endif - E_UNUSED(); + float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; #if ENABLED(PIDTEMP) #if DISABLED(PID_OPENLOOP) @@ -860,8 +854,13 @@ void Temperature::min_temp_error(const heater_ind_t heater) { pid_output = work_pid[ee].Kp + work_pid[ee].Ki + work_pid[ee].Kd + float(MIN_POWER); #if ENABLED(PID_EXTRUSION_SCALING) + #if HOTENDS == 1 + constexpr bool this_hotend = true; + #else + const bool this_hotend = (e == active_extruder); + #endif work_pid[ee].Kc = 0; - if (_HOTEND_TEST) { + if (this_hotend) { const long e_position = stepper.position(E_AXIS); if (e_position > last_e_position) { lpq[lpq_ptr] = e_position - last_e_position; @@ -895,6 +894,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { MSG_PID_DEBUG_OUTPUT, pid_output ); #if DISABLED(PID_OPENLOOP) + { SERIAL_ECHOPAIR( MSG_PID_DEBUG_PTERM, work_pid[ee].Kp, MSG_PID_DEBUG_ITERM, work_pid[ee].Ki, @@ -903,6 +903,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { , MSG_PID_DEBUG_CTERM, work_pid[ee].Kc #endif ); + } #endif SERIAL_EOL(); } @@ -911,12 +912,11 @@ void Temperature::min_temp_error(const heater_ind_t heater) { #else // No PID enabled #if HEATER_IDLE_HANDLER - #define _TIMED_OUT_TEST hotend_idle[ee].timed_out + const bool is_idling = hotend_idle[ee].timed_out; #else - #define _TIMED_OUT_TEST false + constexpr bool is_idling = false; #endif - const float pid_output = (!_TIMED_OUT_TEST && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0; - #undef _TIMED_OUT_TEST + const float pid_output = (!is_idling && temp_hotend[ee].celsius < temp_hotend[ee].target) ? BANG_MAX : 0; #endif @@ -971,6 +971,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { #endif // PID_OPENLOOP #if ENABLED(PID_BED_DEBUG) + { SERIAL_ECHO_START(); SERIAL_ECHOLNPAIR( " PID_BED_DEBUG : Input ", temp_bed.celsius, " Output ", pid_output, @@ -980,6 +981,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { MSG_PID_DEBUG_DTERM, work_pid.Kd, #endif ); + } #endif return pid_output; @@ -1811,8 +1813,7 @@ void Temperature::init() { * their target temperature by a configurable margin. * This is called when the temperature is set. (M104, M109) */ - void Temperature::start_watching_hotend(const uint8_t e) { - E_UNUSED(); + void Temperature::start_watching_hotend(const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; if (degTargetHotend(ee) && degHotend(ee) < degTargetHotend(ee) - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1)) { watch_hotend[ee].target = degHotend(ee) + WATCH_TEMP_INCREASE; diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 63251cd40f..e75eae4f85 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -39,10 +39,10 @@ #if HOTENDS <= 1 #define HOTEND_INDEX 0 - #define E_UNUSED() UNUSED(e) + #define E_NAME #else #define HOTEND_INDEX e - #define E_UNUSED() + #define E_NAME e #endif // Identifiers for other heaters @@ -304,17 +304,15 @@ class Temperature { static bool allow_cold_extrude; static int16_t extrude_min_temp; FORCE_INLINE static bool tooCold(const int16_t temp) { return allow_cold_extrude ? false : temp < extrude_min_temp; } - FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { - E_UNUSED(); + FORCE_INLINE static bool tooColdToExtrude(const uint8_t E_NAME) { return tooCold(degHotend(HOTEND_INDEX)); } - FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { - E_UNUSED(); + FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t E_NAME) { return tooCold(degTargetHotend(HOTEND_INDEX)); } #else - FORCE_INLINE static bool tooColdToExtrude(const uint8_t e) { UNUSED(e); return false; } - FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t e) { UNUSED(e); return false; } + FORCE_INLINE static bool tooColdToExtrude(const uint8_t) { return false; } + FORCE_INLINE static bool targetTooColdToExtrude(const uint8_t) { return false; } #endif FORCE_INLINE static bool hotEnoughToExtrude(const uint8_t e) { return !tooColdToExtrude(e); } @@ -546,16 +544,13 @@ class Temperature { * Preheating hotends */ #ifdef MILLISECONDS_PREHEAT_TIME - static bool is_preheating(const uint8_t e) { - E_UNUSED(); + static bool is_preheating(const uint8_t E_NAME) { return preheat_end_time[HOTEND_INDEX] && PENDING(millis(), preheat_end_time[HOTEND_INDEX]); } - static void start_preheat_time(const uint8_t e) { - E_UNUSED(); + static void start_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = millis() + MILLISECONDS_PREHEAT_TIME; } - static void reset_preheat_time(const uint8_t e) { - E_UNUSED(); + static void reset_preheat_time(const uint8_t E_NAME) { preheat_end_time[HOTEND_INDEX] = 0; } #else @@ -566,39 +561,36 @@ class Temperature { //inline so that there is no performance decrease. //deg=degreeCelsius - FORCE_INLINE static float degHotend(const uint8_t e) { - E_UNUSED(); - #if HOTENDS - return temp_hotend[HOTEND_INDEX].celsius; - #else - return 0; - #endif + FORCE_INLINE static float degHotend(const uint8_t E_NAME) { + return (0 + #if HOTENDS + + temp_hotend[HOTEND_INDEX].celsius + #endif + ); } #if ENABLED(SHOW_TEMP_ADC_VALUES) - FORCE_INLINE static int16_t rawHotendTemp(const uint8_t e) { - E_UNUSED(); - #if HOTENDS - return temp_hotend[HOTEND_INDEX].raw; - #else - return 0; - #endif + FORCE_INLINE static int16_t rawHotendTemp(const uint8_t E_NAME) { + return (0 + #if HOTENDS + + temp_hotend[HOTEND_INDEX].raw + #endif + ); } #endif - FORCE_INLINE static int16_t degTargetHotend(const uint8_t e) { - E_UNUSED(); - #if HOTENDS - return temp_hotend[HOTEND_INDEX].target; - #else - return 0; - #endif + FORCE_INLINE static int16_t degTargetHotend(const uint8_t E_NAME) { + return (0 + #if HOTENDS + + temp_hotend[HOTEND_INDEX].target + #endif + ); } #if WATCH_HOTENDS static void start_watching_hotend(const uint8_t e=0); #else - static inline void start_watching_hotend(const uint8_t e=0) { UNUSED(e); } + static inline void start_watching_hotend(const uint8_t=0) {} #endif #if HOTENDS @@ -612,8 +604,7 @@ class Temperature { static inline void start_watching_E5() { start_watching_hotend(5); } #endif - static void setTargetHotend(const int16_t celsius, const uint8_t e) { - E_UNUSED(); + static void setTargetHotend(const int16_t celsius, const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; #ifdef MILLISECONDS_PREHEAT_TIME if (celsius == 0) @@ -628,13 +619,11 @@ class Temperature { start_watching_hotend(ee); } - FORCE_INLINE static bool isHeatingHotend(const uint8_t e) { - E_UNUSED(); + FORCE_INLINE static bool isHeatingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target > temp_hotend[HOTEND_INDEX].celsius; } - FORCE_INLINE static bool isCoolingHotend(const uint8_t e) { - E_UNUSED(); + FORCE_INLINE static bool isCoolingHotend(const uint8_t E_NAME) { return temp_hotend[HOTEND_INDEX].target < temp_hotend[HOTEND_INDEX].celsius; } @@ -765,8 +754,7 @@ class Temperature { #if HEATER_IDLE_HANDLER - static void reset_heater_idle_timer(const uint8_t e) { - E_UNUSED(); + static void reset_heater_idle_timer(const uint8_t E_NAME) { hotend_idle[HOTEND_INDEX].reset(); start_watching_hotend(HOTEND_INDEX); } diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h index 5ab82d3af7..a429bfd28f 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.h @@ -57,13 +57,13 @@ class Sd2Card { static void idle(); - inline bool readStart(const uint32_t block) { pos = block; return ready(); } - inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); } - inline bool readStop() const { return true; } + inline bool readStart(const uint32_t block) { pos = block; return ready(); } + inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); } + inline bool readStop() const { return true; } - inline bool writeStart(const uint32_t block, const uint32_t eraseCount) { UNUSED(eraseCount); pos = block; return ready(); } - inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); } - inline bool writeStop() const { return true; } + inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return ready(); } + inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); } + inline bool writeStop() const { return true; } bool readBlock(uint32_t block, uint8_t* dst); bool writeBlock(uint32_t blockNumber, const uint8_t* src); diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h b/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h index 529bafbbc0..28a2841446 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs2/parsetools.h @@ -120,7 +120,7 @@ public: lenSize(0), valSize(0), pBuf(nullptr), - prsMode(modeArray) { } + prsMode(modeArray) {} ; void Initialize(const uint8_t len_size, const uint8_t val_size, MultiValueBuffer * const p, const uint8_t mode = modeArray) {