Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Add standard BUZZ types
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 12, 2022
1 parent 0bf319c commit 89a9c3a
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 59 deletions.
45 changes: 21 additions & 24 deletions Marlin/src/feature/mmu/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ uint8_t MMU2::get_current_tool() {
#define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE)
#endif

inline void ATTN_BUZZ(const bool two=false) { BUZZ(200, 404); if (two) { BUZZ(10, 0); BUZZ(200, 404); } }

void MMU2::mmu_loop() {

switch (state) {
Expand Down Expand Up @@ -525,7 +527,7 @@ static void mmu2_not_responding() {
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
load_filament_to_nozzle(index);
#else
BUZZ(400, 40);
ERR_BUZZ();
#endif
} break;

Expand All @@ -544,7 +546,7 @@ static void mmu2_not_responding() {
active_extruder = 0;
}
#else
BUZZ(400, 40);
ERR_BUZZ();
#endif
} break;

Expand Down Expand Up @@ -613,7 +615,7 @@ static void mmu2_not_responding() {
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
load_filament_to_nozzle(index);
#else
BUZZ(400, 40);
ERR_BUZZ();
#endif
} break;

Expand All @@ -633,7 +635,7 @@ static void mmu2_not_responding() {
extruder = index;
active_extruder = 0;
#else
BUZZ(400, 40);
ERR_BUZZ();
#endif
} break;

Expand Down Expand Up @@ -707,7 +709,7 @@ static void mmu2_not_responding() {
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
load_filament_to_nozzle(index);
#else
BUZZ(400, 40);
ERR_BUZZ();
#endif
} break;

Expand All @@ -726,7 +728,7 @@ static void mmu2_not_responding() {
extruder = index;
active_extruder = 0;
#else
BUZZ(400, 40);
ERR_BUZZ();
#endif
} break;

Expand Down Expand Up @@ -811,25 +813,21 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
if (turn_off_nozzle && resume_hotend_temp) {
thermalManager.setTargetHotend(resume_hotend_temp, active_extruder);
LCD_MESSAGE(MSG_HEATING);
BUZZ(200, 40);
ERR_BUZZ();

while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000);
}

if (move_axes && all_axes_homed()) {
LCD_MESSAGE(MSG_MMU2_RESUMING);
BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404);
LCD_MESSAGE(MSG_MMU2_RESUMING);
ATTN_BUZZ(true);

if (move_axes && all_axes_homed()) {
// Move XY to starting position, then Z
do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE));

// Move Z_AXIS to saved position
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);
}
}
}
}
Expand Down Expand Up @@ -898,7 +896,7 @@ void MMU2::load_filament(const uint8_t index) {

command(MMU_CMD_L0 + index);
manage_response(false, false);
BUZZ(200, 404);
ATTN_BUZZ();
}

/**
Expand All @@ -909,7 +907,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
if (!_enabled) return false;

if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404);
ATTN_BUZZ();
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
return false;
}
Expand All @@ -924,7 +922,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
extruder = index;
active_extruder = 0;
load_to_nozzle();
BUZZ(200, 404);
ATTN_BUZZ();
}
return success;
}
Expand All @@ -945,7 +943,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
if (!_enabled) return false;

if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404);
ATTN_BUZZ();
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
return false;
}
Expand All @@ -961,12 +959,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {

if (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_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover")));
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
BUZZ(200, 404);
BUZZ(200, 404);
ATTN_BUZZ(true);

command(MMU_CMD_R0);
manage_response(false, false);
Expand All @@ -979,7 +976,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {

set_runout_valid(false);

BUZZ(200, 404);
ATTN_BUZZ();

stepper.disable_extruder();

Expand All @@ -994,7 +991,7 @@ bool MMU2::unload() {
if (!_enabled) return false;

if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404);
ATTN_BUZZ();
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
return false;
}
Expand All @@ -1005,7 +1002,7 @@ bool MMU2::unload() {
command(MMU_CMD_U0);
manage_response(false, true);

BUZZ(200, 404);
ATTN_BUZZ();

// no active tool
extruder = MMU2_NO_TOOL;
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/gcode/bedlevel/mbl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ void GcodeSuite::G29() {
mbl_probe_index = -1;
SERIAL_ECHOLNPGM("Mesh probing done.");
TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE));
BUZZ(100, 659);
BUZZ(100, 698);
OKAY_BUZZ();

home_all_axes();
set_bed_leveling_enabled(true);
Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/gcode/geometry/M206_M428.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,15 @@ void GcodeSuite::M428() {
if (!WITHIN(diff[i], -20, 20)) {
SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR);
LCD_ALERTMESSAGE_F("Err: Too far!");
BUZZ(200, 40);
ERR_BUZZ();
return;
}
}

LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]);
report_current_position();
LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED);
BUZZ(100, 659);
BUZZ(100, 698);
OKAY_BUZZ();
}

#endif // HAS_M206_COMMAND
14 changes: 3 additions & 11 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4920,18 +4920,10 @@ void CrealityDWINClass::Screen_Update() {
}

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

void CrealityDWINClass::Save_Settings(char *buff) {
Expand Down
12 changes: 1 addition & 11 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,17 +1285,7 @@ void HMI_Printing() {

#include "../../../libs/buzzer.h"

void HMI_AudioFeedback(const bool success/*=true*/) {
#if HAS_BUZZER
if (success) {
BUZZ(100, 659);
BUZZ(10, 0);
BUZZ(100, 698);
}
else
BUZZ(40, 440);
#endif
}
void HMI_AudioFeedback(const bool success/*=true*/) { DONE_BUZZ(success); }

void Draw_Main_Area() {
switch (checkkey) {
Expand Down
6 changes: 1 addition & 5 deletions Marlin/src/lcd/menu/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
#if HAS_BUZZER
void MarlinUI::completion_feedback(const bool good/*=true*/) {
TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click...
if (good) {
BUZZ(100, 659);
BUZZ(100, 698);
}
else BUZZ(20, 440);
if (good) OKAY_BUZZ(); else ERR_BUZZ();
}
#endif

Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/libs/buzzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,8 @@
#define BUZZ(d,f) NOOP

#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)
2 changes: 1 addition & 1 deletion Marlin/src/module/printcounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void PrintCounter::loadStats() {
if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3));
#endif
#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
UNUSED(doBuzz);
#endif
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
if (deploy != PROBE_TRIGGERED()) break;
#endif

BUZZ(100, 659);
BUZZ(100, 698);
OKAY_BUZZ();

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
Expand Down

0 comments on commit 89a9c3a

Please sign in to comment.