Support for Filament runout sensor and endstop beep.
This commit is contained in:
@@ -181,6 +181,10 @@
|
||||
#include "libs/L64XX/L64XX_Marlin.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(ANYCUBIC_TOUCHSCREEN)
|
||||
#include "lcd/anycubic_touchscreen.h"
|
||||
#endif
|
||||
|
||||
const char NUL_STR[] PROGMEM = "",
|
||||
M112_KILL_STR[] PROGMEM = "M112 Shutdown",
|
||||
G28_STR[] PROGMEM = "G28",
|
||||
@@ -345,6 +349,90 @@ void disable_all_steppers() {
|
||||
disable_e_steppers();
|
||||
}
|
||||
|
||||
#ifdef ENDSTOP_BEEP
|
||||
void EndstopBeep() {
|
||||
static char last_status=((READ(X_MIN_PIN)<<2)|(READ(Y_MIN_PIN)<<1)|READ(X_MAX_PIN));
|
||||
static unsigned char now_status;
|
||||
|
||||
now_status=((READ(X_MIN_PIN)<<2)|(READ(Y_MIN_PIN)<<1)|READ(X_MAX_PIN))&0xff;
|
||||
|
||||
if(now_status<last_status) {
|
||||
static millis_t endstop_ms = millis() + 300UL;
|
||||
if (ELAPSED(millis(), endstop_ms)) {
|
||||
buzzer.tone(60, 2000);
|
||||
}
|
||||
last_status=now_status;
|
||||
} else if(now_status!=last_status) {
|
||||
last_status=now_status;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
|
||||
void event_filament_runout() {
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
if (did_pause_print) return; // Action already in progress. Purge triggered repeated runout.
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onFilamentRunout(ExtUI::getActiveTool());
|
||||
#endif
|
||||
|
||||
#if EITHER(HOST_PROMPT_SUPPORT, HOST_ACTION_COMMANDS)
|
||||
const char tool = '0'
|
||||
#if NUM_RUNOUT_SENSORS > 1
|
||||
+ active_extruder
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
//action:out_of_filament
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_reason = PROMPT_FILAMENT_RUNOUT;
|
||||
host_action_prompt_end();
|
||||
host_action_prompt_begin(PSTR("FilamentRunout T"), false);
|
||||
SERIAL_CHAR(tool);
|
||||
SERIAL_EOL();
|
||||
host_action_prompt_show();
|
||||
#endif
|
||||
|
||||
const bool run_runout_script = !runout.host_handling;
|
||||
|
||||
#if ENABLED(HOST_ACTION_COMMANDS)
|
||||
if (run_runout_script
|
||||
&& ( strstr(FILAMENT_RUNOUT_SCRIPT, "M600")
|
||||
|| strstr(FILAMENT_RUNOUT_SCRIPT, "M125")
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
|| strstr(FILAMENT_RUNOUT_SCRIPT, "M25")
|
||||
#endif
|
||||
)
|
||||
) {
|
||||
host_action_paused(false);
|
||||
}
|
||||
else {
|
||||
// Legacy Repetier command for use until newer version supports standard dialog
|
||||
// To be removed later when pause command also triggers dialog
|
||||
#ifdef ACTION_ON_FILAMENT_RUNOUT
|
||||
host_action(PSTR(ACTION_ON_FILAMENT_RUNOUT " T"), false);
|
||||
SERIAL_CHAR(tool);
|
||||
SERIAL_EOL();
|
||||
#endif
|
||||
|
||||
host_action_pause(false);
|
||||
}
|
||||
SERIAL_ECHOPGM(" " ACTION_REASON_ON_FILAMENT_RUNOUT " ");
|
||||
SERIAL_CHAR(tool);
|
||||
SERIAL_EOL();
|
||||
#endif // HOST_ACTION_COMMANDS
|
||||
|
||||
if (run_runout_script)
|
||||
queue.inject_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
|
||||
}
|
||||
|
||||
#endif // HAS_FILAMENT_SENSOR
|
||||
|
||||
#if ENABLED(G29_RETRY_AND_RECOVER)
|
||||
|
||||
void event_probe_failure() {
|
||||
@@ -462,6 +550,9 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
||||
runout.run();
|
||||
#endif
|
||||
|
||||
#if ENABLED(ANYCUBIC_TOUCHSCREEN) && ENABLED(ANYCUBIC_FILAMENT_RUNOUT_SENSOR)
|
||||
AnycubicTouchscreen.FilamentRunout();
|
||||
#endif
|
||||
if (queue.length < BUFSIZE) queue.get_available_commands();
|
||||
|
||||
const millis_t ms = millis();
|
||||
@@ -671,6 +762,14 @@ void idle(
|
||||
max7219.idle_tasks();
|
||||
#endif
|
||||
|
||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
||||
AnycubicTouchscreen.CommandScan();
|
||||
#endif
|
||||
|
||||
#ifdef ENDSTOP_BEEP
|
||||
EndstopBeep();
|
||||
#endif
|
||||
|
||||
ui.update();
|
||||
|
||||
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
||||
@@ -748,6 +847,10 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
|
||||
UNUSED(lcd_component);
|
||||
#endif
|
||||
|
||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
||||
AnycubicTouchscreen.KillTFT();
|
||||
#endif
|
||||
|
||||
#ifdef ACTION_ON_KILL
|
||||
host_action_kill();
|
||||
#endif
|
||||
@@ -900,6 +1003,10 @@ void setup() {
|
||||
SERIAL_ECHOLNPGM("start");
|
||||
SERIAL_ECHO_START();
|
||||
|
||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
||||
AnycubicTouchscreen.Setup();
|
||||
#endif
|
||||
|
||||
#if HAS_TMC_SPI
|
||||
#if DISABLED(TMC_USE_SW_SPI)
|
||||
SPI.begin();
|
||||
@@ -924,6 +1031,10 @@ void setup() {
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOLNPGM(SHORT_BUILD_VERSION);
|
||||
SERIAL_EOL();
|
||||
SERIAL_ECHOPGM(STR_MARLIN_AI3M);
|
||||
SERIAL_CHAR(' ');
|
||||
//SERIAL_ECHOLNPGM(CUSTOM_BUILD_VERSION);
|
||||
SERIAL_EOL();
|
||||
|
||||
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
|
||||
SERIAL_ECHO_MSG(
|
||||
@@ -1188,6 +1299,10 @@ void loop() {
|
||||
queue.advance();
|
||||
|
||||
endstops.event_handler();
|
||||
idle();
|
||||
#ifdef ANYCUBIC_TOUCHSCREEN
|
||||
AnycubicTouchscreen.CommandScan();
|
||||
#endif
|
||||
|
||||
} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
|
||||
}
|
||||
|
Reference in New Issue
Block a user