From d77e921a1512c22670b5ccf421a186d7ce3bd815 Mon Sep 17 00:00:00 2001 From: Scott Lahteine <thinkyhead@users.noreply.github.com> Date: Fri, 14 Apr 2023 22:26:06 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20STARTUP=5FTUNE=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 5 +++++ Marlin/src/gcode/lcd/M300.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index d2a9f395b70..aaa8e0b4b4e 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1660,6 +1660,11 @@ void setup() { marlin_state = MF_RUNNING; + #if ENABLED(SPEAKER) && defined(STARTUP_TUNE) + constexpr uint16_t tune[] = STARTUP_TUNE; + for (uint8_t i = 0; i < COUNT(tune); i += 2) BUZZ(tune[i + 1], tune[i]); + #endif + SETUP_LOG("setup() completed."); TERN_(MARLIN_TEST_BUILD, runStartupTests()); diff --git a/Marlin/src/gcode/lcd/M300.cpp b/Marlin/src/gcode/lcd/M300.cpp index 76d4b96b242..7ee811f0bdc 100644 --- a/Marlin/src/gcode/lcd/M300.cpp +++ b/Marlin/src/gcode/lcd/M300.cpp @@ -30,10 +30,13 @@ #include "../../libs/buzzer.h" // Buzzer, if possible /** - * M300: Play beep sound S<frequency Hz> P<duration ms> + * M300: Play a Tone / Add a tone to the queue + * + * S<frequency> - (Hz) The frequency of the tone. 0 for silence. + * P<duration> - (ms) The duration of the tone. */ void GcodeSuite::M300() { - uint16_t const frequency = parser.ushortval('S', 260); + const uint16_t frequency = parser.ushortval('S', 260); uint16_t duration = parser.ushortval('P', 1000); // Limits the tone duration to 0-5 seconds.