diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 50552c2dc6..4f2941790d 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -352,10 +352,6 @@ bool pin_is_protected(const int8_t pin) { return false; } -#if HAS_BUZZER - #include "gcode/lcd/M300.h" -#endif - #if ENABLED(PIDTEMP) #include "gcode/config/M301.h" #endif diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 1ba1f5c661..5e089afb24 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -121,7 +121,6 @@ extern void gcode_M164(); extern void gcode_M165(); extern void gcode_M240(); extern void gcode_M250(); -extern void gcode_M300(); extern void gcode_M301(); extern void gcode_M302(); extern void gcode_M304(); @@ -567,10 +566,8 @@ void GcodeSuite::process_next_command() { #endif #if HAS_BUZZER - case 300: // M300: Play beep tone - gcode_M300(); - break; - #endif // HAS_BUZZER + case 300: M300(); break; // M300: Play beep tone + #endif #if ENABLED(PIDTEMP) case 301: // M301: Set hotend PID parameters diff --git a/Marlin/src/gcode/lcd/M300.h b/Marlin/src/gcode/lcd/M300.cpp similarity index 83% rename from Marlin/src/gcode/lcd/M300.h rename to Marlin/src/gcode/lcd/M300.cpp index 9acfb2842f..847efc9c40 100644 --- a/Marlin/src/gcode/lcd/M300.h +++ b/Marlin/src/gcode/lcd/M300.cpp @@ -20,10 +20,19 @@ * */ +#include "../../inc/MarlinConfig.h" + +#if HAS_BUZZER + +#include "../gcode.h" + +#include "../../lcd/ultralcd.h" // i2c-based BUZZ +#include "../../libs/buzzer.h" // Buzzer, if possible + /** * M300: Play beep sound S P */ -void gcode_M300() { +void GcodeSuite::M300() { uint16_t const frequency = parser.ushortval('S', 260); uint16_t duration = parser.ushortval('P', 1000); @@ -32,3 +41,5 @@ void gcode_M300() { BUZZ(duration, frequency); } + +#endif // HAS_BUZZER