diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 7704009107..9d20947fc1 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2722,6 +2722,21 @@ */ //#define EXTRA_FAN_SPEED +/** + * Fan speed offset + * Adds a constant value to fan_speed, to increase/decrease for the totality of your print. + * Can modify the fan speed permanently and proportionnaly , whatever the many fan speed changes + * Threshold must be used to target the normal fan speed with no effect, when full power or very low value. + * 'M106 C <%> : (-100/100) Set the additional speed + * 'M106 B <%> : (0/100) Min threshold of fan speed to be affected by(Any speed below this will not be modified) + * 'M106 D <%> : (0/100) Max threshold of fan speed addition (If set on 70%, all higher fan speeds called will not be modified, like full power, will remains full power) + */ +//#define FAN_SPEED_OFFSET +#if ENABLED(FAN_SPEED_OFFSET) + #define FAN_SPEED_OFFSET_THR_MIN 20 // '%' + #define FAN_SPEED_OFFSET_THR_MAX 70 // '%' +#endif + // @section gcode /** diff --git a/Marlin/src/gcode/temp/M106_M107.cpp b/Marlin/src/gcode/temp/M106_M107.cpp index afa2ebfc56..c51efc4d6a 100644 --- a/Marlin/src/gcode/temp/M106_M107.cpp +++ b/Marlin/src/gcode/temp/M106_M107.cpp @@ -47,6 +47,9 @@ /** * M106: Set Fan Speed * + * B Min threshold of constant addition + * D Max threshold of constant addition + * C Constant value for permanent modification during printing * I Material Preset index (if material presets are defined) * S Speed between 0-255 * P Fan index, if more than one fan @@ -63,6 +66,12 @@ void GcodeSuite::M106() { if (pfan >= _CNT_P) return; if (FAN_IS_REDUNDANT(pfan)) return; + #if ENABLED(FAN_SPEED_OFFSET) + if (parser.seen_test('B')) thermalManager.fan_speed_offset_thr_min[pfan] = parser.intval('B') * (255/100); + if (parser.seen_test('C')) thermalManager.fan_speed_offset[pfan] = parser.intval('C'); + if (parser.seen_test('D')) thermalManager.fan_speed_offset_thr_max[pfan] = parser.intval('D') * (255/100); + #endif + #if ENABLED(EXTRA_FAN_SPEED) const uint16_t t = parser.intval('T'); if (t > 0) return thermalManager.set_temp_fan_speed(pfan, t); @@ -85,6 +94,14 @@ void GcodeSuite::M106() { TERN_(FOAMCUTTER_XYUV, speed *= 2.55f); // Get command in % of max heat + #if ENABLED(FAN_SPEED_OFFSET) + if ((speed > thermalManager.fan_speed_offset_thr_min[pfan]) + && (speed < thermalManager.fan_speed_offset_thr_max[pfan]) + && (thermalManager.fan_speed_offset_thr_min[pfan] < thermalManager.fan_speed_offset_thr_max[pfan]) + ) + speed += (thermalManager.fan_speed_offset[pfan] * 255/100); + #endif + // Set speed, with constraint thermalManager.set_fan_speed(pfan, speed); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 5d49a6afee..111510470b 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -338,6 +338,12 @@ namespace LanguageNarrow_en { LSTR MSG_STORED_FAN_N = _UxGT("Stored Fan ~"); LSTR MSG_EXTRA_FAN_SPEED = _UxGT("Extra Fan Speed"); LSTR MSG_EXTRA_FAN_SPEED_N = _UxGT("Extra Fan Speed ~"); + LSTR MSG_OFFSET_FAN_SPEED = _UxGT("Fan speed offs ~"); + LSTR MSG_OFFSET_MIN_FAN_SPEED = _UxGT("Fan offs min ~"); + LSTR MSG_OFFSET_MAX_FAN_SPEED = _UxGT("Fan offs max ~"); + LSTR MSG_OFFSET_FAN_SPEED_N = _UxGT("Fan speed offs ~"); + LSTR MSG_OFFSET_MIN_FAN_SPEED_N = _UxGT("Fan offs min ~"); + LSTR MSG_OFFSET_MAX_FAN_SPEED_N = _UxGT("Fan offs max ~"); LSTR MSG_CONTROLLER_FAN = _UxGT("Controller Fan"); LSTR MSG_CONTROLLER_FAN_IDLE_SPEED = _UxGT("Idle Speed"); LSTR MSG_CONTROLLER_FAN_AUTO_ON = _UxGT("Auto Mode"); diff --git a/Marlin/src/lcd/language/language_fr_na.h b/Marlin/src/lcd/language/language_fr_na.h index 8fb7b68026..6f8076e813 100644 --- a/Marlin/src/lcd/language/language_fr_na.h +++ b/Marlin/src/lcd/language/language_fr_na.h @@ -246,6 +246,12 @@ namespace LanguageNarrow_fr_na { LSTR MSG_EXTRA_FAN_SPEED = _UxGT("Extra ventil. "); LSTR MSG_EXTRA_FAN_SPEED_N = _UxGT("Extra ventil. ~"); + LSTR MSG_OFFSET_FAN_SPEED = _UxGT("Ventil. sup ~"); + LSTR MSG_OFFSET_MIN_FAN_SPEED = _UxGT("Seuil min ~"); + LSTR MSG_OFFSET_MAX_FAN_SPEED = _UxGT("Seuil max ~"); + LSTR MSG_OFFSET_FAN_SPEED_N = _UxGT("Ventil. sup ~"); + LSTR MSG_OFFSET_MIN_FAN_SPEED_N = _UxGT("Seuil min ~"); + LSTR MSG_OFFSET_MAX_FAN_SPEED_N = _UxGT("Seuil max ~"); LSTR MSG_FLOW = _UxGT("Flux"); LSTR MSG_FLOW_N = _UxGT("Flux ~"); LSTR MSG_CONTROL = _UxGT("Controler"); diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 07aa59675a..573a79eb8b 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -578,20 +578,44 @@ class MenuItem_bool : public MenuEditItemBase { #define EDIT_EXTRA_FAN_SPEED(...) #endif - #if FAN_COUNT == 1 - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED + #if ENABLED(FAN_SPEED_OFFSET) + #define EDIT_OFFSET_FAN_SPEED(V...) EDIT_ITEM_FAST_N(V) + #define EDIT_OFFSET_MIN_FAN_SPEED(V...) EDIT_ITEM_FAST_N(V) + #define EDIT_OFFSET_MAX_FAN_SPEED(V...) EDIT_ITEM_FAST_N(V) #else - #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N - #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N + #define EDIT_OFFSET_FAN_SPEED(...) + #define EDIT_OFFSET_MIN_FAN_SPEED(...) + #define EDIT_OFFSET_MAX_FAN_SPEED(...) + #endif + + #if FAN_COUNT == 1 + #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED + #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED + #define MSG_OFFSET_FIRST_FAN_SPEED MSG_OFFSET_FAN_SPEED + #define MSG_OFFSET_MIN_FIRST_FAN_SPEED MSG_OFFSET_MIN_FAN_SPEED + #define MSG_OFFSET_MAX_FIRST_FAN_SPEED MSG_OFFSET_MAX_FAN_SPEED + #else + #define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N + #define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N + #define MSG_OFFSET_FIRST_FAN_SPEED MSG_OFFSET_FAN_SPEED_N + #define MSG_OFFSET_MIN_FIRST_FAN_SPEED MSG_OFFSET_MIN_FAN_SPEED_N + #define MSG_OFFSET_MAX_FIRST_FAN_SPEED MSG_OFFSET_MAX_FAN_SPEED_N #endif #define _FAN_EDIT_ITEMS(F,L) do{ \ editable.uint8 = thermalManager.fan_speed[F]; \ EDIT_ITEM_FAST_N(percent, F, MSG_##L, &editable.uint8, 0, 255, on_fan_update); \ EDIT_EXTRA_FAN_SPEED(percent, F, MSG_EXTRA_##L, &thermalManager.extra_fan_speed[F].speed, 3, 255); \ + EDIT_OFFSET_FAN_SPEED(int3, F, MSG_OFFSET_##L, &thermalManager.fan_speed_offset[F], -100, 100); \ + EDIT_OFFSET_MIN_FAN_SPEED(percent, F, MSG_OFFSET_MIN_##L, &thermalManager.fan_speed_offset_thr_min[F], 0, 255); \ + EDIT_OFFSET_MAX_FAN_SPEED(percent, F, MSG_OFFSET_MAX_##L, &thermalManager.fan_speed_offset_thr_max[F], 0, 255); \ }while(0) + /*EDIT_TUNE_FAN_SPEED(percent, F, MSG_MODIFIER_##L, &thermalManager.fan_speed_offset[F], -255, 255); \ + EDIT_MIN_TUNE_FAN_SPEED(percent, F, MSG_MODIFIER_MIN_##L, &thermalManager.fan_speed_offset_thr_min[F], 1, 255); \ + EDIT_MAX_TUNE_FAN_SPEED(percent, F, MSG_MODIFIER_MAX_##L, &thermalManager.fan_speed_offset_thr_max[F], 1, 255); \ +*/ + #if FAN_COUNT > 1 #define FAN_EDIT_ITEMS(F) _FAN_EDIT_ITEMS(F, FAN_SPEED_N) #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 15cfeac911..6ab2b15142 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -912,6 +912,12 @@ class Temperature { static void set_temp_fan_speed(const uint8_t fan, const uint16_t command_or_speed); #endif + #if ENABLED(FAN_SPEED_OFFSET) + int16_t fan_speed_offset[FAN_COUNT] = {0}; + uint8_t fan_speed_offset_thr_min[FAN_COUNT] = {uint8_t(FAN_SPEED_OFFSET_THR_MIN * 255/100)}; + uint8_t fan_speed_offset_thr_max[FAN_COUNT] = {uint8_t(FAN_SPEED_OFFSET_THR_MAX * 255/100)}; + #endif + #if ANY(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) void set_fans_paused(const bool p); #endif