Add BUTTON*_IMMEDIATE option
This commit is contained in:
@@ -4187,6 +4187,7 @@
|
||||
#define BUTTON1_WHEN_PRINTING false // Button allowed to trigger during printing?
|
||||
#define BUTTON1_GCODE "G28"
|
||||
#define BUTTON1_DESC "Homing" // Optional string to set the LCD status
|
||||
//#define BUTTON1_IMMEDIATE // Skip the queue and run the G-code immediately
|
||||
#endif
|
||||
|
||||
//#define BUTTON2_PIN -1
|
||||
@@ -4195,6 +4196,7 @@
|
||||
#define BUTTON2_WHEN_PRINTING false
|
||||
#define BUTTON2_GCODE "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
|
||||
#define BUTTON2_DESC "Preheat for " PREHEAT_1_LABEL
|
||||
//#define BUTTON2_IMMEDIATE
|
||||
#endif
|
||||
|
||||
//#define BUTTON3_PIN -1
|
||||
@@ -4203,6 +4205,7 @@
|
||||
#define BUTTON3_WHEN_PRINTING false
|
||||
#define BUTTON3_GCODE "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
|
||||
#define BUTTON3_DESC "Preheat for " PREHEAT_2_LABEL
|
||||
//#define BUTTON3_IMMEDIATE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -531,11 +531,15 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
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)) { \
|
||||
&& (ENABLED(BUTTON##N##_WHEN_PRINTING) || printer_not_busy) \
|
||||
) { \
|
||||
if (ELAPSED(ms, next_cub_ms_##N)) { \
|
||||
next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \
|
||||
CODE; \
|
||||
queue.inject(F(BUTTON##N##_GCODE)); \
|
||||
if (ENABLED(BUTTON##N##_IMMEDIATE)) \
|
||||
gcode.process_subcommands_now(F(BUTTON##N##_GCODE)); \
|
||||
else \
|
||||
queue.inject(F(BUTTON##N##_GCODE)); \
|
||||
TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \
|
||||
} \
|
||||
} \
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "menu.h"
|
||||
#include "../marlinui.h"
|
||||
#include "../../gcode/gcode.h" // for process_subcommands_now
|
||||
#include "../../gcode/queue.h" // for inject
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
Reference in New Issue
Block a user