Selaa lähdekoodia

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 vuotta sitten
vanhempi
commit
064f2b37d0

+ 3
- 4
Marlin/Configuration.h Näytä tiedosto

@@ -661,10 +661,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
661 661
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
662 662
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
663 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 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 667
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
669 668
 // http://reprap.org/wiki/PanelOne
670 669
 //#define PANEL_ONE
@@ -681,7 +680,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
681 680
 
682 681
 // The RepRapDiscount Smart Controller (white PCB)
683 682
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
684
-//#define REPRAP_DISCOUNT_SMART_CONTROLLER
683
+#define REPRAP_DISCOUNT_SMART_CONTROLLER
685 684
 
686 685
 // The GADGETS3D G3D LCD/SD Controller (blue PCB)
687 686
 // http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel

+ 2
- 14
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -3965,20 +3965,8 @@ inline void gcode_M226() {
3965 3965
   inline void gcode_M300() {
3966 3966
     uint16_t beepS = code_seen('S') ? code_value_short() : 110;
3967 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 3972
 #endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER

+ 2
- 2
Marlin/configurator/config/Configuration.h Näytä tiedosto

@@ -660,9 +660,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
660 660
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
661 661
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
662 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 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 667
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
668 668
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/Felix/Configuration.h Näytä tiedosto

@@ -594,9 +594,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
594 594
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
595 595
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
596 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 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 601
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
602 602
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/Felix/Configuration_DUAL.h Näytä tiedosto

@@ -590,9 +590,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
590 590
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
591 591
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
592 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 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 597
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
598 598
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/Hephestos/Configuration.h Näytä tiedosto

@@ -614,9 +614,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
614 614
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
615 615
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
616 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 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 621
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
622 622
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/K8200/Configuration.h Näytä tiedosto

@@ -622,9 +622,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
622 622
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
623 623
 #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
624 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 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 629
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
630 630
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/SCARA/Configuration.h Näytä tiedosto

@@ -645,9 +645,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
645 645
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
646 646
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
647 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 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 652
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
653 653
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/WITBOX/Configuration.h Näytä tiedosto

@@ -613,9 +613,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
613 613
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
614 614
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
615 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 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 620
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
621 621
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/delta/generic/Configuration.h Näytä tiedosto

@@ -662,9 +662,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
662 662
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
663 663
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
664 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 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 669
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
670 670
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/delta/kossel_mini/Configuration.h Näytä tiedosto

@@ -666,9 +666,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
666 666
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
667 667
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
668 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 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 673
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
674 674
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/makibox/Configuration.h Näytä tiedosto

@@ -613,9 +613,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
613 613
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
614 614
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
615 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 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 620
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
621 621
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/tvrrug/Round2/Configuration.h Näytä tiedosto

@@ -619,9 +619,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
619 619
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
620 620
 //#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
621 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 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 626
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
627 627
 // http://reprap.org/wiki/PanelOne

+ 21
- 14
Marlin/ultralcd.cpp Näytä tiedosto

@@ -1131,23 +1131,18 @@ void lcd_quick_feedback() {
1131 1131
     #endif    
1132 1132
     lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
1133 1133
   #elif defined(BEEPER) && BEEPER > -1
1134
-    SET_OUTPUT(BEEPER);
1135 1134
     #ifndef LCD_FEEDBACK_FREQUENCY_HZ
1136 1135
       #define LCD_FEEDBACK_FREQUENCY_HZ 5000
1137 1136
     #endif
1138 1137
     #ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
1139 1138
       #define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2
1140 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 1146
   #endif
1152 1147
 }
1153 1148
 
@@ -1544,9 +1539,21 @@ bool lcd_detected(void) {
1544 1539
 }
1545 1540
 
1546 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 1559
 bool lcd_clicked() { return LCD_CLICKED; }

Loading…
Peruuta
Tallenna