Skip to content

Commit 89a9c3a

Browse files
committed
πŸ§‘β€πŸ’» Add standard BUZZ types
1 parent 0bf319c commit 89a9c3a

File tree

9 files changed

+36
-59
lines changed

9 files changed

+36
-59
lines changed

β€ŽMarlin/src/feature/mmu/mmu2.cpp

+21-24
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ uint8_t MMU2::get_current_tool() {
143143
#define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE)
144144
#endif
145145

146+
inline void ATTN_BUZZ(const bool two=false) { BUZZ(200, 404); if (two) { BUZZ(10, 0); BUZZ(200, 404); } }
147+
146148
void MMU2::mmu_loop() {
147149

148150
switch (state) {
@@ -525,7 +527,7 @@ static void mmu2_not_responding() {
525527
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
526528
load_filament_to_nozzle(index);
527529
#else
528-
BUZZ(400, 40);
530+
ERR_BUZZ();
529531
#endif
530532
} break;
531533

@@ -544,7 +546,7 @@ static void mmu2_not_responding() {
544546
active_extruder = 0;
545547
}
546548
#else
547-
BUZZ(400, 40);
549+
ERR_BUZZ();
548550
#endif
549551
} break;
550552

@@ -613,7 +615,7 @@ static void mmu2_not_responding() {
613615
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
614616
load_filament_to_nozzle(index);
615617
#else
616-
BUZZ(400, 40);
618+
ERR_BUZZ();
617619
#endif
618620
} break;
619621

@@ -633,7 +635,7 @@ static void mmu2_not_responding() {
633635
extruder = index;
634636
active_extruder = 0;
635637
#else
636-
BUZZ(400, 40);
638+
ERR_BUZZ();
637639
#endif
638640
} break;
639641

@@ -707,7 +709,7 @@ static void mmu2_not_responding() {
707709
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
708710
load_filament_to_nozzle(index);
709711
#else
710-
BUZZ(400, 40);
712+
ERR_BUZZ();
711713
#endif
712714
} break;
713715

@@ -726,7 +728,7 @@ static void mmu2_not_responding() {
726728
extruder = index;
727729
active_extruder = 0;
728730
#else
729-
BUZZ(400, 40);
731+
ERR_BUZZ();
730732
#endif
731733
} break;
732734

@@ -811,25 +813,21 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
811813
if (turn_off_nozzle && resume_hotend_temp) {
812814
thermalManager.setTargetHotend(resume_hotend_temp, active_extruder);
813815
LCD_MESSAGE(MSG_HEATING);
814-
BUZZ(200, 40);
816+
ERR_BUZZ();
815817

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

819-
if (move_axes && all_axes_homed()) {
820-
LCD_MESSAGE(MSG_MMU2_RESUMING);
821-
BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404);
821+
LCD_MESSAGE(MSG_MMU2_RESUMING);
822+
ATTN_BUZZ(true);
822823

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

826828
// Move Z_AXIS to saved position
827829
do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
828830
}
829-
else {
830-
BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404);
831-
LCD_MESSAGE(MSG_MMU2_RESUMING);
832-
}
833831
}
834832
}
835833
}
@@ -898,7 +896,7 @@ void MMU2::load_filament(const uint8_t index) {
898896

899897
command(MMU_CMD_L0 + index);
900898
manage_response(false, false);
901-
BUZZ(200, 404);
899+
ATTN_BUZZ();
902900
}
903901

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

911909
if (thermalManager.tooColdToExtrude(active_extruder)) {
912-
BUZZ(200, 404);
910+
ATTN_BUZZ();
913911
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
914912
return false;
915913
}
@@ -924,7 +922,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
924922
extruder = index;
925923
active_extruder = 0;
926924
load_to_nozzle();
927-
BUZZ(200, 404);
925+
ATTN_BUZZ();
928926
}
929927
return success;
930928
}
@@ -945,7 +943,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
945943
if (!_enabled) return false;
946944

947945
if (thermalManager.tooColdToExtrude(active_extruder)) {
948-
BUZZ(200, 404);
946+
ATTN_BUZZ();
949947
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
950948
return false;
951949
}
@@ -961,12 +959,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
961959

962960
if (recover) {
963961
LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER);
964-
BUZZ(200, 404);
962+
ATTN_BUZZ();
965963
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR)));
966964
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover")));
967965
TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
968-
BUZZ(200, 404);
969-
BUZZ(200, 404);
966+
ATTN_BUZZ(true);
970967

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

980977
set_runout_valid(false);
981978

982-
BUZZ(200, 404);
979+
ATTN_BUZZ();
983980

984981
stepper.disable_extruder();
985982

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

996993
if (thermalManager.tooColdToExtrude(active_extruder)) {
997-
BUZZ(200, 404);
994+
ATTN_BUZZ();
998995
LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
999996
return false;
1000997
}
@@ -1005,7 +1002,7 @@ bool MMU2::unload() {
10051002
command(MMU_CMD_U0);
10061003
manage_response(false, true);
10071004

1008-
BUZZ(200, 404);
1005+
ATTN_BUZZ();
10091006

10101007
// no active tool
10111008
extruder = MMU2_NO_TOOL;

β€ŽMarlin/src/gcode/bedlevel/mbl/G29.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ void GcodeSuite::G29() {
155155
mbl_probe_index = -1;
156156
SERIAL_ECHOLNPGM("Mesh probing done.");
157157
TERN_(HAS_STATUS_MESSAGE, LCD_MESSAGE(MSG_MESH_DONE));
158-
BUZZ(100, 659);
159-
BUZZ(100, 698);
158+
OKAY_BUZZ();
160159

161160
home_all_axes();
162161
set_bed_leveling_enabled(true);

β€ŽMarlin/src/gcode/geometry/M206_M428.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,15 @@ void GcodeSuite::M428() {
9292
if (!WITHIN(diff[i], -20, 20)) {
9393
SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR);
9494
LCD_ALERTMESSAGE_F("Err: Too far!");
95-
BUZZ(200, 40);
95+
ERR_BUZZ();
9696
return;
9797
}
9898
}
9999

100100
LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]);
101101
report_current_position();
102102
LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED);
103-
BUZZ(100, 659);
104-
BUZZ(100, 698);
103+
OKAY_BUZZ();
105104
}
106105

107106
#endif // HAS_M206_COMMAND

β€ŽMarlin/src/lcd/e3v2/jyersui/dwin.cpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -4920,18 +4920,10 @@ void CrealityDWINClass::Screen_Update() {
49204920
}
49214921

49224922
void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
4923-
if (success) {
4924-
if (ui.buzzer_enabled) {
4925-
BUZZ(100, 659);
4926-
BUZZ( 10, 0);
4927-
BUZZ(100, 698);
4928-
}
4929-
else Update_Status("Success");
4930-
}
4931-
else if (ui.buzzer_enabled)
4932-
BUZZ(40, 440);
4923+
if (ui.buzzer_enabled)
4924+
DONE_BUZZ(success);
49334925
else
4934-
Update_Status("Failed");
4926+
Update_Status(success ? "Success" : "Failed");
49354927
}
49364928

49374929
void CrealityDWINClass::Save_Settings(char *buff) {

β€ŽMarlin/src/lcd/e3v2/proui/dwin.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -1285,17 +1285,7 @@ void HMI_Printing() {
12851285

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

1288-
void HMI_AudioFeedback(const bool success/*=true*/) {
1289-
#if HAS_BUZZER
1290-
if (success) {
1291-
BUZZ(100, 659);
1292-
BUZZ(10, 0);
1293-
BUZZ(100, 698);
1294-
}
1295-
else
1296-
BUZZ(40, 440);
1297-
#endif
1298-
}
1288+
void HMI_AudioFeedback(const bool success/*=true*/) { DONE_BUZZ(success); }
12991289

13001290
void Draw_Main_Area() {
13011291
switch (checkkey) {

β€ŽMarlin/src/lcd/menu/menu.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
276276
#if HAS_BUZZER
277277
void MarlinUI::completion_feedback(const bool good/*=true*/) {
278278
TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click...
279-
if (good) {
280-
BUZZ(100, 659);
281-
BUZZ(100, 698);
282-
}
283-
else BUZZ(20, 440);
279+
if (good) OKAY_BUZZ(); else ERR_BUZZ();
284280
}
285281
#endif
286282

β€ŽMarlin/src/libs/buzzer.h

+5
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@
127127
#define BUZZ(d,f) NOOP
128128

129129
#endif
130+
131+
#define ERR_BUZZ() BUZZ(400, 40);
132+
#define ATTN_BUZZ() do{ BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404); }while(0)
133+
#define OKAY_BUZZ() do{ BUZZ(100, 659); BUZZ(10, 0); BUZZ(100, 698); }while(0)
134+
#define DONE_BUZZ(OK) do{ if (OK) OKAY_BUZZ(); else ERR_BUZZ(); }while(0)

β€ŽMarlin/src/module/printcounter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void PrintCounter::loadStats() {
151151
if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3));
152152
#endif
153153
#if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0
154-
if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) BUZZ(200, 404);
154+
if (doBuzz) for (int i = 0; i < SERVICE_WARNING_BUZZES; i++) { BUZZ(200, 404); BUZZ(10, 0); }
155155
#else
156156
UNUSED(doBuzz);
157157
#endif

β€ŽMarlin/src/module/probe.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
306306
if (deploy != PROBE_TRIGGERED()) break;
307307
#endif
308308

309-
BUZZ(100, 659);
310-
BUZZ(100, 698);
309+
OKAY_BUZZ();
311310

312311
FSTR_P const ds_str = deploy ? GET_TEXT_F(MSG_MANUAL_DEPLOY) : GET_TEXT_F(MSG_MANUAL_STOW);
313312
ui.return_to_status(); // To display the new status message

0 commit comments

Comments
Β (0)