Browse Source

More Beeper clean up.

Centralised beep code to lcd_buzz().
From gcode_M300() and lcd_quick_feedback().

Enforced max. duration for M300 to 5 seconds.

Corrected description in 'Configuration.h'

LCD_FEEDBACK_FREQUENCY_HZ 0 gives now a silent delay of
LCD_FEEDBACK_FREQUENCY_DURATION_MS.
AnHardt 10 years ago
parent
commit
064f2b37d0

+ 3
- 4
Marlin/Configuration.h View File

661
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
661
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
662
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
662
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
663
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
663
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
664
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
665
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
664
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
666
-                                               // 0 to disable buzzer feedback  
667
-
665
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
666
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
668
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
667
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
669
 // http://reprap.org/wiki/PanelOne
668
 // http://reprap.org/wiki/PanelOne
670
 //#define PANEL_ONE
669
 //#define PANEL_ONE
681
 
680
 
682
 // The RepRapDiscount Smart Controller (white PCB)
681
 // The RepRapDiscount Smart Controller (white PCB)
683
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
682
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
684
-//#define REPRAP_DISCOUNT_SMART_CONTROLLER
683
+#define REPRAP_DISCOUNT_SMART_CONTROLLER
685
 
684
 
686
 // The GADGETS3D G3D LCD/SD Controller (blue PCB)
685
 // The GADGETS3D G3D LCD/SD Controller (blue PCB)
687
 // http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel
686
 // http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel

+ 2
- 14
Marlin/Marlin_main.cpp View File

3965
   inline void gcode_M300() {
3965
   inline void gcode_M300() {
3966
     uint16_t beepS = code_seen('S') ? code_value_short() : 110;
3966
     uint16_t beepS = code_seen('S') ? code_value_short() : 110;
3967
     uint32_t beepP = code_seen('P') ? code_value_long() : 1000;
3967
     uint32_t beepP = code_seen('P') ? code_value_long() : 1000;
3968
-    if (beepS > 0) {
3969
-      #if BEEPER > 0
3970
-        tone(BEEPER, beepS);
3971
-        delay(beepP);
3972
-        noTone(BEEPER);
3973
-      #elif defined(ULTRALCD)
3974
-        lcd_buzz(beepP, beepS);
3975
-      #elif defined(LCD_USE_I2C_BUZZER)
3976
-        lcd_buzz(beepP, beepS);
3977
-      #endif
3978
-    }
3979
-    else {
3980
-      delay(beepP);
3981
-    }
3968
+    if (beepP > 5000) beepP = 5000; // limit to 5 seconds
3969
+    lcd_buzz(beepP, beepS);
3982
   }
3970
   }
3983
 
3971
 
3984
 #endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER
3972
 #endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER

+ 2
- 2
Marlin/configurator/config/Configuration.h View File

660
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
660
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
661
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
661
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
662
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
662
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
663
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
664
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
663
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
665
-                                               // 0 to disable buzzer feedback  
664
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
665
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
666
 
666
 
667
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
667
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
668
 // http://reprap.org/wiki/PanelOne
668
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/Felix/Configuration.h View File

594
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
594
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
595
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
595
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
596
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
596
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
597
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
598
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
597
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
599
-                                               // 0 to disable buzzer feedback  
598
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
599
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
600
 
600
 
601
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
601
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
602
 // http://reprap.org/wiki/PanelOne
602
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/Felix/Configuration_DUAL.h View File

590
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
590
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
591
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
591
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
592
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
592
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
593
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
594
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
593
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
595
-                                               // 0 to disable buzzer feedback  
594
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
595
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
596
 
596
 
597
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
597
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
598
 // http://reprap.org/wiki/PanelOne
598
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/Hephestos/Configuration.h View File

614
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
614
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
615
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
615
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
616
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
616
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
617
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
618
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
617
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
619
-                                               // 0 to disable buzzer feedback  
618
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
619
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
620
 
620
 
621
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
621
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
622
 // http://reprap.org/wiki/PanelOne
622
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/K8200/Configuration.h View File

622
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
622
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
623
 #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
623
 #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
624
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
624
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
625
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
626
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
625
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
627
-                                               // 0 to disable buzzer feedback  
626
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
627
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
628
 
628
 
629
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
629
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
630
 // http://reprap.org/wiki/PanelOne
630
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/SCARA/Configuration.h View File

