🧑‍💻 Add standard BUZZ types

This commit is contained in:
Scott Lahteine 2022-03-12 16:34:58 -06:00 committed by Scott Lahteine
parent f82b133595
commit c49f26a7ae
9 changed files with 36 additions and 59 deletions

View File

@ -143,6 +143,8 @@ uint8_t MMU2::get_current_tool() {
#define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE) #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE)
#endif #endif
inline void ATTN_BUZZ(const bool two=false) { BUZZ(200, 404); if (two) { BUZZ(10, 0); BUZZ(200, 404); } }
void MMU2::mmu_loop() { void MMU2::mmu_loop() {
switch (state) { switch (state) {
@ -525,7 +527,7 @@ static void mmu2_not_responding() {
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
load_filament_to_nozzle(index); load_filament_to_nozzle(index);
#else #else
BUZZ(400, 40); ERR_BUZZ();
#endif #endif
} break; } break;
@ -544,7 +546,7 @@ static void mmu2_not_responding() {
active_extruder = 0; active_extruder = 0;
} }
#else #else
BUZZ(400, 40); ERR_BUZZ();
#endif #endif
} break; } break;
@ -613,7 +615,7 @@ static void mmu2_not_responding() {
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
load_filament_to_nozzle(index); load_filament_to_nozzle(index);
#else #else
BUZZ(400, 40); ERR_BUZZ();
#endif #endif
} break; } break;
@ -633,7 +635,7 @@ static void mmu2_not_responding() {
extruder = index; extruder = index;
active_extruder = 0; active_extruder = 0;
#else #else
BUZZ(400, 40); ERR_BUZZ();
#endif #endif
} break; } break;
@ -707,7 +709,7 @@ static void mmu2_not_responding() {
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
load_filament_to_nozzle(index); load_filament_to_nozzle(index);
#else #else
BUZZ(400, 40); ERR_BUZZ();
#endif #endif
} break; } break;
@ -726,7 +728,7 @@ static void mmu2_not_responding() {
extruder = index; extruder = index;
active_extruder = 0; active_extruder = 0;
#else #else
BUZZ(400, 40); ERR_BUZZ();
#endif #endif
} break; } break;
@ -811,25 +813,21 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
if (turn_off_nozzle && resume_hotend_temp) { if (turn_off_nozzle && resume_hotend_temp) {
thermalManager.setTargetHotend(resume_hotend_temp, active_extruder); thermalManager.setTargetHotend(resume_hotend_temp, active_extruder);
LCD_MESSAGE(MSG_HEATING); LCD_MESSAGE(MSG_HEATING);
BUZZ(200, 40); ERR_BUZZ();
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000);
} }
if (move_axes && all_axes_homed()) { LCD_MESSAGE(MSG_MMU2_RESUMING);
LCD_MESSAGE(MSG_MMU2_RESUMING); ATTN_BUZZ(true);
BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404);
if (move_axes && all_axes_homed()) {
// Move XY to starting position, then Z // Move XY to starting position, then Z
do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE)); do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE));
// Move Z_AXIS to saved position // Move Z_AXIS to saved position
do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE)); do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
} }
else {
BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404);
LCD_MESSAGE(MSG_MMU2_RESUMING);
}
} }
} }
} }
@ -898,7 +896,7 @@ void MMU2::load_filament(const uint8_t index) {
command(MMU_CMD_L0 + index); command(MMU_CMD_L0 + index);
manage_response(false, false); manage_response(false, false);
BUZZ(200, 404); ATTN_BUZZ();
} }
/** /**
@ -909,7 +907,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
if (!_enabled) return false; if (!_enabled) return false;
if (thermalManager.tooColdToExtrude(active_extruder)) { if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404); ATTN_BUZZ();
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
return false; return false;
} }
@ -924,7 +922,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
extruder = index; extruder = index;
active_extruder = 0; active_extruder = 0;
load_to_nozzle(); load_to_nozzle();
BUZZ(200, 404); ATTN_BUZZ();
} }
return success; return success;
} }
@ -945,7 +943,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
if (!_enabled) return false; if (!_enabled) return false;
if (thermalManager.tooColdToExtrude(active_extruder)) { if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404); ATTN_BUZZ();
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
return false; return false;
} }
@ -961,12 +959,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
if (recover) { if (recover) {
LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER); LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER);
BUZZ(200, 404); ATTN_BUZZ();
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR))); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover"))); TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover")));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response()); TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
BUZZ(200, 404); ATTN_BUZZ(true);
BUZZ(200, 404);
command(MMU_CMD_R0); command(MMU_CMD_R0);
manage_response(false, false); manage_response(false, false);
@ -979,7 +976,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
set_runout_valid(false); set_runout_valid(false);
BUZZ(200, 404); ATTN_BUZZ();
stepper.disable_extruder(); stepper.disable_extruder();
@ -994,7 +991,7 @@ bool MMU2::unload() {
if (!_enabled) return false; if (!_enabled) return false;
if (thermalManager.tooColdToExtrude(active_extruder)) { if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404); ATTN_BUZZ();
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD); LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
return false; return false;
} }
@ -1005,7 +1002,7 @@ bool MMU2::unload() {
command(MMU_CMD_U0); command(MMU_CMD_U0);
manage_response(false, true); manage_response(false, true);
BUZZ(200, 404); ATTN_BUZZ();
// no active tool // no active tool
extruder = MMU2_NO_TOOL; extruder = MMU2_NO_TOOL;

View File

@ -155,8 +155,7 @@ void GcodeSuite::G29() {
mbl_probe_index = -1; mbl_probe_index = -1;
SERIAL_ECHOLNPGM("Mesh probing done."); SERIAL_ECHOLNPGM("Mesh probing done.");
TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE)); TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE));
BUZZ(100, 659); OKAY_BUZZ();
BUZZ(100, 698);
home_all_axes(); home_all_axes();
set_bed_leveling_enabled(true); set_bed_leveling_enabled(true);

View File

@ -92,7 +92,7 @@ void GcodeSuite::M428() {
if (!WITHIN(diff[i], -20, 20)) { if (!WITHIN(diff[i], -20, 20)) {
SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR); SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR);
LCD_ALERTMESSAGE_F("Err: Too far!"); LCD_ALERTMESSAGE_F("Err: Too far!");
BUZZ(200, 40); ERR_BUZZ();
return; return;
} }
} }
@ -100,8 +100,7 @@ void GcodeSuite::M428() {
LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]); LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]);
report_current_position(); report_current_position();
LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED); LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED);
BUZZ(100, 659); OKAY_BUZZ();
BUZZ(100, 698);
} }
#endif // HAS_M206_COMMAND #endif // HAS_M206_COMMAND

View File

@ -4920,18 +4920,10 @@ void CrealityDWINClass::Screen_Update() {
} }
void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) { void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
if (success) { if (ui.buzzer_enabled)
if (ui.buzzer_enabled) { DONE_BUZZ(success);
BUZZ(100, 659);
BUZZ( 10, 0);
BUZZ(100, 698);
}
else Update_Status("Success");
}
else if (ui.buzzer_enabled)
BUZZ(40, 440);
else else
Update_Status("Failed"); Update_Status(success ? "Success" : "Failed");
} }
void CrealityDWINClass::Save_Settings(char *buff) { void CrealityDWINClass::Save_Settings(char *buff) {

View File

@ -1285,17 +1285,7 @@ void HMI_Printing() {
#include "../../../libs/buzzer.h" #include "../../../libs/buzzer.h"
void HMI_AudioFeedback(const bool success/*=true*/) { void HMI_AudioFeedback(const bool success/*=true*/) { DONE_BUZZ(success); }
#if HAS_BUZZER
if (success) {
BUZZ(100, 659);
BUZZ(10, 0);
BUZZ(100, 698);
}
else
BUZZ(40, 440);
#endif
}
void Draw_Main_Area() { void Draw_Main_Area() {
switch (checkkey) { switch (checkkey) {

View File

@ -276,11 +276,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#if HAS_BUZZER #if HAS_BUZZER
void MarlinUI::completion_feedback(const bool good/*=true*/) { void MarlinUI::completion_feedback(const bool good/*=true*/) {
TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click... TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click...
if (good) { if (good) OKAY_BUZZ(); else ERR_BUZZ();
BUZZ(100, 659);
BUZZ(100, 698);
}
else BUZZ(20, 440);
} }
#endif #endif

View File

@ -127,3 +127,8 @@
#define BUZZ(d,f) NOOP #define BUZZ(d,f) NOOP
#endif #endif
#define ERR_BUZZ() BUZZ(400, 40);
#define ATTN_BUZZ() do{ BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); }while(0)
#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0)
#define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0)

View File

@ -151,7 +151,7 @@ void PrintCounter::loadStats() {
if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3)); if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3));
#endif #endif
#if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0 #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0
if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) BUZZ(200, 404); if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) { BUZZ(200, 404); BUZZ(10, 0); }
#else #else
UNUSED(doBuzz); UNUSED(doBuzz);
#endif #endif

View File

@ -306,8 +306,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
if (deploy != PROBE_TRIGGERED()) break; if (deploy != PROBE_TRIGGERED()) break;
#endif #endif
BUZZ(100, 659); OKAY_BUZZ();
BUZZ(100, 698);
FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW); FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW);
ui.return_to_status(); // To display the new status message ui.return_to_status(); // To display the new status message