🎨 Optional Custom Button description (#22336)

2.0.x
ellensp 3 years ago committed by Scott Lahteine
parent 00b27b1aa7
commit 24f0613b9f

@ -522,95 +522,148 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
#if ENABLED(CUSTOM_USER_BUTTONS)
// Handle a custom user button if defined
const bool printer_not_busy = !printingIsActive();
#define HAS_CUSTOM_USER_BUTTON(N) (PIN_EXISTS(BUTTON##N) && defined(BUTTON##N##_HIT_STATE) && defined(BUTTON##N##_GCODE) && defined(BUTTON##N##_DESC))
#define CHECK_CUSTOM_USER_BUTTON(N) do{ \
const millis_t ms = millis();
#define HAS_CUSTOM_USER_BUTTON(N) (PIN_EXISTS(BUTTON##N) && defined(BUTTON##N##_HIT_STATE) && defined(BUTTON##N##_GCODE))
#define HAS_BETTER_USER_BUTTON(N) HAS_CUSTOM_USER_BUTTON(N) && defined(BUTTON##N##_DESC)
#define _CHECK_CUSTOM_USER_BUTTON(N, CODE) do{ \
constexpr millis_t CUB_DEBOUNCE_DELAY_##N = 250UL; \
static millis_t next_cub_ms_##N; \
if (BUTTON##N##_HIT_STATE == READ(BUTTON##N##_PIN) \
&& (ENABLED(BUTTON##N##_WHEN_PRINTING) || printer_not_busy)) { \
const millis_t ms = millis(); \
if (ELAPSED(ms, next_cub_ms_##N)) { \
next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \
if (strlen(BUTTON##N##_DESC)) \
LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC)); \
CODE; \
queue.inject_P(PSTR(BUTTON##N##_GCODE)); \
} \
} \
}while(0)
#if HAS_CUSTOM_USER_BUTTON(1)
#define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP)
#define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC)))
#if HAS_BETTER_USER_BUTTON(1)
CHECK_BETTER_USER_BUTTON(1);
#elif HAS_CUSTOM_USER_BUTTON(1)
CHECK_CUSTOM_USER_BUTTON(1);
#endif
#if HAS_CUSTOM_USER_BUTTON(2)
#if HAS_BETTER_USER_BUTTON(2)
CHECK_BETTER_USER_BUTTON(2);
#elif HAS_CUSTOM_USER_BUTTON(2)
CHECK_CUSTOM_USER_BUTTON(2);
#endif
#if HAS_CUSTOM_USER_BUTTON(3)
#if HAS_BETTER_USER_BUTTON(3)
CHECK_BETTER_USER_BUTTON(3);
#elif HAS_CUSTOM_USER_BUTTON(3)
CHECK_CUSTOM_USER_BUTTON(3);
#endif
#if HAS_CUSTOM_USER_BUTTON(4)
#if HAS_BETTER_USER_BUTTON(4)
CHECK_BETTER_USER_BUTTON(4);
#elif HAS_CUSTOM_USER_BUTTON(4)
CHECK_CUSTOM_USER_BUTTON(4);
#endif
#if HAS_CUSTOM_USER_BUTTON(5)
#if HAS_BETTER_USER_BUTTON(5)
CHECK_BETTER_USER_BUTTON(5);
#elif HAS_CUSTOM_USER_BUTTON(5)
CHECK_CUSTOM_USER_BUTTON(5);
#endif
#if HAS_CUSTOM_USER_BUTTON(6)
#if HAS_BETTER_USER_BUTTON(6)
CHECK_BETTER_USER_BUTTON(6);
#elif HAS_CUSTOM_USER_BUTTON(6)
CHECK_CUSTOM_USER_BUTTON(6);
#endif
#if HAS_CUSTOM_USER_BUTTON(7)
#if HAS_BETTER_USER_BUTTON(7)
CHECK_BETTER_USER_BUTTON(7);
#elif HAS_CUSTOM_USER_BUTTON(7)
CHECK_CUSTOM_USER_BUTTON(7);
#endif
#if HAS_CUSTOM_USER_BUTTON(8)
#if HAS_BETTER_USER_BUTTON(8)
CHECK_BETTER_USER_BUTTON(8);
#elif HAS_CUSTOM_USER_BUTTON(8)
CHECK_CUSTOM_USER_BUTTON(8);
#endif
#if HAS_CUSTOM_USER_BUTTON(9)
#if HAS_BETTER_USER_BUTTON(9)
CHECK_BETTER_USER_BUTTON(9);
#elif HAS_CUSTOM_USER_BUTTON(9)
CHECK_CUSTOM_USER_BUTTON(9);
#endif
#if HAS_CUSTOM_USER_BUTTON(10)
#if HAS_BETTER_USER_BUTTON(10)
CHECK_BETTER_USER_BUTTON(10);
#elif HAS_CUSTOM_USER_BUTTON(10)
CHECK_CUSTOM_USER_BUTTON(10);
#endif
#if HAS_CUSTOM_USER_BUTTON(11)
#if HAS_BETTER_USER_BUTTON(11)
CHECK_BETTER_USER_BUTTON(11);
#elif HAS_CUSTOM_USER_BUTTON(11)
CHECK_CUSTOM_USER_BUTTON(11);
#endif
#if HAS_CUSTOM_USER_BUTTON(12)
#if HAS_BETTER_USER_BUTTON(12)
CHECK_BETTER_USER_BUTTON(12);
#elif HAS_CUSTOM_USER_BUTTON(12)
CHECK_CUSTOM_USER_BUTTON(12);
#endif
#if HAS_CUSTOM_USER_BUTTON(13)
#if HAS_BETTER_USER_BUTTON(13)
CHECK_BETTER_USER_BUTTON(13);
#elif HAS_CUSTOM_USER_BUTTON(13)
CHECK_CUSTOM_USER_BUTTON(13);
#endif
#if HAS_CUSTOM_USER_BUTTON(14)
#if HAS_BETTER_USER_BUTTON(14)
CHECK_BETTER_USER_BUTTON(14);
#elif HAS_CUSTOM_USER_BUTTON(14)
CHECK_CUSTOM_USER_BUTTON(14);
#endif
#if HAS_CUSTOM_USER_BUTTON(15)
#if HAS_BETTER_USER_BUTTON(15)
CHECK_BETTER_USER_BUTTON(15);
#elif HAS_CUSTOM_USER_BUTTON(15)
CHECK_CUSTOM_USER_BUTTON(15);
#endif
#if HAS_CUSTOM_USER_BUTTON(16)
#if HAS_BETTER_USER_BUTTON(16)
CHECK_BETTER_USER_BUTTON(16);
#elif HAS_CUSTOM_USER_BUTTON(16)
CHECK_CUSTOM_USER_BUTTON(16);
#endif
#if HAS_CUSTOM_USER_BUTTON(17)
#if HAS_BETTER_USER_BUTTON(17)
CHECK_BETTER_USER_BUTTON(17);
#elif HAS_CUSTOM_USER_BUTTON(17)
CHECK_CUSTOM_USER_BUTTON(17);
#endif
#if HAS_CUSTOM_USER_BUTTON(18)
#if HAS_BETTER_USER_BUTTON(18)
CHECK_BETTER_USER_BUTTON(18);
#elif HAS_CUSTOM_USER_BUTTON(18)
CHECK_CUSTOM_USER_BUTTON(18);
#endif
#if HAS_CUSTOM_USER_BUTTON(19)
#if HAS_BETTER_USER_BUTTON(19)
CHECK_BETTER_USER_BUTTON(19);
#elif HAS_CUSTOM_USER_BUTTON(19)
CHECK_CUSTOM_USER_BUTTON(19);
#endif
#if HAS_CUSTOM_USER_BUTTON(20)
#if HAS_BETTER_USER_BUTTON(20)
CHECK_BETTER_USER_BUTTON(20);
#elif HAS_CUSTOM_USER_BUTTON(20)
CHECK_CUSTOM_USER_BUTTON(20);
#endif
#if HAS_CUSTOM_USER_BUTTON(21)
#if HAS_BETTER_USER_BUTTON(21)
CHECK_BETTER_USER_BUTTON(21);
#elif HAS_CUSTOM_USER_BUTTON(21)
CHECK_CUSTOM_USER_BUTTON(21);
#endif
#if HAS_CUSTOM_USER_BUTTON(22)
#if HAS_BETTER_USER_BUTTON(22)
CHECK_BETTER_USER_BUTTON(22);
#elif HAS_CUSTOM_USER_BUTTON(22)
CHECK_CUSTOM_USER_BUTTON(22);
#endif
#if HAS_CUSTOM_USER_BUTTON(23)
#if HAS_BETTER_USER_BUTTON(23)
CHECK_BETTER_USER_BUTTON(23);
#elif HAS_CUSTOM_USER_BUTTON(23)
CHECK_CUSTOM_USER_BUTTON(23);
#endif
#if HAS_CUSTOM_USER_BUTTON(24)
#if HAS_BETTER_USER_BUTTON(24)
CHECK_BETTER_USER_BUTTON(24);
#elif HAS_CUSTOM_USER_BUTTON(24)
CHECK_CUSTOM_USER_BUTTON(24);
#endif
#if HAS_CUSTOM_USER_BUTTON(25)
#if HAS_BETTER_USER_BUTTON(25)
CHECK_BETTER_USER_BUTTON(25);
#elif HAS_CUSTOM_USER_BUTTON(25)
CHECK_CUSTOM_USER_BUTTON(25);
#endif
#endif

Loading…
Cancel
Save