From 4c3cbc09619155d0c397b46755129b55933f25c8 Mon Sep 17 00:00:00 2001 From: Christian Bohn Date: Wed, 25 Mar 2015 12:23:50 +0100 Subject: [PATCH] use only one implementation for beeper feedback --- Marlin/dogm_lcd_implementation.h | 12 --------- Marlin/ultralcd.cpp | 23 +++++++++++++++- .../ultralcd_implementation_hitachi_HD44780.h | 26 ------------------- 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 7025e87bbd..e38b1d2a40 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -408,16 +408,4 @@ static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const c #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') -static void lcd_implementation_quick_feedback() { - #if BEEPER > -1 - SET_OUTPUT(BEEPER); - for(int8_t i=0; i<10; i++) { - WRITE(BEEPER,HIGH); - delay(3); - WRITE(BEEPER,LOW); - delay(3); - } - #endif -} - #endif //__DOGM_LCD_IMPLEMENTATION_H diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index f6af156d53..846a5ac096 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1137,7 +1137,28 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01) static void lcd_quick_feedback() { lcdDrawUpdate = 2; blocking_enc = millis() + 500; - lcd_implementation_quick_feedback(); + +#ifdef LCD_USE_I2C_BUZZER +#if defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) && defined(LCD_FEEDBACK_FREQUENCY_HZ) + lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); +#else + lcd_buzz(1000/6, 100); +#endif +#elif defined(BEEPER) && BEEPER > -1 + SET_OUTPUT(BEEPER); +#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) +#define LCD_FEEDBACK_FREQUENCY_HZ 500 +#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 50 +#endif + const unsigned int delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2; + int8_t i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000; + while (i--) { + WRITE(BEEPER,HIGH); + delayMicroseconds(delay); + WRITE(BEEPER,LOW); + delayMicroseconds(delay); +} +#endif } /** Menu action functions **/ diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 044ac95eee..c303ff06a3 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -709,32 +709,6 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') -static void lcd_implementation_quick_feedback() -{ - #ifdef LCD_USE_I2C_BUZZER - #if defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) && defined(LCD_FEEDBACK_FREQUENCY_HZ) - lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ); - #else - lcd_buzz(1000/6, 100); - #endif - #elif defined(BEEPER) && BEEPER > -1 - SET_OUTPUT(BEEPER); - #if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) - const unsigned int delay = 100; - uint8_t i = 10; - #else - const unsigned int delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2; - int8_t i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000; - #endif - while (i--) { - WRITE(BEEPER,HIGH); - delayMicroseconds(delay); - WRITE(BEEPER,LOW); - delayMicroseconds(delay); - } - #endif -} - #ifdef LCD_HAS_STATUS_INDICATORS static void lcd_implementation_update_indicators() {