From 3bddbb1110b6ca13a291de426553839b99cae102 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Apr 2021 19:06:55 -0500 Subject: [PATCH] Clean up formatting, wrap macros --- Marlin/src/HAL/STM32/usb_host.cpp | 2 +- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/feature/hotend_idle.cpp | 2 +- Marlin/src/feature/leds/printer_event_leds.h | 8 +--- Marlin/src/feature/power.cpp | 6 +-- Marlin/src/feature/probe_temp_comp.cpp | 2 +- Marlin/src/feature/probe_temp_comp.h | 6 +-- Marlin/src/gcode/calibrate/G76_M192_M871.cpp | 2 +- .../extui/lib/anycubic_chiron/chiron_tft.cpp | 2 +- .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 12 +++--- .../lcd/extui/lib/mks_ui/draw_printing.cpp | 2 +- Marlin/src/lcd/extui/malyan_lcd.cpp | 6 +-- Marlin/src/lcd/extui/ui_api.cpp | 16 ++----- Marlin/src/lcd/extui/ui_api.h | 42 +++++++++---------- Marlin/src/module/temperature.cpp | 4 +- Marlin/src/module/tool_change.cpp | 4 +- 16 files changed, 49 insertions(+), 69 deletions(-) diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index ed743361e..8fa49ccbc 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -110,7 +110,7 @@ uint8_t BulkStorage::Read(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t bl } uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t blocks, const uint8_t * buf) { - return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast (buf), blocks) != USBH_OK; + return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast(buf), blocks) != USBH_OK; } #endif // USE_OTG_USB_HOST && USBHOST diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1405f2033..668f977b0 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -600,7 +600,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check()); #if ENABLED(EXTRUDER_RUNOUT_PREVENT) - if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP + if (thermalManager.degHotend(active_extruder) > (EXTRUDER_RUNOUT_MINTEMP) && ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS)) && !planner.has_blocks_queued() ) { diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index 911cd20e6..b962743ed 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -45,7 +45,7 @@ void HotendIdleProtection::check_hotends(const millis_t &ms) { bool do_prot = false; HOTEND_LOOP() { const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); - if (thermalManager.degHotend(e) >= HOTEND_IDLE_MIN_TRIGGER && !busy) { + if (thermalManager.degHotend(e) >= (HOTEND_IDLE_MIN_TRIGGER) && !busy) { do_prot = true; break; } } diff --git a/Marlin/src/feature/leds/printer_event_leds.h b/Marlin/src/feature/leds/printer_event_leds.h index a262ddf85..2e1e58973 100644 --- a/Marlin/src/feature/leds/printer_event_leds.h +++ b/Marlin/src/feature/leds/printer_event_leds.h @@ -36,13 +36,7 @@ private: static bool leds_off_after_print; #endif - static inline void set_done() { - #if ENABLED(LED_COLOR_PRESETS) - leds.set_default(); - #else - leds.set_off(); - #endif - } + static inline void set_done() { TERN(LED_COLOR_PRESETS, leds.set_default(), leds.set_off()); } public: #if HAS_TEMP_HOTEND diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 8ab49de2b..2f19dae7a 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -85,15 +85,15 @@ bool Power::is_power_needed() { if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0 || thermalManager.temp_bed.soft_pwm_amount > 0)) return true; #if HAS_HOTEND && AUTO_POWER_E_TEMP - HOTEND_LOOP() if (thermalManager.degHotend(e) >= AUTO_POWER_E_TEMP) return true; + HOTEND_LOOP() if (thermalManager.degHotend(e) >= (AUTO_POWER_E_TEMP)) return true; #endif #if HAS_HEATED_CHAMBER && AUTO_POWER_CHAMBER_TEMP - if (thermalManager.degChamber() >= AUTO_POWER_CHAMBER_TEMP) return true; + if (thermalManager.degChamber() >= (AUTO_POWER_CHAMBER_TEMP)) return true; #endif #if HAS_COOLER && AUTO_POWER_COOLER_TEMP - if (thermalManager.degCooler() >= AUTO_POWER_COOLER_TEMP) return true; + if (thermalManager.degCooler() >= (AUTO_POWER_COOLER_TEMP)) return true; #endif return false; diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 68e669224..edb33da8c 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -181,7 +181,7 @@ float ProbeTempComp::get_offset_for_temperature(const TempSensorID tsi, const_fl // Linear interpolation uint8_t idx = static_cast((temp - start_temp) / res_temp); - // offset in um + // offset in µm float offset = 0.0f; #if !defined(PTC_LINEAR_EXTRAPOLATION) || PTC_LINEAR_EXTRAPOLATION <= 0 diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 5fb637a17..c31d287a1 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -81,10 +81,10 @@ typedef struct { #endif static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { - { PTC_SAMPLE_COUNT, PTC_SAMPLE_RES, PTC_SAMPLE_START, PTC_SAMPLE_END }, // Probe - { BTC_SAMPLE_COUNT, BTC_SAMPLE_RES, BTC_SAMPLE_START, BTC_SAMPLE_END }, // Bed + { PTC_SAMPLE_COUNT, PTC_SAMPLE_RES, PTC_SAMPLE_START, PTC_SAMPLE_END }, // Probe + { BTC_SAMPLE_COUNT, BTC_SAMPLE_RES, BTC_SAMPLE_START, BTC_SAMPLE_END }, // Bed #if ENABLED(USE_TEMP_EXT_COMPENSATION) - { 20, 5, 180, 180 + 5 * 20 } // Extruder + { 20, 5, 180, 180 + 5 * 20 } // Extruder #endif }; diff --git a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp index 9fc30b794..f07d39822 100644 --- a/Marlin/src/gcode/calibrate/G76_M192_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M192_M871.cpp @@ -208,7 +208,7 @@ void GcodeSuite::G76() { report_temps(next_temp_report); const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); - if (isnan(measured_z) || target_bed > BED_MAX_TARGET) break; + if (isnan(measured_z) || target_bed > (BED_MAX_TARGET)) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); diff --git a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp index ee8f18cd8..5ad3895da 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_chiron/chiron_tft.cpp @@ -700,7 +700,7 @@ void ChironTFT::PanelAction(uint8_t req) { if (!isPrinting()) { // Ignore request if printing char MoveCmnd[30]; - sprintf_P(MoveCmnd, PSTR("G91\nG0 %s \nG90"), panel_command+3); + sprintf_P(MoveCmnd, PSTR("G91\nG0%s\nG90"), panel_command + 3); #if ACDEBUG(AC_ACTION) SERIAL_ECHOLNPAIR("Move: ", MoveCmnd); #endif diff --git a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp index acd4d202b..f3a9472c2 100644 --- a/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -700,13 +700,13 @@ void AnycubicTFTClass::GetCommandFromTFT() { unsigned int tempvalue; if (CodeSeen('S')) { tempvalue = constrain(CodeValue(), 0, 275); - setTargetTemp_celsius(tempvalue, (extruder_t) E0); + setTargetTemp_celsius(tempvalue, (extruder_t)E0); } else if (CodeSeen('C') && !isPrinting()) { if (getAxisPosition_mm(Z) < 10) injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS tempvalue = constrain(CodeValue(), 0, 275); - setTargetTemp_celsius(tempvalue, (extruder_t) E0); + setTargetTemp_celsius(tempvalue, (extruder_t)E0); } } break; @@ -832,8 +832,8 @@ void AnycubicTFTClass::GetCommandFromTFT() { if (getAxisPosition_mm(Z) < 10) injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS - setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (heater_t) BED); - setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (extruder_t) E0); + setTargetTemp_celsius(PREHEAT_1_TEMP_BED, (heater_t)BED); + setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, (extruder_t)E0); SENDLINE_PGM("OK"); } break; @@ -843,8 +843,8 @@ void AnycubicTFTClass::GetCommandFromTFT() { if (getAxisPosition_mm(Z) < 10) injectCommands_P(PSTR("G1 Z10")); // RASE Z AXIS - setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (heater_t) BED); - setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (extruder_t) E0); + setTargetTemp_celsius(PREHEAT_2_TEMP_BED, (heater_t)BED); + setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, (extruder_t)E0); SENDLINE_PGM("OK"); } break; diff --git a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp index e9cfd8179..e35027a65 100644 --- a/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp @@ -236,7 +236,7 @@ void disp_bed_temp() { } void disp_fan_speed() { - sprintf_P(public_buf_l, PSTR("%d%%"), thermalManager.fanSpeedPercent(0)); + sprintf_P(public_buf_l, PSTR("%d%%"), (int)thermalManager.fanSpeedPercent(0)); lv_label_set_text(labelFan, public_buf_l); } diff --git a/Marlin/src/lcd/extui/malyan_lcd.cpp b/Marlin/src/lcd/extui/malyan_lcd.cpp index 780401964..b6a8923a3 100644 --- a/Marlin/src/lcd/extui/malyan_lcd.cpp +++ b/Marlin/src/lcd/extui/malyan_lcd.cpp @@ -178,11 +178,7 @@ void process_lcd_eb_command(const char *command) { #else 0, 0, #endif - #if ENABLED(SDSUPPORT) - done_pct, - #else - 0, - #endif + TERN(SDSUPPORT, done_pct, 0), elapsed_buffer ); write_to_lcd(message_buffer); diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index c2f51b326..23cf26a8c 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -296,21 +296,13 @@ namespace ExtUI { } float getTargetFan_percent(const fan_t fan) { - #if HAS_FAN - return thermalManager.fanSpeedPercent(fan - FAN0); - #else - UNUSED(fan); - return 0; - #endif + UNUSED(fan); + return TERN0(HAS_FAN, thermalManager.fanSpeedPercent(fan - FAN0)); } float getActualFan_percent(const fan_t fan) { - #if HAS_FAN - return thermalManager.scaledFanSpeedPercent(fan - FAN0); - #else - UNUSED(fan); - return 0; - #endif + UNUSED(fan); + return TERN0(HAS_FAN, thermalManager.scaledFanSpeedPercent(fan - FAN0)); } float getAxisPosition_mm(const axis_t axis) { diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index bd017c6bd..ba633741f 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -102,11 +102,11 @@ namespace ExtUI { #if HAS_TRINAMIC_CONFIG float getAxisCurrent_mA(const axis_t); float getAxisCurrent_mA(const extruder_t); - void setAxisCurrent_mA(const_float_t , const axis_t); - void setAxisCurrent_mA(const_float_t , const extruder_t); + void setAxisCurrent_mA(const_float_t, const axis_t); + void setAxisCurrent_mA(const_float_t, const extruder_t); int getTMCBumpSensitivity(const axis_t); - void setTMCBumpSensitivity(const_float_t , const axis_t); + void setTMCBumpSensitivity(const_float_t, const axis_t); #endif celsius_float_t getActualTemp_celsius(const heater_t); @@ -195,18 +195,18 @@ namespace ExtUI { char* getFilamentUsed_str(char buffer[21]); #endif - void setTargetTemp_celsius(const_float_t , const heater_t); - void setTargetTemp_celsius(const_float_t , const extruder_t); - void setTargetFan_percent(const_float_t , const fan_t); + void setTargetTemp_celsius(const_float_t, const heater_t); + void setTargetTemp_celsius(const_float_t, const extruder_t); + void setTargetFan_percent(const_float_t, const fan_t); void coolDown(); - void setAxisPosition_mm(const_float_t , const axis_t, const feedRate_t=0); - void setAxisPosition_mm(const_float_t , const extruder_t, const feedRate_t=0); - void setAxisSteps_per_mm(const_float_t , const axis_t); - void setAxisSteps_per_mm(const_float_t , const extruder_t); + void setAxisPosition_mm(const_float_t, const axis_t, const feedRate_t=0); + void setAxisPosition_mm(const_float_t, const extruder_t, const feedRate_t=0); + void setAxisSteps_per_mm(const_float_t, const axis_t); + void setAxisSteps_per_mm(const_float_t, const extruder_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const axis_t); void setAxisMaxFeedrate_mm_s(const feedRate_t, const extruder_t); - void setAxisMaxAcceleration_mm_s2(const_float_t , const axis_t); - void setAxisMaxAcceleration_mm_s2(const_float_t , const extruder_t); + void setAxisMaxAcceleration_mm_s2(const_float_t, const axis_t); + void setAxisMaxAcceleration_mm_s2(const_float_t, const extruder_t); void setFeedrate_mm_s(const feedRate_t); void setMinFeedrate_mm_s(const feedRate_t); void setMinTravelFeedrate_mm_s(const feedRate_t); @@ -220,7 +220,7 @@ namespace ExtUI { #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t); - void setLinearAdvance_mm_mm_s(const_float_t , const extruder_t); + void setLinearAdvance_mm_mm_s(const_float_t, const extruder_t); #endif #if HAS_JUNCTION_DEVIATION @@ -229,8 +229,8 @@ namespace ExtUI { #else float getAxisMaxJerk_mm_s(const axis_t); float getAxisMaxJerk_mm_s(const extruder_t); - void setAxisMaxJerk_mm_s(const_float_t , const axis_t); - void setAxisMaxJerk_mm_s(const_float_t , const extruder_t); + void setAxisMaxJerk_mm_s(const_float_t, const axis_t); + void setAxisMaxJerk_mm_s(const_float_t, const extruder_t); #endif extruder_t getTool(const uint8_t extruder); @@ -246,7 +246,7 @@ namespace ExtUI { #if HAS_HOTEND_OFFSET float getNozzleOffset_mm(const axis_t, const extruder_t); - void setNozzleOffset_mm(const_float_t , const axis_t, const extruder_t); + void setNozzleOffset_mm(const_float_t, const axis_t, const extruder_t); void normalizeNozzleOffset(const axis_t axis); #endif @@ -255,12 +255,12 @@ namespace ExtUI { #if HAS_BED_PROBE float getProbeOffset_mm(const axis_t); - void setProbeOffset_mm(const_float_t , const axis_t); + void setProbeOffset_mm(const_float_t, const axis_t); #endif #if ENABLED(BACKLASH_GCODE) float getAxisBacklash_mm(const axis_t); - void setAxisBacklash_mm(const_float_t , const axis_t); + void setAxisBacklash_mm(const_float_t, const axis_t); float getBacklashCorrection_percent(); void setBacklashCorrection_percent(const_float_t ); @@ -297,15 +297,15 @@ namespace ExtUI { float getPIDValues_Kp(const extruder_t); float getPIDValues_Ki(const extruder_t); float getPIDValues_Kd(const extruder_t); - void setPIDValues(const_float_t , const_float_t , const_float_t , extruder_t); - void startPIDTune(const_float_t , extruder_t); + void setPIDValues(const_float_t, const_float_t , const_float_t , extruder_t); + void startPIDTune(const_float_t, extruder_t); #endif #if ENABLED(PIDTEMPBED) float getBedPIDValues_Kp(); float getBedPIDValues_Ki(); float getBedPIDValues_Kd(); - void setBedPIDValues(const_float_t , const_float_t , const_float_t ); + void setBedPIDValues(const_float_t, const_float_t , const_float_t ); void startBedPIDTune(const_float_t ); #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index cd93ec1fc..1ad0303ab 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -567,7 +567,7 @@ volatile bool Temperature::raw_temps_ready = false; SHV(bias); #if ENABLED(PRINTER_EVENT_LEDS) - const celsius_float_t start_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius); + const celsius_float_t start_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); LEDColor color = ONHEATINGSTART(); #endif @@ -583,7 +583,7 @@ volatile bool Temperature::raw_temps_ready = false; updateTemperaturesFromRawValues(); // Get the current temperature and constrain it - current_temp = GHV(temp_chamber.celsius, temp_bed.celsius, temp_hotend[heater_id].celsius); + current_temp = GHV(degChamber(), degBed(), degHotend(heater_id)); NOLESS(maxT, current_temp); NOMORE(minT, current_temp); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 2b8a43417..8354b8b86 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1054,8 +1054,6 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { first_tool_is_primed = true; TERN_(TOOLCHANGE_FS_INIT_BEFORE_SWAP, toolchange_extruder_ready[old_tool] = true); // Primed and initialized } - #else - constexpr bool first_tool_is_primed = true; #endif if (new_tool != old_tool || TERN0(PARKING_EXTRUDER, extruder_parked)) { // PARKING_EXTRUDER may need to attach old_tool when homing @@ -1092,7 +1090,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { } else { // For first new tool, change without unloading the old. 'Just prime/init the new' - if (first_tool_is_primed) + if (TERN1(TOOLCHANGE_FS_PRIME_FIRST_USED, first_tool_is_primed)) unscaled_e_move(-toolchange_settings.swap_length, MMM_TO_MMS(toolchange_settings.retract_speed)); TERN_(TOOLCHANGE_FS_PRIME_FIRST_USED, first_tool_is_primed = true); // The first new tool will be primed by toolchanging }