Add LCD option BEEP_ON_FEEDRATE_CHANGE (#12774)

This commit is contained in:
Kaushik Vemparala
2019-01-04 20:30:08 -05:00
committed by Scott Lahteine
parent d372e7e477
commit ba7e35cbab
65 changed files with 471 additions and 20 deletions

View File

@ -419,7 +419,8 @@ void MarlinUI::status_screen() {
//
#if DISABLED(PROGRESS_MSG_ONCE) || (PROGRESS_MSG_EXPIRE > 0)
millis_t ms = millis();
#define GOT_MS
const millis_t ms = millis();
#endif
// If the message will blink rather than expire...
@ -464,31 +465,40 @@ void MarlinUI::status_screen() {
#endif // HAS_LCD_MENU
#if ENABLED(ULTIPANEL_FEEDMULTIPLY) && HAS_ENCODER_ACTION
#if ENABLED(ULTIPANEL_FEEDMULTIPLY)
const int16_t old_frm = feedrate_percentage;
int16_t new_frm = old_frm + (int32_t)encoderPosition;
const int16_t new_frm = feedrate_percentage + (int32_t)encoderPosition;
// Dead zone at 100% feedrate
if ((feedrate_percentage < 100 && new_frm > 100) || (feedrate_percentage > 100 && new_frm < 100)) {
feedrate_percentage = 100;
encoderPosition = 0;
if (old_frm == 100) {
if ((int32_t)encoderPosition > ENCODER_FEEDRATE_DEADZONE)
new_frm -= ENCODER_FEEDRATE_DEADZONE;
else if ((int32_t)encoderPosition < -(ENCODER_FEEDRATE_DEADZONE))
new_frm += ENCODER_FEEDRATE_DEADZONE;
else
new_frm = old_frm;
}
else if (feedrate_percentage == 100) {
if ((int32_t)encoderPosition > ENCODER_FEEDRATE_DEADZONE) {
feedrate_percentage += (int32_t)encoderPosition - (ENCODER_FEEDRATE_DEADZONE);
encoderPosition = 0;
}
else if ((int32_t)encoderPosition < -(ENCODER_FEEDRATE_DEADZONE)) {
feedrate_percentage += (int32_t)encoderPosition + ENCODER_FEEDRATE_DEADZONE;
encoderPosition = 0;
}
}
else {
else if ((old_frm < 100 && new_frm > 100) || (old_frm > 100 && new_frm < 100))
new_frm = 100;
new_frm = constrain(new_frm, 10, 999);
if (old_frm != new_frm) {
feedrate_percentage = new_frm;
encoderPosition = 0;
#if ENABLED(BEEP_ON_FEEDRATE_CHANGE)
static millis_t next_beep;
#ifndef GOT_MS
const millis_t ms = millis();
#endif
if (ELAPSED(ms, next_beep)) {
BUZZ(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY);
next_beep = ms + 500UL;
}
#endif
}
feedrate_percentage = constrain(feedrate_percentage, 10, 999);
#endif // ULTIPANEL_FEEDMULTIPLY
draw_status_screen();