From 42c62ff84e9e5322daa61ac2e582414d0304acc8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 15 Apr 2023 17:33:56 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20STARTUP=5FTUNE=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 12 ++++++++++++ Marlin/src/MarlinCore.cpp | 5 +++-- Marlin/src/inc/SanityCheck.h | 10 ++++++++++ buildroot/tests/NUCLEO_F767ZI | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 81591597b2..9844b44e10 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2681,6 +2681,18 @@ //#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 2 //#define LCD_FEEDBACK_FREQUENCY_HZ 5000 +// +// Tone queue size, used to keep beeps from blocking execution. +// Default is 4, or override here. Costs 4 bytes of SRAM per entry. +// +//#define TONE_QUEUE_LENGTH 4 + +// +// A sequence of tones to play at startup, in pairs of tone (Hz), duration (ms). +// Silence in-between tones. +// +//#define STARTUP_TUNE { 698, 300, 0, 50, 523, 50, 0, 25, 494, 50, 0, 25, 523, 100, 0, 50, 554, 300, 0, 100, 523, 300 } + //============================================================================= //======================== LCD / Controller Selection ========================= //======================== (Character-based LCDs) ========================= diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index aaa8e0b4b4..8c0f7a29e8 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1660,9 +1660,10 @@ void setup() { marlin_state = MF_RUNNING; - #if ENABLED(SPEAKER) && defined(STARTUP_TUNE) + #ifdef STARTUP_TUNE + // Play a short startup tune before continuing. constexpr uint16_t tune[] = STARTUP_TUNE; - for (uint8_t i = 0; i < COUNT(tune); i += 2) BUZZ(tune[i + 1], tune[i]); + for (uint8_t i = 0; i < COUNT(tune) - 1; i += 2) BUZZ(tune[i + 1], tune[i]); #endif SETUP_LOG("setup() completed."); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 30b5963e44..fd58a9c54e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3324,6 +3324,16 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS #endif #endif +// Startup Tune requirements +#ifdef STARTUP_TUNE + #if EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_VYPER) + #error "STARTUP_TUNE should be disabled with ANYCUBIC_LCD_CHIRON or ANYCUBIC_LCD_VYPER." + #elif !(BOTH(HAS_BEEPER, SPEAKER) || USE_MARLINUI_BUZZER) + #error "STARTUP_TUNE requires a BEEPER_PIN with SPEAKER or USE_MARLINUI_BUZZER." + #undef STARTUP_TUNE + #endif +#endif + /** * Display Sleep is not supported by these common displays */ diff --git a/buildroot/tests/NUCLEO_F767ZI b/buildroot/tests/NUCLEO_F767ZI index 9e23246606..a331618a09 100755 --- a/buildroot/tests/NUCLEO_F767ZI +++ b/buildroot/tests/NUCLEO_F767ZI @@ -11,7 +11,7 @@ set -e # restore_configs opt_set MOTHERBOARD BOARD_NUCLEO_F767ZI SERIAL_PORT -1 X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2208 -opt_enable BLTOUCH Z_SAFE_HOMING SPEAKER SOFTWARE_DRIVER_ENABLE +opt_enable BLTOUCH Z_SAFE_HOMING REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SPEAKER STARTUP_TUNE SOFTWARE_DRIVER_ENABLE exec_test $1 $2 "Mixed timer usage" "$3" # clean up