Fix Tune/Fan edit items

- Fixes #19617
- Followup to #18400
This commit is contained in:
Scott Lahteine 2020-10-04 14:29:02 -05:00 committed by Scott Lahteine
parent 85c6ffb364
commit 770f2b1e02
11 changed files with 65 additions and 79 deletions

View File

@ -657,8 +657,8 @@ namespace Language_en {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -623,8 +623,8 @@ namespace Language_hu {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -631,8 +631,8 @@ namespace Language_ro {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -767,8 +767,8 @@ namespace Language_ru {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -590,8 +590,8 @@ namespace Language_tr {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -762,8 +762,8 @@ namespace Language_uk {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -630,8 +630,8 @@ namespace Language_zh_CN {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -501,8 +501,8 @@ namespace Language_zh_TW {
#if FAN_COUNT == 1 #if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED #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 #else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N #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 #endif

View File

@ -452,3 +452,31 @@ class MenuItem_bool : public MenuEditItemBase {
#if ENABLED(LEVEL_BED_CORNERS) #if ENABLED(LEVEL_BED_CORNERS)
void _lcd_level_bed_corners(); void _lcd_level_bed_corners();
#endif #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

View File

@ -191,25 +191,6 @@ void menu_temperature() {
// //
#if HAS_FAN #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) #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) { auto singlenozzle_item = [&](const uint8_t f) {
editable.uint8 = singlenozzle_fan_speed[f]; editable.uint8 = singlenozzle_fan_speed[f];
@ -218,11 +199,7 @@ void menu_temperature() {
#endif #endif
#if HAS_FAN0 #if HAS_FAN0
editable.uint8 = thermalManager.fan_speed[0]; _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
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
#endif #endif
#if HAS_FAN1 #if HAS_FAN1
FAN_EDIT_ITEMS(1); FAN_EDIT_ITEMS(1);
@ -232,32 +209,32 @@ void menu_temperature() {
#if HAS_FAN2 #if HAS_FAN2
FAN_EDIT_ITEMS(2); FAN_EDIT_ITEMS(2);
#elif SNFAN(2) #elif SNFAN(2)
singlenozzle_item(1); singlenozzle_item(2);
#endif #endif
#if HAS_FAN3 #if HAS_FAN3
FAN_EDIT_ITEMS(3); FAN_EDIT_ITEMS(3);
#elif SNFAN(3) #elif SNFAN(3)
singlenozzle_item(1); singlenozzle_item(3);
#endif #endif
#if HAS_FAN4 #if HAS_FAN4
FAN_EDIT_ITEMS(4); FAN_EDIT_ITEMS(4);
#elif SNFAN(4) #elif SNFAN(4)
singlenozzle_item(1); singlenozzle_item(4);
#endif #endif
#if HAS_FAN5 #if HAS_FAN5
FAN_EDIT_ITEMS(5); FAN_EDIT_ITEMS(5);
#elif SNFAN(5) #elif SNFAN(5)
singlenozzle_item(1); singlenozzle_item(5);
#endif #endif
#if HAS_FAN6 #if HAS_FAN6
FAN_EDIT_ITEMS(6); FAN_EDIT_ITEMS(6);
#elif SNFAN(6) #elif SNFAN(6)
singlenozzle_item(1); singlenozzle_item(6);
#endif #endif
#if HAS_FAN7 #if HAS_FAN7
FAN_EDIT_ITEMS(7); FAN_EDIT_ITEMS(7);
#elif SNFAN(7) #elif SNFAN(7)
singlenozzle_item(1); singlenozzle_item(7);
#endif #endif
#endif // HAS_FAN #endif // HAS_FAN

View File

@ -142,21 +142,6 @@ void menu_tune() {
// //
#if HAS_FAN #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) #if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
auto singlenozzle_item = [&](const uint8_t f) { auto singlenozzle_item = [&](const uint8_t f) {
editable.uint8 = singlenozzle_fan_speed[f]; editable.uint8 = singlenozzle_fan_speed[f];
@ -165,46 +150,42 @@ void menu_tune() {
#endif #endif
#if HAS_FAN0 #if HAS_FAN0
editable.uint8 = thermalManager.fan_speed[0]; _FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
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
#endif #endif
#if HAS_FAN1 #if HAS_FAN1
fan_edit_items(1); FAN_EDIT_ITEMS(1);
#elif SNFAN(1) #elif SNFAN(1)
singlenozzle_item(1); singlenozzle_item(1);
#endif #endif
#if HAS_FAN2 #if HAS_FAN2
fan_edit_items(2); FAN_EDIT_ITEMS(2);
#elif SNFAN(2) #elif SNFAN(2)
singlenozzle_item(1); singlenozzle_item(2);
#endif #endif
#if HAS_FAN3 #if HAS_FAN3
fan_edit_items(3); FAN_EDIT_ITEMS(3);
#elif SNFAN(3) #elif SNFAN(3)
singlenozzle_item(1); singlenozzle_item(3);
#endif #endif
#if HAS_FAN4 #if HAS_FAN4
fan_edit_items(4); FAN_EDIT_ITEMS(4);
#elif SNFAN(4) #elif SNFAN(4)
singlenozzle_item(1); singlenozzle_item(4);
#endif #endif
#if HAS_FAN5 #if HAS_FAN5
fan_edit_items(5); FAN_EDIT_ITEMS(5);
#elif SNFAN(5) #elif SNFAN(5)
singlenozzle_item(1); singlenozzle_item(5);
#endif #endif
#if HAS_FAN6 #if HAS_FAN6
fan_edit_items(6); FAN_EDIT_ITEMS(6);
#elif SNFAN(6) #elif SNFAN(6)
singlenozzle_item(1); singlenozzle_item(6);
#endif #endif
#if HAS_FAN7 #if HAS_FAN7
fan_edit_items(7); FAN_EDIT_ITEMS(7);
#elif SNFAN(7) #elif SNFAN(7)
singlenozzle_item(1); singlenozzle_item(7);
#endif #endif
#endif // HAS_FAN #endif // HAS_FAN