From 1a0f8898035185277e2c4dfbf084dd7a989d6ed1 Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Sun, 24 Mar 2013 23:35:05 -0500 Subject: [PATCH 1/3] Add support for M300: Play beep sound --- Marlin/Marlin_main.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 372554617..1d8e37223 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -117,6 +117,7 @@ // M220 S- set speed factor override percentage // M221 S- set extrude factor override percentage // M240 - Trigger a camera to take a photograph +// M300 - Play beepsound S P // M301 - Set PID parameters P I and D // M302 - Allow cold extrudes // M303 - PID relay autotune S sets the target temperature. (default target temperature = 150C) @@ -157,12 +158,12 @@ float add_homeing[3]={0,0,0}; float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; // Extruder offset, only in XY plane -#if EXTRUDERS > 1 +#if EXTRUDERS > 1 float extruder_offset[2][EXTRUDERS] = { #if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y) EXTRUDER_OFFSET_X, EXTRUDER_OFFSET_Y #endif -}; +}; #endif uint8_t active_extruder = 0; int fanSpeed=0; @@ -1380,7 +1381,7 @@ void process_commands() } }break; - #endif // FWRETRACT + #endif // FWRETRACT #if EXTRUDERS > 1 case 218: // M218 - set hotend offset (in mm), T X Y { @@ -1405,7 +1406,7 @@ void process_commands() SERIAL_ECHO(extruder_offset[Y_AXIS][tmp_extruder]); } SERIAL_ECHOLN(""); - }break; + }break; #endif case 220: // M220 S- set speed factor override percentage { @@ -1424,6 +1425,20 @@ void process_commands() } break; + #ifdef BEEPER + case 300: // M300 + { + int beepS = 1; + int beepP = 1000; + if(code_seen('S')) beepS = code_value(); + if(code_seen('P')) beepP = code_value(); + tone(BEEPER, beepS); + delay(beepP); + noTone(BEEPER); + } + break; + #endif // M300 + #ifdef PIDTEMP case 301: // M301 { @@ -1756,7 +1771,7 @@ void process_commands() if(make_move && Stopped == false) { prepare_move(); } - } + } #endif SERIAL_ECHO_START; SERIAL_ECHO(MSG_ACTIVE_EXTRUDER); From 9a1c90471f630a3011622fed25959b9e197e1ea2 Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Mon, 25 Mar 2013 10:28:15 -0500 Subject: [PATCH 2/3] Ignore unused beeper pins --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1d8e37223..27e35b6a5 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1425,7 +1425,7 @@ void process_commands() } break; - #ifdef BEEPER + #if defined(BEEPER) && BEEPER > -1 case 300: // M300 { int beepS = 1; From 0d075378d500dedf46877fceaf27c9d46f0f31ad Mon Sep 17 00:00:00 2001 From: Colin Edwards Date: Mon, 25 Mar 2013 10:42:27 -0500 Subject: [PATCH 3/3] Add LARGE_FLASH define and enable it for some of the beefier boards The LARGE_FLASH flag allows superfluous features to be excluded on boards with less memory --- Marlin/Marlin_main.cpp | 4 ++-- Marlin/pins.h | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 27e35b6a5..069438486 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1424,8 +1424,8 @@ void process_commands() } } break; - - #if defined(BEEPER) && BEEPER > -1 + + #if defined(LARGE_FLASH) && LARGE_FLASH == true && defined(BEEPER) && BEEPER > -1 case 300: // M300 { int beepS = 1; diff --git a/Marlin/pins.h b/Marlin/pins.h index f1babfa70..17b47f312 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -321,6 +321,8 @@ #if MOTHERBOARD == 33 || MOTHERBOARD == 34 +#define LARGE_FLASH true + #define X_STEP_PIN 54 #define X_DIR_PIN 55 #define X_ENABLE_PIN 38 @@ -789,6 +791,8 @@ #endif #endif +#define LARGE_FLASH true + #define X_STEP_PIN 25 #define X_DIR_PIN 23 #define X_MIN_PIN 22 @@ -924,6 +928,8 @@ #endif #endif +#define LARGE_FLASH true + #define X_STEP_PIN 25 #define X_DIR_PIN 23 #define X_MIN_PIN 15 @@ -993,6 +999,8 @@ #error Oops! Make sure you have 'Teensy++ 2.0' selected from the 'Tools -> Boards' menu. #endif +#define LARGE_FLASH true + #define X_STEP_PIN 0 #define X_DIR_PIN 1 #define X_ENABLE_PIN 39 @@ -1326,6 +1334,8 @@ #error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu. #endif +#define LARGE_FLASH true + #define X_STEP_PIN 37 #define X_DIR_PIN 48 #define X_MIN_PIN 12 @@ -1401,7 +1411,7 @@ #endif - +#define LARGE_FLASH true #define X_STEP_PIN 26 #define X_DIR_PIN 28