Skip to content

Commit

Permalink
Add optional endstop beeps
Browse files Browse the repository at this point in the history
Enable ENDSTOP_BEEP in Configuration.h to enable a 2KHz beep when endstops are hit. Disabled by default.
  • Loading branch information
davidramiro committed Mar 27, 2019
1 parent 3f19385 commit 6deb881
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -15041,6 +15060,10 @@ void idle(
AnycubicTFT.CommandScan();
#endif

#ifdef ENDSTOP_BEEP
EndstopBeep();
#endif

lcd_update();

host_keepalive();
Expand Down

0 comments on commit 6deb881

Please sign in to comment.