Improve sound handling for MMU error screen
Change in memory: Flash: -174 bytes SRAM: +4 bytes
This commit is contained in:
parent
e34faee389
commit
8db2fbc97f
|
|
@ -3429,35 +3429,14 @@ static void mmu_M600_wait_and_beep() {
|
|||
// Beep and wait for user to remove old filament and prepare new filament for load
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
|
||||
int counterBeep = 0;
|
||||
lcd_display_message_fullscreen_P(_i("Remove old filament and press the knob to start loading new filament.")); ////MSG_REMOVE_OLD_FILAMENT c=20 r=5
|
||||
bool bFirst = true;
|
||||
|
||||
while (!lcd_clicked()) {
|
||||
manage_heater();
|
||||
manage_inactivity(true);
|
||||
|
||||
#if BEEPER > 0
|
||||
if (counterBeep == 500) {
|
||||
counterBeep = 0;
|
||||
}
|
||||
SET_OUTPUT(BEEPER);
|
||||
if (counterBeep == 0) {
|
||||
if ((eSoundMode == e_SOUND_MODE_BLIND) || (eSoundMode == e_SOUND_MODE_LOUD) || ((eSoundMode == e_SOUND_MODE_ONCE) && bFirst)) {
|
||||
bFirst = false;
|
||||
WRITE(BEEPER, HIGH);
|
||||
}
|
||||
}
|
||||
if (counterBeep == 20) {
|
||||
WRITE(BEEPER, LOW);
|
||||
}
|
||||
|
||||
counterBeep++;
|
||||
#endif // BEEPER > 0
|
||||
|
||||
delay_keep_alive(4);
|
||||
sound_wait_for_user();
|
||||
}
|
||||
WRITE(BEEPER, LOW);
|
||||
sound_wait_for_user_reset();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -11288,34 +11267,14 @@ void M600_wait_for_user(float HotendTempBckp) {
|
|||
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
|
||||
int counterBeep = 0;
|
||||
unsigned long waiting_start_time = _millis();
|
||||
uint8_t wait_for_user_state = 0;
|
||||
lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD));
|
||||
bool bFirst=true;
|
||||
|
||||
while (!(wait_for_user_state == 0 && lcd_clicked())){
|
||||
manage_heater();
|
||||
manage_inactivity(true);
|
||||
|
||||
#if BEEPER > 0
|
||||
if (counterBeep == 500) {
|
||||
counterBeep = 0;
|
||||
}
|
||||
SET_OUTPUT(BEEPER);
|
||||
if (counterBeep == 0) {
|
||||
if((eSoundMode==e_SOUND_MODE_BLIND)|| (eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst))
|
||||
{
|
||||
bFirst=false;
|
||||
WRITE(BEEPER, HIGH);
|
||||
}
|
||||
}
|
||||
if (counterBeep == 20) {
|
||||
WRITE(BEEPER, LOW);
|
||||
}
|
||||
|
||||
counterBeep++;
|
||||
#endif //BEEPER > 0
|
||||
if (wait_for_user_state != 2) sound_wait_for_user();
|
||||
|
||||
switch (wait_for_user_state) {
|
||||
case 0: //nozzle is hot, waiting for user to press the knob to unload filament
|
||||
|
|
@ -11335,28 +11294,22 @@ void M600_wait_for_user(float HotendTempBckp) {
|
|||
if (lcd_clicked()) {
|
||||
setTargetHotend(HotendTempBckp);
|
||||
lcd_wait_for_heater();
|
||||
|
||||
wait_for_user_state = 2;
|
||||
}
|
||||
break;
|
||||
case 2: //waiting for nozzle to reach target temperature
|
||||
|
||||
if (fabs(degTargetHotend(active_extruder) - degHotend(active_extruder)) < 1) {
|
||||
lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD));
|
||||
waiting_start_time = _millis();
|
||||
wait_for_user_state = 0;
|
||||
}
|
||||
else {
|
||||
counterBeep = 20; //beeper will be inactive during waiting for nozzle preheat
|
||||
} else {
|
||||
lcd_set_cursor(1, 4);
|
||||
lcd_printf_P(PSTR("%3d"), (int16_t)degHotend(active_extruder));
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
WRITE(BEEPER, LOW);
|
||||
sound_wait_for_user_reset();
|
||||
}
|
||||
|
||||
void M600_load_filament_movements()
|
||||
|
|
|
|||
|
|
@ -907,9 +907,6 @@ void MMU2::ReportError(ErrorCode ec, ErrorSource res) {
|
|||
// or if 'Retry' operation is not available
|
||||
// raise the MMU error sceen and wait for user input
|
||||
ReportErrorHook((CommandInProgress)logic.CommandInProgress(), (uint16_t)ec, uint8_t(lastErrorSource));
|
||||
|
||||
// Beep when error screen is shown for the first time
|
||||
MakeSound(Prompt);
|
||||
}
|
||||
|
||||
static_assert(mmu2Magic[0] == 'M'
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
|||
case (uint8_t)ReportErrorHookStates::MONITOR_SELECTION:
|
||||
mmu2.is_mmu_error_monitor_active = true;
|
||||
ReportErrorHookDynamicRender(); // Render dynamic characters
|
||||
sound_wait_for_user();
|
||||
switch (ReportErrorHookMonitor(ei)) {
|
||||
case 0:
|
||||
// No choice selected, return to loop()
|
||||
|
|
@ -252,13 +253,7 @@ void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
|||
ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
||||
break;
|
||||
case 2:
|
||||
// Exit error screen and enable lcd updates
|
||||
lcd_set_custom_characters();
|
||||
lcd_update_enable(true);
|
||||
lcd_return_to_status();
|
||||
// Reset the state in case a new error is reported
|
||||
mmu2.is_mmu_error_monitor_active = false;
|
||||
ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
||||
ReportErrorHookState = ReportErrorHookStates::DISMISS_ERROR_SCREEN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -269,6 +264,7 @@ void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
|||
lcd_set_custom_characters();
|
||||
lcd_update_enable(true);
|
||||
lcd_return_to_status();
|
||||
sound_wait_for_user_reset();
|
||||
// Reset the state in case a new error is reported
|
||||
mmu2.is_mmu_error_monitor_active = false;
|
||||
ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
||||
|
|
|
|||
|
|
@ -183,3 +183,49 @@ for(nI=0;nI<nMax;nI++)
|
|||
delayMicroseconds(500);
|
||||
}
|
||||
}
|
||||
|
||||
static int16_t constexpr CONTINOUS_BEEP_PERIOD = 2000; // in ms
|
||||
static ShortTimer beep_timer; // Timer to keep track of continous beeping
|
||||
static bool bFirst; // true if the first beep has occurred, e_SOUND_MODE_ONCE
|
||||
|
||||
/// @brief Handles sound when waiting for user input
|
||||
/// the function must be non-blocking. It is up to the caller
|
||||
/// to call this function repeatedly.
|
||||
/// Make sure to call sound_wait_for_user_reset() when the user has clicked the knob
|
||||
/// Loud - should continuously beep
|
||||
/// Silent - should be silent
|
||||
/// Once - should beep once
|
||||
/// Assist/Blind - as loud with beep and click on knob rotation and press
|
||||
void sound_wait_for_user() {
|
||||
#if BEEPER > 0
|
||||
if (eSoundMode == e_SOUND_MODE_SILENT) return;
|
||||
|
||||
// Handle case where only one beep is needed
|
||||
if (!bFirst) {
|
||||
if (eSoundMode == e_SOUND_MODE_ONCE) {
|
||||
Sound_MakeSound(e_SOUND_TYPE_StandardPrompt);
|
||||
}
|
||||
bFirst = true;
|
||||
}
|
||||
|
||||
// Handle case where there should be continous beeps
|
||||
if (beep_timer.expired(CONTINOUS_BEEP_PERIOD))
|
||||
{
|
||||
beep_timer.start();
|
||||
if (eSoundMode == e_SOUND_MODE_LOUD)
|
||||
{
|
||||
Sound_MakeSound(e_SOUND_TYPE_StandardPrompt);
|
||||
} else {
|
||||
// Assist (lower volume sound)
|
||||
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
|
||||
}
|
||||
}
|
||||
#endif // BEEPER > 0
|
||||
}
|
||||
|
||||
/// @brief Resets the global state of sound_wait_for_user()
|
||||
void sound_wait_for_user_reset()
|
||||
{
|
||||
beep_timer.stop();
|
||||
bFirst = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ extern void Sound_Default(void);
|
|||
extern void Sound_CycleState(void);
|
||||
extern void Sound_MakeSound(eSOUND_TYPE eSoundType);
|
||||
extern void Sound_MakeCustom(uint16_t ms,uint16_t tone_ ,bool critical);
|
||||
void sound_wait_for_user();
|
||||
void sound_wait_for_user_reset();
|
||||
|
||||
//static void Sound_DoSound_Echo(void);
|
||||
//static void Sound_DoSound_Prompt(void);
|
||||
|
|
|
|||
Loading…
Reference in New Issue