Add optional endstop beeps

Enable ENDSTOP_BEEP in Configuration.h to enable a 2KHz beep when endstops are hit. Disabled by default.
This commit is contained in:
David Ramiro 2019-03-25 19:15:28 +01:00
parent 9c133f5c05
commit a2c47b53c2
No known key found for this signature in database
GPG Key ID: 5B042737EBEEB736
2 changed files with 30 additions and 0 deletions

View File

@ -1526,6 +1526,13 @@
//
//#define STARTUP_CHIME
//
// ENDSTOP BEEP
//
// Short 2KHz beep when endstops are hit
//
//#define ENDSTOP_BEEP
//
// The duration and frequency for the UI feedback sound.
// Set these to 0 to disable audio feedback in the LCD menus.

View File

@ -14815,6 +14815,25 @@ 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
/**
* Manage several activities:
* - Check for Filament Runout
@ -15041,6 +15060,10 @@ void idle(
AnycubicTFT.CommandScan();
#endif
#ifdef ENDSTOP_BEEP
EndstopBeep();
#endif
lcd_update();
host_keepalive();