645
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
645
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
646
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
646
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
647
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
647
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
648
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
649
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
648
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
650
-                                               // 0 to disable buzzer feedback  
649
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
650
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
651
 
651
 
652
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
652
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
653
 // http://reprap.org/wiki/PanelOne
653
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/WITBOX/Configuration.h View File

613
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
613
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
614
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
614
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
615
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
615
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
616
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
617
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
616
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
618
-                                               // 0 to disable buzzer feedback  
617
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
618
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
619
 
619
 
620
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
620
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
621
 // http://reprap.org/wiki/PanelOne
621
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/delta/generic/Configuration.h View File

662
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
662
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
663
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
663
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
664
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
664
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
665
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
666
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
665
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
667
-                                               // 0 to disable buzzer feedback  
666
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
667
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
668
 
668
 
669
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
669
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
670
 // http://reprap.org/wiki/PanelOne
670
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

666
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
666
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
667
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
667
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
668
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
668
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
669
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
670
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
669
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
671
-                                               // 0 to disable buzzer feedback  
670
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
671
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
672
 
672
 
673
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
673
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
674
 // http://reprap.org/wiki/PanelOne
674
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/makibox/Configuration.h View File

613
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
613
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
614
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
614
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
615
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
615
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
616
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
617
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
616
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
618
-                                               // 0 to disable buzzer feedback  
617
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
618
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
619
 
619
 
620
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
620
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
621
 // http://reprap.org/wiki/PanelOne
621
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

619
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
619
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
620
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
620
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
621
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
621
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
622
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
623
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
622
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
624
-                                               // 0 to disable buzzer feedback  
623
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
624
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
625
 
625
 
626
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
626
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
627
 // http://reprap.org/wiki/PanelOne
627
 // http://reprap.org/wiki/PanelOne

+ 21
- 14
Marlin/ultralcd.cpp View File

1131
     #endif    
1131
     #endif    
1132
     lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
1132
     lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
1133
   #elif defined(BEEPER) && BEEPER > -1
1133
   #elif defined(BEEPER) && BEEPER > -1
1134
-    SET_OUTPUT(BEEPER);
1135
     #ifndef LCD_FEEDBACK_FREQUENCY_HZ
1134
     #ifndef LCD_FEEDBACK_FREQUENCY_HZ
1136
       #define LCD_FEEDBACK_FREQUENCY_HZ 5000
1135
       #define LCD_FEEDBACK_FREQUENCY_HZ 5000
1137
     #endif
1136
     #endif
1138
     #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
1137
     #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
1139
       #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
1138
       #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
1140
     #endif
1139
     #endif
1141
-    const uint16_t delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2;
1142
-    uint16_t i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000;
1143
-    while (i--) {
1144
-      WRITE(BEEPER,HIGH);
1145
-      delayMicroseconds(delay);
1146
-      WRITE(BEEPER,LOW);
1147
-      delayMicroseconds(delay);
1148
-    }
1149
-    const uint16_t j = max(10000 - LCD_FEEDBACK_FREQUENCY_DURATION_MS * 1000, 0);
1150
-    if (j) delayMicroseconds(j);
1140
+    lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
1141
+  #else
1142
+    #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
1143
+      #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
1144
+    #endif
1145
+    delay(LCD_FEEDBACK_FREQUENCY_DURATION_MS);
1151
   #endif
1146
   #endif
1152
 }
1147
 }
1153
 
1148
 
1544
 }
1539
 }
1545
 
1540
 
1546
 void lcd_buzz(long duration, uint16_t freq) {
1541
 void lcd_buzz(long duration, uint16_t freq) {
1547
-  #ifdef LCD_USE_I2C_BUZZER
1548
-    lcd.buzz(duration,freq);
1549
-  #endif
1542
+  if (freq > 0) {
1543
+    #if BEEPER > 0
1544
+      SET_OUTPUT(BEEPER);
1545
+      tone(BEEPER, freq);
1546
+      delay(duration);
1547
+      noTone(BEEPER);
1548
+    #elif defined(LCD_USE_I2C_BUZZER)
1549
+      lcd.buzz(duration,freq);
1550
+    #else
1551
+      delay(duration);
1552
+    #endif
1553
+  }
1554
+  else {
1555
+    delay(duration);
1556
+  }
1550
 }
1557
 }
1551
 
1558
 
1552
 bool lcd_clicked() { return LCD_CLICKED; }
1559
 bool lcd_clicked() { return LCD_CLICKED; }

Loading…
Cancel
Save