Skip to content

Commit

Permalink
Fix Tune/Fan edit items
Browse files Browse the repository at this point in the history
- Fixes #19617
- Followup to #18400
  • Loading branch information
thinkyhead committed Oct 16, 2020
1 parent 7d47ee7 commit d4b6542
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 79 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ namespace Language_en {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_hu.h
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ namespace Language_hu {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_ro.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ namespace Language_ro {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_ru.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,8 @@ namespace Language_ru {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_tr.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,8 @@ namespace Language_tr {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_uk.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,8 @@ namespace Language_uk {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_zh_CN.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ namespace Language_zh_CN {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
4 changes: 2 additions & 2 deletions Marlin/src/lcd/language/language_zh_TW.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ namespace Language_zh_TW {

#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_FIRST_EXTRA_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
28 changes: 28 additions & 0 deletions Marlin/src/lcd/menu/menu_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,31 @@ class MenuItem_bool : public MenuEditItemBase {
#if ENABLED(LEVEL_BED_CORNERS)
void _lcd_level_bed_corners();
#endif

#if HAS_FAN

#include "../../module/temperature.h"

inline void on_fan_update() {
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
}

#if ENABLED(EXTRA_FAN_SPEED)
#define EDIT_EXTRA_FAN_SPEED(V...) EDIT_ITEM_FAST_N(V)
#else
#define EDIT_EXTRA_FAN_SPEED(...)
#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.new_fan_speed[F], 3, 255); \
}while(0)

#if FAN_COUNT > 1
#define FAN_EDIT_ITEMS(F) _FAN_EDIT_ITEMS(F,FAN_SPEED_N)
#endif

#define SNFAN(N) (ENABLED(SINGLENOZZLE_STANDBY_FAN) && !HAS_FAN##N && EXTRUDERS > N)

#endif // HAS_FAN
37 changes: 7 additions & 30 deletions Marlin/src/lcd/menu/menu_temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,6 @@ void menu_temperature() {
//
#if HAS_FAN

auto on_fan_update = []{
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
};

#if ENABLED(EXTRA_FAN_SPEED)
#define EDIT_EXTRA_FAN_SPEED(V...) EDIT_ITEM_FAST_N(V)
#else
#define EDIT_EXTRA_FAN_SPEED(...)
#endif

#if FAN_COUNT > 1
#define FAN_EDIT_ITEMS(F) do{ \
editable.uint8 = thermalManager.fan_speed[F]; \
EDIT_ITEM_FAST_N(percent, F, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update); \
EDIT_EXTRA_FAN_SPEED(percent, F, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[F], 3, 255); \
}while(0)
#endif

#define SNFAN(N) (ENABLED(SINGLENOZZLE_STANDBY_FAN) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) {
editable.uint8 = singlenozzle_fan_speed[f];
Expand All @@ -218,11 +199,7 @@ void menu_temperature() {
#endif

#if HAS_FAN0
editable.uint8 = thermalManager.fan_speed[0];
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
#endif
_FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
#endif
#if HAS_FAN1
FAN_EDIT_ITEMS(1);
Expand All @@ -232,32 +209,32 @@ void menu_temperature() {
#if HAS_FAN2
FAN_EDIT_ITEMS(2);
#elif SNFAN(2)
singlenozzle_item(1);
singlenozzle_item(2);
#endif
#if HAS_FAN3
FAN_EDIT_ITEMS(3);
#elif SNFAN(3)
singlenozzle_item(1);
singlenozzle_item(3);
#endif
#if HAS_FAN4
FAN_EDIT_ITEMS(4);
#elif SNFAN(4)
singlenozzle_item(1);
singlenozzle_item(4);
#endif
#if HAS_FAN5
FAN_EDIT_ITEMS(5);
#elif SNFAN(5)
singlenozzle_item(1);
singlenozzle_item(5);
#endif
#if HAS_FAN6
FAN_EDIT_ITEMS(6);
#elif SNFAN(6)
singlenozzle_item(1);
singlenozzle_item(6);
#endif
#if HAS_FAN7
FAN_EDIT_ITEMS(7);
#elif SNFAN(7)
singlenozzle_item(1);
singlenozzle_item(7);
#endif

#endif // HAS_FAN
Expand Down
47 changes: 14 additions & 33 deletions Marlin/src/lcd/menu/menu_tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,6 @@ void menu_tune() {
//
#if HAS_FAN

auto on_fan_update = []{
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
};

#if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
auto fan_edit_items = [&](const uint8_t f) {
editable.uint8 = thermalManager.fan_speed[f];
EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
#endif
};
#endif

#define SNFAN(N) (ENABLED(SINGLENOZZLE_STANDBY_FAN) && !HAS_FAN##N && EXTRUDERS > N)
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) {
editable.uint8 = singlenozzle_fan_speed[f];
Expand All @@ -165,46 +150,42 @@ void menu_tune() {
#endif

#if HAS_FAN0
editable.uint8 = thermalManager.fan_speed[0];
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
#if ENABLED(EXTRA_FAN_SPEED)
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
#endif
_FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
#endif
#if HAS_FAN1
fan_edit_items(1);
FAN_EDIT_ITEMS(1);
#elif SNFAN(1)
singlenozzle_item(1);
#endif
#if HAS_FAN2
fan_edit_items(2);
FAN_EDIT_ITEMS(2);
#elif SNFAN(2)
singlenozzle_item(1);
singlenozzle_item(2);
#endif
#if HAS_FAN3
fan_edit_items(3);
FAN_EDIT_ITEMS(3);
#elif SNFAN(3)
singlenozzle_item(1);
singlenozzle_item(3);
#endif
#if HAS_FAN4
fan_edit_items(4);
FAN_EDIT_ITEMS(4);
#elif SNFAN(4)
singlenozzle_item(1);
singlenozzle_item(4);
#endif
#if HAS_FAN5
fan_edit_items(5);
FAN_EDIT_ITEMS(5);
#elif SNFAN(5)
singlenozzle_item(1);
singlenozzle_item(5);
#endif
#if HAS_FAN6
fan_edit_items(6);
FAN_EDIT_ITEMS(6);
#elif SNFAN(6)
singlenozzle_item(1);
singlenozzle_item(6);
#endif
#if HAS_FAN7
fan_edit_items(7);
FAN_EDIT_ITEMS(7);
#elif SNFAN(7)
singlenozzle_item(1);
singlenozzle_item(7);
#endif

#endif // HAS_FAN
Expand Down

0 comments on commit d4b6542

Please sign in to comment.