From 5a4be02112c77e5fcd9775a3fa6010a0f0ebe7b3 Mon Sep 17 00:00:00 2001 From: David Ross Smith <5095074+DragRedSim@users.noreply.github.com> Date: Fri, 7 Jan 2022 22:33:40 +1100 Subject: [PATCH 1/2] Fix for preheat selecting the wrong device --- Marlin/src/lcd/marlinui.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 4f797d899d83..81d79c6814e0 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -497,15 +497,16 @@ class MarlinUI { #endif #if HAS_PREHEAT - enum PreheatMask : uint8_t { PM_HOTEND = _BV(0), PM_BED = _BV(1), PM_FAN = _BV(2), PM_CHAMBER = _BV(3) }; + enum PreheatMask : uint8_t { PM_HOTEND = 0, PM_BED = 1, PM_FAN = 2, PM_CHAMBER = 3 }; //these values are the bit indexes used, NOT the actual values. + //Since the TEST() macro does bit-shifting on the second value, doing so here as well causes mismatches. static preheat_t material_preset[PREHEAT_COUNT]; static PGM_P get_preheat_label(const uint8_t m); static void apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e=active_extruder); - static inline void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, PM_FAN)); } - static inline void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, PM_HOTEND)); } - static inline void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); } - static inline void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, PM_BED)); } - static inline void preheat_all(const uint8_t m) { apply_preheat(m, 0xFF); } + static void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, _BV(PM_FAN))); } + static void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, _BV(PM_HOTEND))); } + static void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { TERN_(ANY(HAS_HOTEND, HAS_FAN), apply_preheat(m, _BV(PM_HOTEND) + _BV(PM_FAN), e)); } //the check inside apply_preheat will mask off non-available devices + static void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, _BV(PM_BED))); } + static void preheat_all(const uint8_t m) { apply_preheat(m, 0xFF); } #endif #if SCREENS_CAN_TIME_OUT From 8511917f32ed6994fc577b45083321d6dd4d94f4 Mon Sep 17 00:00:00 2001 From: David Ross Smith <5095074+DragRedSim@users.noreply.github.com> Date: Fri, 7 Jan 2022 23:07:22 +1100 Subject: [PATCH 2/2] Reverted logic for preheat_hotend_and_fan() # TERN_(ANY()) failed to compile on LPC1769, reverted --- Marlin/src/lcd/marlinui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index 81d79c6814e0..8d90ff9c0277 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -504,7 +504,7 @@ class MarlinUI { static void apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e=active_extruder); static void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, _BV(PM_FAN))); } static void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, _BV(PM_HOTEND))); } - static void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { TERN_(ANY(HAS_HOTEND, HAS_FAN), apply_preheat(m, _BV(PM_HOTEND) + _BV(PM_FAN), e)); } //the check inside apply_preheat will mask off non-available devices + static void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); } static void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, _BV(PM_BED))); } static void preheat_all(const uint8_t m) { apply_preheat(m, 0xFF); } #endif