Browse Source

🧑‍💻 Add standard BUZZ types

Scott Lahteine 3 years ago
parent
commit
89a9c3a391

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

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

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

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

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

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

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

4920
 }
4920
 }
4921
 
4921
 
4922
 void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
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
   else
4925
   else
4934
-    Update_Status("Failed");
4926
+    Update_Status(success ? "Success" : "Failed");
4935
 }
4927
 }
4936
 
4928
 
4937
 void CrealityDWINClass::Save_Settings(char *buff) {
4929
 void CrealityDWINClass::Save_Settings(char *buff) {

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

1285
 
1285
 
1286
 #include "../../../libs/buzzer.h"
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
 void Draw_Main_Area() {
1290
 void Draw_Main_Area() {
1301
   switch (checkkey) {
1291
   switch (checkkey) {

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

276
 #if HAS_BUZZER
276
 #if HAS_BUZZER
277
   void MarlinUI::completion_feedback(const bool good/*=true*/) {
277
   void MarlinUI::completion_feedback(const bool good/*=true*/) {
278
     TERN_(HAS_TOUCH_SLEEP, wakeup_screen()); // Wake up on rotary encoder click...
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
 #endif
281
 #endif
286
 
282
 

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

127
   #define BUZZ(d,f) NOOP
127
   #define BUZZ(d,f) NOOP
128
 
128
 
129
 #endif
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
       if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3));
151
       if (data.nextService3 == 0) doBuzz = _service_warn(PSTR(" " SERVICE_NAME_3));
152
     #endif
152
     #endif
153
     #if HAS_BUZZER && SERVICE_WARNING_BUZZES > 0
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
     #else
155
     #else
156
       UNUSED(doBuzz);
156
       UNUSED(doBuzz);
157
     #endif
157
     #endif

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

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

Loading…
Cancel
Save