Przeglądaj źródła

Merge pull request #1944 from AnHardt/beep2

More Beeper clean up
Scott Lahteine 10 lat temu
rodzic
commit
3b97a7d446

+ 8
- 9
Marlin/Configuration.h Wyświetl plik

@@ -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
@@ -792,13 +791,13 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
792 791
 // Uncomment below to enable
793 792
 //#define FILAMENT_SENSOR
794 793
 
795
-#define FILAMENT_SENSOR_EXTRUDER_NUM	0  //The number of the extruder that has the filament sensor (0,1,2)
796
-#define MEASUREMENT_DELAY_CM			14  //measurement delay in cm.  This is the distance from filament sensor to middle of barrel
794
+#define FILAMENT_SENSOR_EXTRUDER_NUM 0   //The number of the extruder that has the filament sensor (0,1,2)
795
+#define MEASUREMENT_DELAY_CM        14   //measurement delay in cm.  This is the distance from filament sensor to middle of barrel
797 796
 
798
-#define DEFAULT_NOMINAL_FILAMENT_DIA  3.0  //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software.  Used for sensor reading validation
799
-#define MEASURED_UPPER_LIMIT          3.30  //upper limit factor used for sensor reading validation in mm
800
-#define MEASURED_LOWER_LIMIT          1.90  //lower limit factor for sensor reading validation in mm
801
-#define MAX_MEASUREMENT_DELAY			20  //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM  and lower number saves RAM)
797
+#define DEFAULT_NOMINAL_FILAMENT_DIA 3.0 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software.  Used for sensor reading validation
798
+#define MEASURED_UPPER_LIMIT         3.3 //upper limit factor used for sensor reading validation in mm
799
+#define MEASURED_LOWER_LIMIT         1.9 //lower limit factor for sensor reading validation in mm
800
+#define MAX_MEASUREMENT_DELAY       20   //delay buffer size in bytes (1 byte = 1cm)- limits maximum measurement delay allowable (must be larger than MEASUREMENT_DELAY_CM  and lower number saves RAM)
802 801
 
803 802
 //defines used in the code
804 803
 #define DEFAULT_MEASURED_FILAMENT_DIA  DEFAULT_NOMINAL_FILAMENT_DIA  //set measured to nominal initially

+ 2
- 14
Marlin/Marlin_main.cpp Wyświetl plik

@@ -4022,20 +4022,8 @@ inline void gcode_M226() {
4022 4022
   inline void gcode_M300() {
4023 4023
     uint16_t beepS = code_seen('S') ? code_value_short() : 110;
4024 4024
     uint32_t beepP = code_seen('P') ? code_value_long() : 1000;
4025
-    if (beepS > 0) {
4026
-      #if BEEPER > 0
4027
-        tone(BEEPER, beepS);
4028
-        delay(beepP);
4029
-        noTone(BEEPER);
4030
-      #elif defined(ULTRALCD)
4031
-        lcd_buzz(beepS, beepP);
4032
-      #elif defined(LCD_USE_I2C_BUZZER)
4033
-        lcd_buzz(beepP, beepS);
4034
-      #endif
4035
-    }
4036
-    else {
4037
-      delay(beepP);
4038
-    }
4025
+    if (beepP > 5000) beepP = 5000; // limit to 5 seconds
4026
+    lcd_buzz(beepP, beepS);
4039 4027
   }
4040 4028
 
4041 4029
 #endif // BEEPER>0 || ULTRALCD || LCD_USE_I2C_BUZZER

+ 2
- 2
Marlin/configurator/config/Configuration.h Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -672,9 +672,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
672 672
 //#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
673 673
 #define ULTIMAKERCONTROLLER // K8200: for Display VM8201 // as available from the Ultimaker online store.
674 674
 //#define ULTIPANEL  //the UltiPanel as on Thingiverse
675
-//#define LCD_FEEDBACK_FREQUENCY_HZ 1000	// this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
676 675
 //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
677
-                                               // 0 to disable buzzer feedback  
676
+//#define LCD_FEEDBACK_FREQUENCY_HZ 1000         // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
677
+                                                 // 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
678 678
 
679 679
 // PanelOne from T3P3 (via RAMPS 1.4 AUX2/AUX3)
680 680
 // http://reprap.org/wiki/PanelOne

+ 2
- 2
Marlin/example_configurations/SCARA/Configuration.h Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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

+ 19
- 14
Marlin/ultralcd.cpp Wyświetl plik

@@ -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,19 @@ 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, duration);
1546
+    #elif defined(LCD_USE_I2C_BUZZER)
1547
+      lcd.buzz(duration,freq);
1548
+    #else
1549
+      delay(duration);
1550
+    #endif
1551
+  }
1552
+  else {
1553
+    delay(duration);
1554
+  }
1550 1555
 }
1551 1556
 
1552 1557
 bool lcd_clicked() { return LCD_CLICKED; }

Ładowanie…
Anuluj
Zapisz