From 8b3c7dda755ebce5bd57a7ce52891a137ea12b35 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 27 Apr 2020 04:41:18 -0500 Subject: [PATCH] Add HAS_FAN and others --- Marlin/src/feature/pause.cpp | 4 +-- Marlin/src/feature/powerloss.cpp | 4 +-- Marlin/src/feature/powerloss.h | 2 +- Marlin/src/feature/probe_temp_comp.h | 2 +- Marlin/src/gcode/bedlevel/G26.cpp | 4 +-- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 +- Marlin/src/gcode/config/M217.cpp | 2 +- Marlin/src/gcode/control/M42.cpp | 4 +-- Marlin/src/gcode/control/M80_M81.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/gcode/lcd/M145.cpp | 2 +- Marlin/src/gcode/temp/M106_M107.cpp | 4 +-- Marlin/src/inc/Conditionals_LCD.h | 2 ++ Marlin/src/inc/Conditionals_post.h | 2 ++ Marlin/src/inc/SanityCheck.h | 2 +- Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp | 4 +-- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp | 4 +-- Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h | 4 +-- .../extui/lib/dgus/fysetc/DGUSDisplayDef.cpp | 8 ++--- .../extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp | 10 +++--- .../extui/lib/dgus/origin/DGUSDisplayDef.cpp | 4 +-- .../screens/temperature_screen.cpp | 6 ++-- Marlin/src/lcd/extui/ui_api.cpp | 8 ++--- Marlin/src/lcd/menu/menu.h | 2 +- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_temperature.cpp | 31 +++++++------------ Marlin/src/lcd/menu/menu_tune.cpp | 6 ++-- Marlin/src/lcd/menu/menu_ubl.cpp | 4 +-- Marlin/src/module/planner.cpp | 14 ++++----- Marlin/src/module/planner.h | 2 +- Marlin/src/module/temperature.cpp | 6 ++-- Marlin/src/module/temperature.h | 8 ++--- Marlin/src/module/tool_change.cpp | 8 ++--- Marlin/src/module/tool_change.h | 2 +- 35 files changed, 85 insertions(+), 90 deletions(-) diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 4b50d3df26..396819324c 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -402,7 +402,7 @@ bool pause_print(const float &retract, const xyz_pos_t &park_point, const float // Wait for buffered blocks to complete planner.synchronize(); - #if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && FAN_COUNT > 0 + #if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN thermalManager.set_fans_paused(true); #endif @@ -621,7 +621,7 @@ void resume_print(const float &slow_load_length/*=0*/, const float &fast_load_le if (did_pause_print) { card.startFileprint(); --did_pause_print; } #endif - #if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && FAN_COUNT > 0 + #if ENABLED(ADVANCED_PAUSE_FANS_PAUSE) && HAS_FAN thermalManager.set_fans_paused(false); #endif diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index ccb85049d8..02a97e3436 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -195,7 +195,7 @@ void PrintJobRecovery::save(const bool force/*=false*/) { TERN_(HAS_HEATED_BED, info.target_temperature_bed = thermalManager.temp_bed.target); - #if FAN_COUNT + #if HAS_FAN COPY(info.fan_speed, thermalManager.fan_speed); #endif @@ -508,7 +508,7 @@ void PrintJobRecovery::resume() { DEBUG_ECHOLNPAIR("target_temperature_bed: ", info.target_temperature_bed); #endif - #if FAN_COUNT + #if HAS_FAN DEBUG_ECHOPGM("fan_speed: "); FANS_LOOP(i) { DEBUG_ECHO(int(info.fan_speed[i])); diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 34a26b6eb9..71f9861e87 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -76,7 +76,7 @@ typedef struct { int16_t target_temperature_bed; #endif - #if FAN_COUNT + #if HAS_FAN uint8_t fan_speed[FAN_COUNT]; #endif diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 4ce7066c15..5ae4175104 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -65,7 +65,7 @@ class ProbeTempComp { static constexpr xy_pos_t measure_point = PTC_PROBE_POS; // Coordinates to probe //measure_point = { 12.0f, 7.3f }; // Coordinates for the MK52 magnetic heatbed - static constexpr int probe_calib_bed_temp = BED_MAXTEMP - 10, // Bed temperature while calibrating probe + static constexpr int probe_calib_bed_temp = BED_MAX_TARGET, // Bed temperature while calibrating probe bed_calib_probe_temp = 30; // Probe temperature while calibrating bed static int16_t *sensor_z_offsets[TSI_COUNT], diff --git a/Marlin/src/gcode/bedlevel/G26.cpp b/Marlin/src/gcode/bedlevel/G26.cpp index 9f3833803a..355f1ffa1c 100644 --- a/Marlin/src/gcode/bedlevel/G26.cpp +++ b/Marlin/src/gcode/bedlevel/G26.cpp @@ -511,8 +511,8 @@ void GcodeSuite::G26() { #if HAS_HEATED_BED if (parser.seenval('B')) { g26_bed_temp = parser.value_celsius(); - if (g26_bed_temp && !WITHIN(g26_bed_temp, 40, (BED_MAXTEMP - 10))) { - SERIAL_ECHOLNPAIR("?Specified bed temperature not plausible (40-", int(BED_MAXTEMP - 10), "C)."); + if (g26_bed_temp && !WITHIN(g26_bed_temp, 40, BED_MAX_TARGET)) { + SERIAL_ECHOLNPAIR("?Specified bed temperature not plausible (40-", int(BED_MAX_TARGET), "C)."); return; } } diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 02895c7e05..adabf22344 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -201,7 +201,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_MAXTEMP - 10) break; + if (isnan(measured_z) || target_bed > BED_MAX_TARGET) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 6e8c899fb0..a1e53e5ecb 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -115,7 +115,7 @@ void GcodeSuite::M217() { if (parser.seenval('P')) { const int16_t v = parser.value_linear_units(); toolchange_settings.prime_speed = constrain(v, 10, 5400); } if (parser.seenval('R')) { const int16_t v = parser.value_linear_units(); toolchange_settings.retract_speed = constrain(v, 10, 5400); } if (parser.seenval('U')) { const int16_t v = parser.value_linear_units(); toolchange_settings.unretract_speed = constrain(v, 10, 5400); } - #if TOOLCHANGE_FS_FAN >= 0 && FAN_COUNT > 0 + #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN if (parser.seenval('F')) { const int16_t v = parser.value_linear_units(); toolchange_settings.fan_speed = constrain(v, 0, 255); } if (parser.seenval('G')) { const int16_t v = parser.value_linear_units(); toolchange_settings.fan_time = constrain(v, 1, 30); } #endif diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index 74625b0318..4b2b7fc0f7 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -24,7 +24,7 @@ #include "../../MarlinCore.h" // for pin_is_protected #include "../../inc/MarlinConfig.h" -#if FAN_COUNT > 0 +#if HAS_FAN #include "../../module/temperature.h" #endif @@ -64,7 +64,7 @@ void GcodeSuite::M42() { if (!parser.seenval('S')) return; const byte pin_status = parser.value_byte(); - #if FAN_COUNT > 0 + #if HAS_FAN switch (pin) { #if HAS_FAN0 case FAN0_PIN: thermalManager.fan_speed[0] = pin_status; return; diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index a5ff7d05d9..6ba0949027 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -92,7 +92,7 @@ void GcodeSuite::M81() { print_job_timer.stop(); planner.finish_and_disable(); - #if FAN_COUNT > 0 + #if HAS_FAN thermalManager.zero_fan_speeds(); #if ENABLED(PROBING_FANS_OFF) thermalManager.fans_paused = false; diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 8bebeb1c15..a6f54ee022 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -467,7 +467,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 105: M105(); return; // M105: Report Temperatures (and say "ok") - #if FAN_COUNT > 0 + #if HAS_FAN case 106: M106(); break; // M106: Fan On case 107: M107(); break; // M107: Fan Off #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index a3d37262f2..6a4a7af985 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -554,7 +554,7 @@ private: static void M105(); - #if FAN_COUNT > 0 + #if HAS_FAN static void M106(); static void M107(); #endif diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 3116727533..a66c62e8af 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -52,7 +52,7 @@ void GcodeSuite::M145() { #if TEMP_SENSOR_BED != 0 if (parser.seenval('B')) { v = parser.value_int(); - ui.preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAXTEMP - 10); + ui.preheat_bed_temp[material] = constrain(v, BED_MINTEMP, BED_MAX_TARGET); } #endif } diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index 2415484d51..7fbc53297e 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if FAN_COUNT > 0 +#if HAS_FAN #include "../gcode.h" #include "../../module/motion.h" @@ -74,4 +74,4 @@ void GcodeSuite::M107() { thermalManager.set_fan_speed(p, 0); } -#endif // FAN_COUNT > 0 +#endif // HAS_FAN diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 14aa031ac6..9558c314d1 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -408,6 +408,8 @@ */ #if EXTRUDERS == 0 + #undef EXTRUDERS + #define EXTRUDERS 0 #undef DISTINCT_E_FACTORS #undef SINGLENOZZLE #undef SWITCHING_EXTRUDER diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 67116f662c..b4f68fcf7b 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1707,6 +1707,7 @@ // Shorthand for common combinations #if HAS_TEMP_BED && HAS_HEATER_BED #define HAS_HEATED_BED 1 + #define BED_MAX_TARGET (BED_MAXTEMP - 10) #endif #if HAS_HEATED_BED || HAS_TEMP_CHAMBER #define BED_OR_CHAMBER 1 @@ -2084,6 +2085,7 @@ #endif #if FAN_COUNT > 0 + #define HAS_FAN 1 #define WRITE_FAN(n, v) WRITE(FAN##n##_PIN, (v) ^ FAN_INVERTING) #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 181ca8b88e..8e37362971 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -262,7 +262,7 @@ #error "LCD_PIN_RESET is now LCD_RESET_PIN. Please update your pins definitions." #elif defined(EXTRUDER_0_AUTO_FAN_PIN) || defined(EXTRUDER_1_AUTO_FAN_PIN) || defined(EXTRUDER_2_AUTO_FAN_PIN) || defined(EXTRUDER_3_AUTO_FAN_PIN) #error "EXTRUDER_[0123]_AUTO_FAN_PIN is now E[0123]_AUTO_FAN_PIN. Please update your Configuration_adv.h." -#elif defined(PID_FAN_SCALING) && FAN_COUNT <= 0 +#elif defined(PID_FAN_SCALING) && !HAS_FAN #error "PID_FAN_SCALING needs at least one fan enabled." #elif defined(min_software_endstops) || defined(max_software_endstops) #error "(min|max)_software_endstops are now (MIN|MAX)_SOFTWARE_ENDSTOPS. Please update your configuration." diff --git a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp index ff76741ce7..18befefc13 100644 --- a/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp @@ -1072,7 +1072,7 @@ void MarlinUI::draw_status_screen() { if (TERN0(HAS_HEATED_BED, thermalManager.degTargetBed() > 0)) leds |= LED_A; if (TERN0(HAS_HOTEND, thermalManager.degTargetHotend(0) > 0)) leds |= LED_B; - #if FAN_COUNT > 0 + #if HAS_FAN if ( TERN0(HAS_FAN0, thermalManager.fan_speed[0]) || TERN0(HAS_FAN1, thermalManager.fan_speed[1]) || TERN0(HAS_FAN2, thermalManager.fan_speed[2]) @@ -1082,7 +1082,7 @@ void MarlinUI::draw_status_screen() { || TERN0(HAS_FAN6, thermalManager.fan_speed[6]) || TERN0(HAS_FAN7, thermalManager.fan_speed[7]) ) leds |= LED_C; - #endif // FAN_COUNT > 0 + #endif // HAS_FAN if (TERN0(HAS_MULTI_HOTEND, thermalManager.degTargetHotend(1) > 0)) leds |= LED_C; diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp index 91acd0a360..ccaef782a6 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.cpp @@ -277,7 +277,7 @@ void DGUSScreenVariableHandler::DGUSLCD_SendStringToDisplayPGM(DGUS_VP_Variable #endif // Send fan status value to the display. -#if FAN_COUNT > 0 +#if HAS_FAN void DGUSScreenVariableHandler::DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var) { if (var.memadr) { DEBUG_ECHOPAIR(" DGUSLCD_SendFanStatusToDisplay ", var.VP); @@ -872,7 +872,7 @@ void DGUSScreenVariableHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, } #endif -#if FAN_COUNT +#if HAS_FAN void DGUSScreenVariableHandler::HandleFanControl(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleFanControl"); *(uint8_t*)var.memadr = *(uint8_t*)var.memadr > 0 ? 0 : 255; diff --git a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h index 00e626adc9..9eddfcf3b5 100644 --- a/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/lib/dgus/DGUSDisplay.h @@ -151,7 +151,7 @@ public: // Hook for live z adjust action static void HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr); #endif - #if FAN_COUNT > 0 + #if HAS_FAN // Hook for fan control static void HandleFanControl(DGUS_VP_Variable &var, void *val_ptr); #endif @@ -221,7 +221,7 @@ public: static void DGUSLCD_SendPrintAccTimeToDisplay(DGUS_VP_Variable &var); static void DGUSLCD_SendPrintsTotalToDisplay(DGUS_VP_Variable &var); #endif - #if FAN_COUNT > 0 + #if HAS_FAN static void DGUSLCD_SendFanStatusToDisplay(DGUS_VP_Variable &var); #endif static void DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var); diff --git a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp index 4a51606314..b9f7c8543d 100644 --- a/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/fysetc/DGUSDisplayDef.cpp @@ -56,7 +56,7 @@ const uint16_t VPList_Main[] PROGMEM = { #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS, #endif - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, VP_FAN0_STATUS, #endif VP_XPos, VP_YPos, VP_ZPos, @@ -92,7 +92,7 @@ const uint16_t VPList_Status[] PROGMEM = { #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, #endif - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, #endif VP_XPos, VP_YPos, VP_ZPos, @@ -192,7 +192,7 @@ const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, #endif - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, #if FAN_COUNT > 1 VP_Fan1_Percentage, @@ -410,7 +410,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif // Fan Data - #if FAN_COUNT + #if HAS_FAN #define FAN_VPHELPER(N) \ VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8, &DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay), \ VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &DGUSScreenVariableHandler::HandleFanControl, nullptr), \ diff --git a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp index b641ec9ec7..ab5b453855 100644 --- a/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/hiprecy/DGUSDisplayDef.cpp @@ -56,7 +56,7 @@ const uint16_t VPList_Main[] PROGMEM = { #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, VP_BED_STATUS, #endif - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, VP_FAN0_STATUS, #endif VP_XPos, VP_YPos, VP_ZPos, @@ -92,7 +92,7 @@ const uint16_t VPList_Status[] PROGMEM = { #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, #endif - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, #endif VP_XPos, VP_YPos, VP_ZPos, @@ -191,7 +191,7 @@ const uint16_t VPList_SD_PrintManipulation[] PROGMEM = { #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, #endif - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, #if FAN_COUNT > 1 VP_Fan1_Percentage, @@ -212,7 +212,7 @@ const uint16_t VPList_SDPrintTune[] PROGMEM = { VP_T_Bed_Is, VP_T_Bed_Set, #endif VP_Feedrate_Percentage, - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, #endif VP_Flowrate_E0, @@ -409,7 +409,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif // Fan Data - #if FAN_COUNT + #if HAS_FAN #define FAN_VPHELPER(N) \ VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8, &DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay), \ VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &DGUSScreenVariableHandler::HandleFanControl, nullptr), \ diff --git a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp index 81e8a32a7f..b6a7fca903 100644 --- a/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/lib/dgus/origin/DGUSDisplayDef.cpp @@ -73,7 +73,7 @@ const uint16_t VPList_Status[] PROGMEM = { #if HAS_HEATED_BED VP_T_Bed_Is, VP_T_Bed_Set, #endif - #if FAN_COUNT > 0 + #if HAS_FAN VP_Fan0_Percentage, #endif VP_XPos, VP_YPos, VP_ZPos, @@ -233,7 +233,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = { #endif // Fan Data - #if FAN_COUNT + #if HAS_FAN #define FAN_VPHELPER(N) \ VPHELPER(VP_Fan##N##_Percentage, &thermalManager.fan_speed[N], DGUSScreenVariableHandler::DGUSLCD_PercentageToUint8, &DGUSScreenVariableHandler::DGUSLCD_SendPercentageToDisplay), \ VPHELPER(VP_FAN##N##_CONTROL, &thermalManager.fan_speed[N], &DGUSScreenVariableHandler::HandleFanControl, nullptr), \ diff --git a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp index c647812a0a..5f8a74b0b0 100644 --- a/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp +++ b/Marlin/src/lcd/extui/lib/ftdi_eve_touch_ui/screens/temperature_screen.cpp @@ -60,7 +60,7 @@ void TemperatureScreen::onRedraw(draw_mode_t what) { #if HAS_HEATED_CHAMBER w.adjuster( 22, GET_TEXT_F(MSG_CHAMBER), getTargetTemp_celsius(CHAMBER)); #endif - #if FAN_COUNT > 0 + #if HAS_FAN w.color(fan_speed).units(GET_TEXT_F(MSG_UNITS_PERCENT)); w.adjuster( 10, GET_TEXT_F(MSG_FAN_SPEED), getTargetFan_percent(FAN0)); #endif @@ -90,7 +90,7 @@ bool TemperatureScreen::onTouchHeld(uint8_t tag) { case 8: UI_DECREMENT(TargetTemp_celsius, E3); break; case 9: UI_INCREMENT(TargetTemp_celsius, E3); break; #endif - #if FAN_COUNT > 0 + #if HAS_FAN case 10: UI_DECREMENT(TargetFan_percent, FAN0); break; case 11: UI_INCREMENT(TargetFan_percent, FAN0); break; #endif @@ -99,7 +99,7 @@ bool TemperatureScreen::onTouchHeld(uint8_t tag) { REPEAT(HOTENDS, _HOTEND_OFF); TERN_(HAS_HEATED_BED, setTargetTemp_celsius(0,BED)); TERN_(HAS_HEATED_CHAMBER, setTargetTemp_celsius(0,CHAMBER)); - #if FAN_COUNT > 0 + #if HAS_FAN setTargetFan_percent(0,FAN0); #endif break; diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 7a1c0fb251..fe2d680994 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -293,7 +293,7 @@ namespace ExtUI { } float getTargetFan_percent(const fan_t fan) { - #if FAN_COUNT > 0 + #if HAS_FAN return thermalManager.fanPercent(thermalManager.fan_speed[fan - FAN0]); #else UNUSED(fan); @@ -302,7 +302,7 @@ namespace ExtUI { } float getActualFan_percent(const fan_t fan) { - #if FAN_COUNT > 0 + #if HAS_FAN return thermalManager.fanPercent(thermalManager.scaledFanSpeed(fan - FAN0)); #else UNUSED(fan); @@ -940,7 +940,7 @@ namespace ExtUI { #endif #if HAS_HEATED_BED if (heater == BED) - thermalManager.setTargetBed(LROUND(constrain(value, 0, BED_MAXTEMP - 10))); + thermalManager.setTargetBed(LROUND(constrain(value, 0, BED_MAX_TARGET))); else #endif { @@ -963,7 +963,7 @@ namespace ExtUI { } void setTargetFan_percent(const float value, const fan_t fan) { - #if FAN_COUNT > 0 + #if HAS_FAN if (fan < FAN_COUNT) thermalManager.set_fan_speed(fan - FAN0, map(constrain(value, 0, 100), 0, 100, 0, 255)); #else diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index ca475a115e..824b340377 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -522,7 +522,7 @@ void menu_move(); #endif // First Fan Speed title in "Tune" and "Control>Temperature" menus -#if FAN_COUNT > 0 && HAS_FAN0 +#if HAS_FAN && HAS_FAN0 #if FAN_COUNT > 1 #define FAN_SPEED_1_SUFFIX " 1" #else diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index cb7360d09b..e5ad0f9cbf 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -334,7 +334,7 @@ void menu_advanced_settings(); EDIT_ITEM(int3, MSG_NOZZLE, &ui.preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15); #endif #if HAS_HEATED_BED - EDIT_ITEM(int3, MSG_BED, &ui.preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 10); + EDIT_ITEM(int3, MSG_BED, &ui.preheat_bed_temp[material], BED_MINTEMP, BED_MAX_TARGET); #endif #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings); diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 25c9125c27..1e610ec190 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -47,47 +47,38 @@ uint8_t MarlinUI::preheat_fan_speed[2]; // "Temperature" submenu items // - void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb) { #if HAS_HOTEND if (indh >= 0 && ui.preheat_hotend_temp[indh] > 0) setTargetHotend(_MIN(heater_maxtemp[e] - 15, ui.preheat_hotend_temp[indh]), e); #else + UNUSED(e); UNUSED(temph); #endif #if HAS_HEATED_BED - if (indb >= 0 && ui.preheat_bed_temp[indb] >= 0) setTargetBed(ui.preheat_bed_temp[indb]); + if (indb >= 0 && ui.preheat_bed_temp[indb] > 0) setTargetBed(ui.preheat_bed_temp[indb]); #else UNUSED(indb); #endif #if HAS_FAN set_fan_speed(( #if FAN_COUNT > 1 - active_extruder < FAN_COUNT ? active_extruder : 0 - #else - 0 + active_extruder < FAN_COUNT ? active_extruder : #endif - ), fan); - #else - UNUSED(fan); + 0), ui.preheat_fan_speed[m] + ); #endif ui.return_to_status(); } #if HAS_TEMP_HOTEND - inline void _preheat_end(const uint8_t m, const uint8_t e) { - thermalManager.lcd_preheat(e, m, -1); - } + inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } #if HAS_HEATED_BED - inline void _preheat_both(const uint8_t m, const uint8_t e) { - thermalManager.lcd_preheat(e, m, m); - } + inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); } #endif #endif #if HAS_HEATED_BED - inline void _preheat_bed(const uint8_t m) { - thermalManager.lcd_preheat(-1, -1, m); - } + inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(-1, -1, m); } #endif #if HAS_TEMP_HOTEND || HAS_HEATED_BED @@ -186,7 +177,7 @@ void menu_temperature() { // Bed: // #if HAS_HEATED_BED - EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed); + EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed); #endif // @@ -199,7 +190,7 @@ void menu_temperature() { // // Fan Speed: // - #if FAN_COUNT > 0 + #if HAS_FAN auto on_fan_update = []{ thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8); @@ -266,7 +257,7 @@ void menu_temperature() { singlenozzle_item(1); #endif - #endif // FAN_COUNT > 0 + #endif // HAS_FAN #if HAS_TEMP_HOTEND diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 2f4c751775..4ef7e48fa3 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -132,13 +132,13 @@ void menu_tune() { // Bed: // #if HAS_HEATED_BED - EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed); + EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAX_TARGET, thermalManager.start_watching_bed); #endif // // Fan Speed: // - #if FAN_COUNT > 0 + #if HAS_FAN auto on_fan_update = []{ thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8); @@ -205,7 +205,7 @@ void menu_tune() { singlenozzle_item(1); #endif - #endif // FAN_COUNT > 0 + #endif // HAS_FAN // // Flow: diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 31459cf215..dde17b0192 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -128,9 +128,9 @@ void _lcd_ubl_build_custom_mesh() { void _lcd_ubl_custom_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_BUILD_MESH_MENU); - EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 10)); + EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 15)); #if HAS_HEATED_BED - EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, (BED_MAXTEMP - 10)); + EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, BED_MAX_TARGET); #endif ACTION_ITEM(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh); END_MENU(); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index b7dc639246..0643ba1cb3 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1264,7 +1264,7 @@ void Planner::check_axes_activity() { xyze_bool_t axis_active = { false }; #endif - #if FAN_COUNT > 0 + #if HAS_FAN uint8_t tail_fan_speed[FAN_COUNT]; #endif @@ -1279,11 +1279,11 @@ void Planner::check_axes_activity() { if (has_blocks_queued()) { - #if FAN_COUNT > 0 || ENABLED(BARICUDA) + #if HAS_FAN || ENABLED(BARICUDA) block_t *block = &block_buffer[block_buffer_tail]; #endif - #if FAN_COUNT > 0 + #if HAS_FAN FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i, block->fan_speed[i]); #endif @@ -1304,7 +1304,7 @@ void Planner::check_axes_activity() { TERN_(HAS_CUTTER, cutter.refresh()); - #if FAN_COUNT > 0 + #if HAS_FAN FANS_LOOP(i) tail_fan_speed[i] = thermalManager.scaledFanSpeed(i); #endif @@ -1326,7 +1326,7 @@ void Planner::check_axes_activity() { // // Update Fan speeds // - #if FAN_COUNT > 0 + #if HAS_FAN #if FAN_KICKSTART_TIME > 0 static millis_t fan_kick_end[FAN_COUNT] = { 0 }; @@ -1366,7 +1366,7 @@ void Planner::check_axes_activity() { TERN_(HAS_FAN5, FAN_SET(5)); TERN_(HAS_FAN6, FAN_SET(6)); TERN_(HAS_FAN7, FAN_SET(7)); - #endif // FAN_COUNT > 0 + #endif // HAS_FAN TERN_(AUTOTEMP, getHighESpeed()); @@ -1906,7 +1906,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, TERN_(HAS_CUTTER, block->cutter_power = cutter.power); - #if FAN_COUNT > 0 + #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 8b6cdcada0..bf585320de 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -175,7 +175,7 @@ typedef struct block_t { cutter_power_t cutter_power; // Power level for Spindle, Laser, etc. #endif - #if FAN_COUNT > 0 + #if HAS_FAN uint8_t fan_speed[FAN_COUNT]; #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 3b11dcba57..44de7cc40c 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -152,7 +152,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, uint8_t Temperature::chamberfan_speed; // = 0 #endif -#if FAN_COUNT > 0 +#if HAS_FAN uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } @@ -219,7 +219,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #endif -#endif // FAN_COUNT > 0 +#endif // HAS_FAN #if WATCH_HOTENDS hotend_watch_t Temperature::watch_hotend[HOTENDS]; // = { { 0 } } @@ -400,7 +400,7 @@ volatile bool Temperature::raw_temps_ready = false; TERN_(HAS_AUTO_FAN, next_auto_fan_check_ms = next_temp_ms + 2500UL); - if (target > GHV(BED_MAXTEMP - 10, temp_range[heater].maxtemp - 15)) { + if (target > GHV(BED_MAX_TARGET, temp_range[heater].maxtemp - 15)) { SERIAL_ECHOLNPGM(STR_PID_TEMP_TOO_HIGH); TERN_(EXTENSIBLE_UI, ExtUI::onPidTuning(ExtUI::result_t::PID_TEMP_TOO_HIGH)); return; diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index c08f4dc754..b4cba62b10 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -477,7 +477,7 @@ class Temperature { static float analog_to_celsius_chamber(const int raw); #endif - #if FAN_COUNT > 0 + #if HAS_FAN static uint8_t fan_speed[FAN_COUNT]; #define FANS_LOOP(I) LOOP_L_N(I, FAN_COUNT) @@ -517,10 +517,10 @@ class Temperature { void set_fans_paused(const bool p); #endif - #endif // FAN_COUNT > 0 + #endif // HAS_FAN static inline void zero_fan_speeds() { - #if FAN_COUNT > 0 + #if HAS_FAN FANS_LOOP(i) set_fan_speed(i, 0); #endif } @@ -634,7 +634,7 @@ class Temperature { TERN_(AUTO_POWER_CONTROL, powerManager.power_on()); temp_bed.target = #ifdef BED_MAXTEMP - _MIN(celsius, BED_MAXTEMP - 10) + _MIN(celsius, BED_MAX_TARGET) #else celsius #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index d7f6ef15cc..c1060c1233 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -49,7 +49,7 @@ #if ENABLED(SINGLENOZZLE) uint16_t singlenozzle_temp[EXTRUDERS]; - #if FAN_COUNT > 0 + #if HAS_FAN uint8_t singlenozzle_fan_speed[EXTRUDERS]; #endif #endif @@ -819,7 +819,7 @@ void tool_change_prime() { #endif // Cool down with fan - #if TOOLCHANGE_FS_FAN >= 0 && FAN_COUNT > 0 + #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN const int16_t fansp = thermalManager.fan_speed[TOOLCHANGE_FS_FAN]; thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed; safe_delay(toolchange_settings.fan_time * 1000); @@ -1060,7 +1060,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (should_move) { #if ENABLED(SINGLENOZZLE) - #if FAN_COUNT > 0 + #if HAS_FAN singlenozzle_fan_speed[old_tool] = thermalManager.fan_speed[0]; thermalManager.fan_speed[0] = singlenozzle_fan_speed[new_tool]; #endif @@ -1098,7 +1098,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #endif // Cool down with fan - #if TOOLCHANGE_FS_FAN >= 0 && FAN_COUNT > 0 + #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN const int16_t fansp = thermalManager.fan_speed[TOOLCHANGE_FS_FAN]; thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed; safe_delay(toolchange_settings.fan_time * 1000); diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 534a17e946..7e73bd7bb2 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -110,7 +110,7 @@ #if ENABLED(SINGLENOZZLE) extern uint16_t singlenozzle_temp[EXTRUDERS]; - #if FAN_COUNT > 0 + #if HAS_FAN extern uint8_t singlenozzle_fan_speed[EXTRUDERS]; #endif #endif