From 43a994e0dfdba0e6fda7f2b5cf5db3d622e97435 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 24 Jun 2020 20:14:58 -0500 Subject: [PATCH] Fix material preset editing --- Marlin/src/lcd/menu/menu_configuration.cpp | 9 +++-- Marlin/src/lcd/menu/menu_temperature.cpp | 46 +++++++++++++++------- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/temperature.h | 2 +- 4 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 20fa9cc8b5..9e4653cf35 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -300,19 +300,20 @@ void menu_advanced_settings(); #if PREHEAT_COUNT && DISABLED(SLIM_LCD_MENUS) - void _menu_configuration_preheat_settings(const uint8_t material) { + void _menu_configuration_preheat_settings(const uint8_t m) { #define _MINTEMP_ITEM(N) HEATER_##N##_MINTEMP, #define _MAXTEMP_ITEM(N) HEATER_##N##_MAXTEMP, #define MINTEMP_ALL _MIN(REPEAT(HOTENDS, _MINTEMP_ITEM) 999) #define MAXTEMP_ALL _MAX(REPEAT(HOTENDS, _MAXTEMP_ITEM) 0) START_MENU(); BACK_ITEM(MSG_CONFIGURATION); - EDIT_ITEM(percent, MSG_FAN_SPEED, &ui.material_preset[material].fan_speed, 0, 255); + editable.uint8 = uint8_t(ui.material_preset[m].fan_speed); + EDIT_ITEM_N(percent, m, MSG_FAN_SPEED, &editable.uint8, 0, 255, []{ ui.material_preset[MenuItemBase::itemIndex].fan_speed = editable.uint8; }); #if HAS_TEMP_HOTEND - EDIT_ITEM(int3, MSG_NOZZLE, &ui.material_preset[material].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - HOTEND_OVERSHOOT); + EDIT_ITEM(uint16_3, MSG_NOZZLE, &ui.material_preset[m].hotend_temp, MINTEMP_ALL, MAXTEMP_ALL - HOTEND_OVERSHOOT); #endif #if HAS_HEATED_BED - EDIT_ITEM(int3, MSG_BED, &ui.material_preset[material].bed_temp, BED_MINTEMP, BED_MAX_TARGET); + EDIT_ITEM(uint16_3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET); #endif #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 9ff2e75807..b9d6561f94 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -83,15 +83,18 @@ void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t i ACTION_ITEM_N_P(E, msg_preheat_h[M], []{ _preheat_both(M, MenuItemBase::itemIndex); }); \ ACTION_ITEM_N_P(E, msg_preheat_end_e[M], []{ _preheat_end(M, MenuItemBase::itemIndex); }); \ }while(0) - #if HAS_HEATED_BED + + #if HAS_MULTI_HOTEND #define PREHEAT_ITEMS(M,E) _PREHEAT_ITEMS(M,E) #endif - #else - #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N(E, msg_preheat_h[M], []{ _preheat_end(M, MenuItemBase::itemIndex); }) + + #elif HAS_MULTI_HOTEND + + #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_P(E, msg_preheat_h[M], []{ _preheat_end(M, MenuItemBase::itemIndex); }) + #endif void menu_preheat_m(const uint8_t m) { - editable.int8 = m; #if HOTENDS == 1 PGM_P msg_preheat[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1), GET_TEXT(MSG_PREHEAT_2), GET_TEXT(MSG_PREHEAT_3), GET_TEXT(MSG_PREHEAT_4), GET_TEXT(MSG_PREHEAT_5)); PGM_P msg_preheat_end[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_END), GET_TEXT(MSG_PREHEAT_2_END), GET_TEXT(MSG_PREHEAT_3_END), GET_TEXT(MSG_PREHEAT_4_END), GET_TEXT(MSG_PREHEAT_5_END)); @@ -99,31 +102,44 @@ void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t i PGM_P msg_preheat_all[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_ALL), GET_TEXT(MSG_PREHEAT_2_ALL), GET_TEXT(MSG_PREHEAT_3_ALL), GET_TEXT(MSG_PREHEAT_4_ALL), GET_TEXT(MSG_PREHEAT_5_ALL)); #endif PGM_P msg_preheat_end_e[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_END_E), GET_TEXT(MSG_PREHEAT_2_END_E), GET_TEXT(MSG_PREHEAT_3_END_E), GET_TEXT(MSG_PREHEAT_4_END_E), GET_TEXT(MSG_PREHEAT_5_END_E)); - PGM_P msg_preheat_bed[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_BEDONLY), GET_TEXT(MSG_PREHEAT_2_BEDONLY), GET_TEXT(MSG_PREHEAT_3_BEDONLY), GET_TEXT(MSG_PREHEAT_4_BEDONLY), GET_TEXT(MSG_PREHEAT_5_BEDONLY)); - PGM_P msg_preheat_h[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_H), GET_TEXT(MSG_PREHEAT_2_H), GET_TEXT(MSG_PREHEAT_3_H), GET_TEXT(MSG_PREHEAT_4_H), GET_TEXT(MSG_PREHEAT_5_H)); + + #if HAS_MULTI_HOTEND + PGM_P msg_preheat_h[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_H), GET_TEXT(MSG_PREHEAT_2_H), GET_TEXT(MSG_PREHEAT_3_H), GET_TEXT(MSG_PREHEAT_4_H), GET_TEXT(MSG_PREHEAT_5_H)); + #endif + + MenuItemBase::itemIndex = m; START_MENU(); BACK_ITEM(MSG_TEMPERATURE); + #if HOTENDS == 1 + #if HAS_HEATED_BED - ACTION_ITEM_P(msg_preheat[m], []{ _preheat_both(editable.int8, 0); }); - ACTION_ITEM_P(msg_preheat_end[m], []{ _preheat_end(editable.int8, 0); }); + ACTION_ITEM_P(msg_preheat[m], []{ _preheat_both(MenuItemBase::itemIndex, 0); }); + ACTION_ITEM_P(msg_preheat_end[m], []{ _preheat_end(MenuItemBase::itemIndex, 0); }); #else - ACTION_ITEM_P(msg_preheat[m], []{ _preheat_end(editable.int8, 0); }); + ACTION_ITEM_P(msg_preheat[m], []{ _preheat_end(MenuItemBase::itemIndex, 0); }); #endif + #elif HAS_MULTI_HOTEND + #if HAS_HEATED_BED - _PREHEAT_ITEMS(editable.int8,0); + _PREHEAT_ITEMS(MenuItemBase::itemIndex,0); #endif - LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(editable.int8,n); + + LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(MenuItemBase::itemIndex,n); ACTION_ITEM_P(msg_preheat_all[m], []() { - TERN_(HAS_HEATED_BED, _preheat_bed(editable.int8)); - HOTEND_LOOP() thermalManager.setTargetHotend(ui.material_preset[editable.int8].hotend_temp, e); + TERN_(HAS_HEATED_BED, _preheat_bed(MenuItemBase::itemIndex)); + HOTEND_LOOP() thermalManager.setTargetHotend(ui.material_preset[MenuItemBase::itemIndex].hotend_temp, e); }); - #endif // HAS_MULTI_HOTEND + + #endif + #if HAS_HEATED_BED - ACTION_ITEM_P(msg_preheat_bed[m], []{ _preheat_bed(editable.int8); }); + PGM_P msg_preheat_bed[] = ARRAY_N(PREHEAT_COUNT, GET_TEXT(MSG_PREHEAT_1_BEDONLY), GET_TEXT(MSG_PREHEAT_2_BEDONLY), GET_TEXT(MSG_PREHEAT_3_BEDONLY), GET_TEXT(MSG_PREHEAT_4_BEDONLY), GET_TEXT(MSG_PREHEAT_5_BEDONLY)); + ACTION_ITEM_P(msg_preheat_bed[m], []{ _preheat_bed(MenuItemBase::itemIndex); }); #endif + END_MENU(); } diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 9d55867c5b..f909476592 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -151,7 +151,7 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, #if HAS_HOTEND hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 } - const int16_t Temperature::heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); + const uint16_t Temperature::heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); #endif #if ENABLED(AUTO_POWER_E_FANS) diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index fca88608b5..0362e2e8e5 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -330,7 +330,7 @@ class Temperature { #if HAS_HOTEND #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) static hotend_info_t temp_hotend[HOTEND_TEMPS]; - static const int16_t heater_maxtemp[HOTENDS]; + static const uint16_t heater_maxtemp[HOTENDS]; #endif TERN_(HAS_HEATED_BED, static bed_info_t temp_bed); TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe);