Merge pull request #4506 from thinkyhead/rc_buzzer_needs_beeper

Buzzer requires BEEPER_PIN
This commit is contained in:
Scott Lahteine 2016-08-02 14:40:43 -07:00 committed by GitHub
commit fbd8f06951
6 changed files with 30 additions and 26 deletions

View File

@ -384,9 +384,8 @@ extern uint8_t active_extruder;
void calculate_volumetric_multipliers(); void calculate_volumetric_multipliers();
// Buzzer // Buzzer
#if HAS_BUZZER #if HAS_BUZZER && PIN_EXISTS(BEEPER)
#include "buzzer.h" #include "buzzer.h"
extern Buzzer buzzer;
#endif #endif
/** /**

View File

@ -373,9 +373,14 @@ static millis_t stepper_inactive_time = (DEFAULT_STEPPER_DEACTIVE_TIME) * 1000UL
Stopwatch print_job_timer = Stopwatch(); Stopwatch print_job_timer = Stopwatch();
#endif #endif
// Buzzer // Buzzer - I2C on the LCD or a BEEPER_PIN
#if HAS_BUZZER #if ENABLED(LCD_USE_I2C_BUZZER)
#define BUZZ(d,f) lcd_buzz(d, f)
#elif HAS_BUZZER
Buzzer buzzer; Buzzer buzzer;
#define BUZZ(d,f) buzzer.tone(d, f)
#else
#define BUZZ(d,f) NOOP
#endif #endif
static uint8_t target_extruder; static uint8_t target_extruder;
@ -5657,7 +5662,7 @@ inline void gcode_M226() {
// Limits the tone duration to 0-5 seconds. // Limits the tone duration to 0-5 seconds.
NOMORE(duration, 5000); NOMORE(duration, 5000);
buzzer.tone(duration, frequency); BUZZ(duration, frequency);
} }
#endif // HAS_BUZZER #endif // HAS_BUZZER
@ -6129,9 +6134,7 @@ inline void gcode_M428() {
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR); SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
LCD_ALERTMESSAGEPGM("Err: Too far!"); LCD_ALERTMESSAGEPGM("Err: Too far!");
#if HAS_BUZZER BUZZ(200, 40);
buzzer.tone(200, 40);
#endif
err = true; err = true;
break; break;
} }
@ -6142,10 +6145,8 @@ inline void gcode_M428() {
SYNC_PLAN_POSITION_KINEMATIC(); SYNC_PLAN_POSITION_KINEMATIC();
report_current_position(); report_current_position();
LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED); LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
#if HAS_BUZZER BUZZ(200, 659);
buzzer.tone(200, 659); BUZZ(200, 698);
buzzer.tone(200, 698);
#endif
} }
} }
@ -6327,7 +6328,7 @@ inline void gcode_M503() {
#if HAS_BUZZER #if HAS_BUZZER
millis_t ms = millis(); millis_t ms = millis();
if (ms >= next_tick) { if (ms >= next_tick) {
buzzer.tone(300, 2000); BUZZ(300, 2000);
next_tick = ms + 2500; // Beep every 2.5s while waiting next_tick = ms + 2500; // Beep every 2.5s while waiting
} }
#endif #endif
@ -8470,7 +8471,7 @@ void idle(
print_job_timer.tick(); print_job_timer.tick();
#endif #endif
#if HAS_BUZZER #if HAS_BUZZER && PIN_EXISTS(BEEPER)
buzzer.tick(); buzzer.tick();
#endif #endif
} }

View File

@ -27,6 +27,8 @@
#include "circularqueue.h" #include "circularqueue.h"
#include "temperature.h" #include "temperature.h"
#include "MarlinConfig.h"
#define TONE_QUEUE_LENGTH 4 #define TONE_QUEUE_LENGTH 4
/** /**
@ -135,4 +137,6 @@ class Buzzer {
} }
}; };
extern Buzzer buzzer;
#endif #endif

View File

@ -30,7 +30,7 @@
#define BOARD_NAME "Azteeg X3" #define BOARD_NAME "Azteeg X3"
#include "pins_RAMPS.h" #include "pins_RAMPS_13.h"
#if ENABLED(VIKI2) || ENABLED(miniVIKI) #if ENABLED(VIKI2) || ENABLED(miniVIKI)

View File

@ -1074,8 +1074,8 @@ void kill_screen(const char* lcd_msg) {
lcd_return_to_status(); lcd_return_to_status();
//LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE); //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
#if HAS_BUZZER #if HAS_BUZZER
buzzer.tone(200, 659); lcd_buzz(200, 659);
buzzer.tone(200, 698); lcd_buzz(200, 698);
#endif #endif
} }
else { else {
@ -2342,23 +2342,23 @@ void kill_screen(const char* lcd_msg) {
* Audio feedback for controller clicks * Audio feedback for controller clicks
* *
*/ */
void lcd_buzz(long duration, uint16_t freq) {
#if ENABLED(LCD_USE_I2C_BUZZER) #if ENABLED(LCD_USE_I2C_BUZZER)
void lcd_buzz(long duration, uint16_t freq) { // called from buzz() in Marlin_main.cpp where lcd is unknown
lcd.buzz(duration, freq); lcd.buzz(duration, freq);
} #elif PIN_EXISTS(BEEPER)
buzzer.tone(duration, freq);
#endif #endif
}
void lcd_quick_feedback() { void lcd_quick_feedback() {
lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
next_button_update_ms = millis() + 500; next_button_update_ms = millis() + 500;
// Buzz and wait. The delay is needed for buttons to settle! // Buzz and wait. The delay is needed for buttons to settle!
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
#if ENABLED(LCD_USE_I2C_BUZZER) #if ENABLED(LCD_USE_I2C_BUZZER)
lcd.buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
delay(10); delay(10);
#elif PIN_EXISTS(BEEPER) #elif PIN_EXISTS(BEEPER)
buzzer.tone(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); } for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
#endif #endif
} }

View File

@ -43,7 +43,7 @@
void lcd_kill_screen(); void lcd_kill_screen();
void kill_screen(const char* lcd_msg); void kill_screen(const char* lcd_msg);
#if ENABLED(LCD_USE_I2C_BUZZER) #if HAS_BUZZER
void lcd_buzz(long duration, uint16_t freq); void lcd_buzz(long duration, uint16_t freq);
#endif #endif