Browse Source

🧑‍💻 Add standard BUZZ types

Scott Lahteine 2 years ago
parent
commit
89a9c3a391

+ 21
- 24
Marlin/src/feature/mmu/mmu2.cpp View File

@@ -143,6 +143,8 @@ uint8_t MMU2::get_current_tool() {
143 143
   #define FILAMENT_PRESENT() (READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE)
144 144
 #endif
145 145
 
146
+inline void ATTN_BUZZ(const bool two=false) { BUZZ(200, 404); if (two) { BUZZ(10, 0); BUZZ(200, 404); } }
147
+
146 148
 void MMU2::mmu_loop() {
147 149
 
148 150
   switch (state) {
@@ -525,7 +527,7 @@ static void mmu2_not_responding() {
525 527
             while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
526 528
             load_filament_to_nozzle(index);
527 529
           #else
528
-            BUZZ(400, 40);
530
+            ERR_BUZZ();
529 531
           #endif
530 532
         } break;
531 533
 
@@ -544,7 +546,7 @@ static void mmu2_not_responding() {
544 546
               active_extruder = 0;
545 547
             }
546 548
           #else
547
-            BUZZ(400, 40);
549
+            ERR_BUZZ();
548 550
           #endif
549 551
         } break;
550 552
 
@@ -613,7 +615,7 @@ static void mmu2_not_responding() {
613 615
           while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
614 616
           load_filament_to_nozzle(index);
615 617
         #else
616
-          BUZZ(400, 40);
618
+          ERR_BUZZ();
617 619
         #endif
618 620
       } break;
619 621
 
@@ -633,7 +635,7 @@ static void mmu2_not_responding() {
633 635
           extruder = index;
634 636
           active_extruder = 0;
635 637
         #else
636
-          BUZZ(400, 40);
638
+          ERR_BUZZ();
637 639
         #endif
638 640
       } break;
639 641
 
@@ -707,7 +709,7 @@ static void mmu2_not_responding() {
707 709
           while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
708 710
           load_filament_to_nozzle(index);
709 711
         #else
710
-          BUZZ(400, 40);
712
+          ERR_BUZZ();
711 713
         #endif
712 714
       } break;
713 715
 
@@ -726,7 +728,7 @@ static void mmu2_not_responding() {
726 728
           extruder = index;
727 729
           active_extruder = 0;
728 730
         #else
729
-          BUZZ(400, 40);
731
+          ERR_BUZZ();
730 732
         #endif
731 733
       } break;
732 734
 
@@ -811,25 +813,21 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
811 813
       if (turn_off_nozzle && resume_hotend_temp) {
812 814
         thermalManager.setTargetHotend(resume_hotend_temp, active_extruder);
813 815
         LCD_MESSAGE(MSG_HEATING);
814
-        BUZZ(200, 40);
816
+        ERR_BUZZ();
815 817
 
816 818
         while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(1000);
817 819
       }
818 820
 
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);
822 823
 
824
+      if (move_axes && all_axes_homed()) {
823 825
         // Move XY to starting position, then Z
824 826
         do_blocking_move_to_xy(resume_position, feedRate_t(NOZZLE_PARK_XY_FEEDRATE));
825 827
 
826 828
         // Move Z_AXIS to saved position
827 829
         do_blocking_move_to_z(resume_position.z, feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
828 830
       }
829
-      else {
830
-        BUZZ(198, 404); BUZZ(4, 0); BUZZ(198, 404);
831
-        LCD_MESSAGE(MSG_MMU2_RESUMING);
832
-      }
833 831
     }
834 832
   }
835 833
 }
@@ -898,7 +896,7 @@ void MMU2::load_filament(const uint8_t index) {
898 896
 
899 897
   command(MMU_CMD_L0 + index);
900 898
   manage_response(false, false);
901
-  BUZZ(200, 404);
899
+  ATTN_BUZZ();
902 900
 }
903 901
 
