Browse Source

Add typedef extra_fan_t

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
committed by Scott Lahteine
parent
commit
3341e4f88c
  1. 2
      Marlin/src/lcd/menu/menu_item.h
  2. 21
      Marlin/src/module/temperature.cpp
  3. 5
      Marlin/src/module/temperature.h

2
Marlin/src/lcd/menu/menu_item.h

@ -473,7 +473,7 @@ class MenuItem_bool : public MenuEditItemBase {
#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.new_fan_speed[F], 3, 255); \
EDIT_EXTRA_FAN_SPEED(percent, F, MSG_EXTRA_##L, &thermalManager.extra_fan_speed[F].speed, 3, 255); \
}while(0)
#if FAN_COUNT > 1

21
Marlin/src/module/temperature.cpp

@ -273,19 +273,26 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 }
#if ENABLED(EXTRA_FAN_SPEED)
uint8_t Temperature::old_fan_speed[FAN_COUNT], Temperature::new_fan_speed[FAN_COUNT];
void Temperature::set_temp_fan_speed(const uint8_t fan, const uint16_t tmp_temp) {
switch (tmp_temp) {
Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT];
/**
* Handle the M106 P<fan> T<speed> command:
* T1 = Restore fan speed saved on the last T2
* T2 = Save the fan speed, then set to the last T<3-255> value
* T<3-255> = Set the "extra fan speed"
*/
void Temperature::set_temp_fan_speed(const uint8_t fan, const uint16_t command_or_speed) {
switch (command_or_speed) {
case 1:
set_fan_speed(fan, old_fan_speed[fan]);
set_fan_speed(fan, extra_fan_speed[fan].saved);
break;
case 2:
old_fan_speed[fan] = fan_speed[fan];
set_fan_speed(fan, new_fan_speed[fan]);
extra_fan_speed[fan].saved = fan_speed[fan];
set_fan_speed(fan, extra_fan_speed[fan].speed);
break;
default:
new_fan_speed[fan] = _MIN(tmp_temp, 255U);
extra_fan_speed[fan].speed = _MIN(command_or_speed, 255U);
break;
}
}

5
Marlin/src/module/temperature.h

@ -561,8 +561,9 @@ class Temperature {
}
#if ENABLED(EXTRA_FAN_SPEED)
static uint8_t old_fan_speed[FAN_COUNT], new_fan_speed[FAN_COUNT];
static void set_temp_fan_speed(const uint8_t fan, const uint16_t tmp_temp);
typedef struct { uint8_t saved, speed; } extra_fan_t;
static extra_fan_t extra_fan_speed[FAN_COUNT];
static void set_temp_fan_speed(const uint8_t fan, const uint16_t command_or_speed);
#endif
#if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE)

Loading…
Cancel
Save