Skip to content

Commit

Permalink
✨ STARTUP_TUNE configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 16, 2023
1 parent cc3a355 commit 42c62ff
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
12 changes: 12 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) =========================
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
10 changes: 10 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/NUCLEO_F767ZI
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42c62ff

Please sign in to comment.