904 902
 /**
@@ -909,7 +907,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
909 907
   if (!_enabled) return false;
910 908
 
911 909
   if (thermalManager.tooColdToExtrude(active_extruder)) {
912
-    BUZZ(200, 404);
910
+    ATTN_BUZZ();
913 911
     LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
914 912
     return false;
915 913
   }
@@ -924,7 +922,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
924 922
     extruder = index;
925 923
     active_extruder = 0;
926 924
     load_to_nozzle();
927
-    BUZZ(200, 404);
925
+    ATTN_BUZZ();
928 926
   }
929 927
   return success;
930 928
 }
@@ -945,7 +943,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
945 943
   if (!_enabled) return false;
946 944
 
947 945
   if (thermalManager.tooColdToExtrude(active_extruder)) {
948
-    BUZZ(200, 404);
946
+    ATTN_BUZZ();
949 947
     LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
950 948
     return false;
951 949
   }
@@ -961,12 +959,11 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
961 959
 
962 960
   if (recover)  {
963 961
     LCD_MESSAGE(MSG_MMU2_EJECT_RECOVER);
964
-    BUZZ(200, 404);
962
+    ATTN_BUZZ();
965 963
     TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("MMU2 Eject Recover"), FPSTR(CONTINUE_STR)));
966 964
     TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("MMU2 Eject Recover")));
967 965
     TERN_(HAS_RESUME_CONTINUE, wait_for_user_response());
968
-    BUZZ(200, 404);
969
-    BUZZ(200, 404);
966
+    ATTN_BUZZ(true);
970 967
 
971 968
     command(MMU_CMD_R0);
972 969
     manage_response(false, false);
@@ -979,7 +976,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
979 976
 
980 977
   set_runout_valid(false);
981 978
 
982
-  BUZZ(200, 404);
979
+  ATTN_BUZZ();
983 980
 
984 981
   stepper.disable_extruder();
985 982
 
@@ -994,7 +991,7 @@ bool MMU2::unload() {
994 991
   if (!_enabled) return false;
995 992
 
996 993
   if (thermalManager.tooColdToExtrude(active_extruder)) {
997
-    BUZZ(200, 404);
994
+    ATTN_BUZZ();
998 995
     LCD_ALERTMESSAGE(MSG_HOTEND_TOO_COLD);
999 996
     return false;
1000 997
   }
@@ -1005,7 +1002,7 @@ bool MMU2::unload() {
1005 1002
   command(MMU_CMD_U0);
1006 1003
   manage_response(false, true);
1007 1004
 
1008
-  BUZZ(200, 404);
1005
+  ATTN_BUZZ();
1009 1006
 
1010 1007
   // no active tool
1011 1008
   extruder = MMU2_NO_TOOL;

+ 1
- 2
Marlin/src/gcode/bedlevel/mbl/G29.cpp View File

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

+ 2
- 3
Marlin/src/gcode/geometry/M206_M428.cpp View File

@@ -92,7 +92,7 @@ void GcodeSuite::M428() {
92 92
     if (!WITHIN(diff[i], -20, 20)) {
93 93
       SERIAL_ERROR_MSG(STR_ERR_M428_TOO_FAR);
94 94
       LCD_ALERTMESSAGE_F("Err: Too far!");
95
-      BUZZ(200, 40);
95
+      ERR_BUZZ();
96 96
       return;
97 97
     }
98 98
   }
@@ -100,8 +100,7 @@ void GcodeSuite::M428() {
100 100
   LOOP_LINEAR_AXES(i) set_home_offset((AxisEnum)i, diff[i]);
101 101
   report_current_position();
102 102
   LCD_MESSAGE(MSG_HOME_OFFSETS_APPLIED);
103
-  BUZZ(100, 659);
104
-  BUZZ(100, 698);
103
+  OKAY_BUZZ();
105 104
 }
106 105
 
107 106
 #endif // HAS_M206_COMMAND

+ 3
- 11
Marlin/src/lcd/e3v2/jyersui/dwin.cpp View File

@@ -4920,18 +4920,10 @@ void CrealityDWINClass::Screen_Update() {
4920 4920
 }
4921 4921
 
4922 4922
 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);
4933 4925
   else
4934
-    Update_Status("Failed");
4926
+    Update_Status(success ? "Success" : "Failed");
4935 4927
 }
4936 4928
 
4937 4929
 void CrealityDWINClass::Save_Settings(char *buff) {

+ 1
- 11
Marlin/src/lcd/e3v2/proui/dwin.cpp View File

@@ -1285,17 +1285,7 @@ void HMI_Printing() {
1285 1285
 
1286 1286
 #include "../../../libs/buzzer.h"
1287 1287
 
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); }
1299 1289
 
1300 1290
 void Draw_Main_Area() {
1301 1291
   switch (checkkey) {

+ 1
- 5
Marlin/src/lcd/menu/menu.cpp View File

@@ -276,11 +276,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
276 276
 #if HAS_BUZZER
277 277
   void MarlinUI::completion_feedback(const bool good/*=true*/) {
278 278
     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();
284 280
   }
285 281
 #endif
286 282
 

+ 5
- 0
Marlin/src/libs/buzzer.h View File

@@ -127,3 +127,8 @@
127 127
   #define BUZZ(d,f) NOOP
128 128
 
129 129
 #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)

+ 1
- 1
Marlin/src/module/printcounter.cpp View File

@@ -151,7 +151,7 @@ void PrintCounter::loadStats() {
151 151
       if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3));
152 152
     #endif
153 153
     #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); }
155 155
     #else
156 156
       UNUSED(doBuzz);
157 157
     #endif

+ 1
- 2
Marlin/src/module/probe.cpp View File

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

Loading…
Cancel
Save