Distinguish between BUZZER and SPEAKER (PR#2513)
A speaker needs a AC or a pulsed DC to make a sound, a buzzer only needs a DC. A buzzer has it's own resonator. It works in most cases to feed the buzzer with a pulsed DC, but the sound will not be as loud as with pure DC. There seem to be boards where the BEEPER-pin is not able to handle a PWM. Obviously intended for a buzzer. To make these board able to handle a speaker * replace the PWM based tone()-function again with a on-delay-off-delay loop. Hopefully the last time I touch the beeper code.
This commit is contained in:
parent
53d9c9ff23
commit
fd0e81b0c7
|
@ -647,6 +647,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -9,8 +9,21 @@
|
|||
lcd_buzz(duration, freq);
|
||||
#elif defined(BEEPER) && BEEPER >= 0 // on-board buzzers have no further condition
|
||||
SET_OUTPUT(BEEPER);
|
||||
tone(BEEPER, freq, duration);
|
||||
delay(duration);
|
||||
#ifdef SPEAKER // a speaker needs a AC ore a pulsed DC
|
||||
//tone(BEEPER, freq, duration); // needs a PWMable pin
|
||||
unsigned int delay = 1000000 / freq / 2;
|
||||
int i = duration * freq / 1000;
|
||||
while (i--) {
|
||||
WRITE(BEEPER,HIGH);
|
||||
delayMicroseconds(delay);
|
||||
WRITE(BEEPER,LOW);
|
||||
delayMicroseconds(delay);
|
||||
}
|
||||
#else // buzzer has its own resonator - needs a DC
|
||||
WRITE(BEEPER, HIGH);
|
||||
delay(duration);
|
||||
WRITE(BEEPER, LOW);
|
||||
#endif
|
||||
#else
|
||||
delay(duration);
|
||||
#endif
|
||||
|
|
|
@ -647,6 +647,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -630,6 +630,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -587,6 +587,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -639,6 +639,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -635,6 +635,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
#define ULTIMAKERCONTROLLER // K8200: for Display VM8201 // as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -647,6 +647,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -627,6 +627,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -655,6 +655,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -639,6 +639,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -647,6 +647,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -767,6 +767,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -767,6 +767,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -771,6 +771,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -766,6 +766,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -650,6 +650,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
|
@ -641,6 +641,7 @@ const bool Z_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the logic
|
|||
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
|
||||
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
|
||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
|
||||
|
|
Loading…
Reference in a new issue