Commit 398d211d authored by MagoKimbra's avatar MagoKimbra

Add Buzzer routine

parent dc39cc40
...@@ -226,18 +226,18 @@ ...@@ -226,18 +226,18 @@
// Comment the following line to disable PID and enable bang-bang. // Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP #define PIDTEMP
#ifdef PIDTEMP #ifdef PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port. //#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay //#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
// If the temperature difference between the target temperature and the actual temperature // If the temperature difference between the target temperature and the actual temperature
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
#define PID_FUNCTIONAL_RANGE 10 // degC #define PID_FUNCTIONAL_RANGE 10 // degC
#define PID_INTEGRAL_DRIVE_MAX PID_MAX // Limit for the integral term #define PID_INTEGRAL_DRIVE_MAX PID_MAX // Limit for the integral term
// HotEnd{HE0,HE1,HE2,HE3} // HotEnd{HE0,HE1,HE2,HE3}
#define DEFAULT_Kp {40, 40, 40, 40} // Kp for E0, E1, E2, E3 #define DEFAULT_Kp {40, 40, 40, 40} // Kp for E0, E1, E2, E3
#define DEFAULT_Ki {07, 07, 07, 07} // Ki for E0, E1, E2, E3 #define DEFAULT_Ki {07, 07, 07, 07} // Ki for E0, E1, E2, E3
#define DEFAULT_Kd {60, 60, 60, 60} // Kd for E0, E1, E2, E3 #define DEFAULT_Kd {60, 60, 60, 60} // Kd for E0, E1, E2, E3
#endif // PIDTEMP #endif // PIDTEMP
//=========================================================================== //===========================================================================
...@@ -265,12 +265,12 @@ ...@@ -265,12 +265,12 @@
//#define PID_BED_DEBUG // Sends debug data to the serial port. //#define PID_BED_DEBUG // Sends debug data to the serial port.
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
#define PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER // limit for the integral term #define PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER // limit for the integral term
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10) //from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
#define DEFAULT_bedKp 10.00 #define DEFAULT_bedKp 10.00
#define DEFAULT_bedKi .023 #define DEFAULT_bedKi .023
#define DEFAULT_bedKd 305.4 #define DEFAULT_bedKd 305.4
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+) //120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from pidautotune //from pidautotune
...@@ -620,9 +620,9 @@ ...@@ -620,9 +620,9 @@
// It is assumed that when logic high = filament available // It is assumed that when logic high = filament available
// when logic low = filament run out // when logic low = filament run out
#ifdef FILAMENT_RUNOUT_SENSOR #ifdef FILAMENT_RUNOUT_SENSOR
const bool FILRUNOUT_PIN_INVERTING = true; // Should be uncommented and true or false should assigned const bool FILRUNOUT_PIN_INVERTING = true; // Should be uncommented and true or false should assigned
#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined. #define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined.
#define FILAMENT_RUNOUT_SCRIPT "M600" // Script execute when filament run out #define FILAMENT_RUNOUT_SCRIPT "M600" // Script execute when filament run out
#endif #endif
//=========================================================================== //===========================================================================
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "language.h" #include "language.h"
#include "pins_arduino.h" #include "pins_arduino.h"
#include "math.h" #include "math.h"
#include "buzzer.h"
#ifdef BLINKM #ifdef BLINKM
#include "blinkm.h" #include "blinkm.h"
...@@ -1840,7 +1841,7 @@ static void clean_up_after_endstop_move() { ...@@ -1840,7 +1841,7 @@ static void clean_up_after_endstop_move() {
float probe_bed(float x, float y) { float probe_bed(float x, float y) {
//Probe bed at specified location and return z height of bed //Probe bed at specified location and return z height of bed
float probe_bed_z, probe_z, probe_h, probe_l; float probe_bed_z, probe_z;
int probe_count; int probe_count;
// feedrate = homing_feedrate[Z_AXIS]; // feedrate = homing_feedrate[Z_AXIS];
destination[X_AXIS] = x - z_probe_offset[X_AXIS]; destination[X_AXIS] = x - z_probe_offset[X_AXIS];
...@@ -1855,14 +1856,9 @@ static void clean_up_after_endstop_move() { ...@@ -1855,14 +1856,9 @@ static void clean_up_after_endstop_move() {
probe_count = 0; probe_count = 0;
probe_z = -100; probe_z = -100;
probe_h = -100; do {
probe_l = 100;
do
{
probe_bed_z = probe_z; probe_bed_z = probe_z;
probe_z = z_probe() + z_probe_offset[Z_AXIS]; probe_z = z_probe() + z_probe_offset[Z_AXIS];
if (probe_z > probe_h) probe_h = probe_z;
if (probe_z < probe_l) probe_l = probe_z;
probe_count ++; probe_count ++;
} while ((probe_z != probe_bed_z) and (probe_count < 21)); } while ((probe_z != probe_bed_z) and (probe_count < 21));
...@@ -6250,7 +6246,7 @@ void process_next_command() { ...@@ -6250,7 +6246,7 @@ void process_next_command() {
#if defined(DELTA) && defined(Z_PROBE_ENDSTOP) #if defined(DELTA) && defined(Z_PROBE_ENDSTOP)
case 29: // G29 Detailed Z-Probe, probes the bed at more points. case 29: // G29 Detailed Z-Probe, probes the bed at more points.
gcode_G29(); break; gcode_G29(); gcode_M114(); break;
case 30: // G30 Delta AutoCalibration case 30: // G30 Delta AutoCalibration
gcode_G30(); break; gcode_G30(); break;
#endif // DELTA && Z_PROBE_ENDSTOP #endif // DELTA && Z_PROBE_ENDSTOP
......
/*
buzzer.cpp - Library for controlling a buzzer
Created by Mago Kimbra, 10/05/2015
*/
#include "Marlin.h"
#include "buzzer.h"
#include "ultralcd.h"
#if HAS_BUZZER
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#ifdef LCD_USE_I2C_BUZZER
lcd_buzz(duration, freq);
#elif defined(BEEPER) && BEEPER >= 0 // on-board buzzers have no further condition
SET_OUTPUT(BEEPER);
tone(BEEPER, freq, duration);
delay(duration);
noTone(BEEPER);
#else
delay(duration);
#endif
}
else {
delay(duration);
}
}
#endif
/* buzzer.h
* MarlinKimbra
*
*/
#ifndef BUZZER_H
#define BUZZER_H
#if HAS_BUZZER
void buzz(long duration, uint16_t freq);
#endif
#endif BUZZER_H
...@@ -384,7 +384,7 @@ ...@@ -384,7 +384,7 @@
#define DOUBLE_STEP_FREQUENCY MAX_STEP_FREQUENCY #define DOUBLE_STEP_FREQUENCY MAX_STEP_FREQUENCY
#else #else
#define MAX_STEP_FREQUENCY 500000 // Max step frequency for the Due is approx. 330kHz #define MAX_STEP_FREQUENCY 500000 // Max step frequency for the Due is approx. 330kHz
#define DOUBLE_STEP_FREQUENCY 120000 //96kHz is close to maximum for an Arduino Due #define DOUBLE_STEP_FREQUENCY 100000 //96kHz is close to maximum for an Arduino Due
#endif #endif
#else #else
#if defined(CONFIG_STEPPERS_TOSHIBA) || !defined(ENABLE_HIGH_SPEED_STEPPING) #if defined(CONFIG_STEPPERS_TOSHIBA) || !defined(ENABLE_HIGH_SPEED_STEPPING)
......
...@@ -2410,21 +2410,15 @@ ...@@ -2410,21 +2410,15 @@
* 63 - Melzi * 63 - Melzi
* 64 - STB 1.1 * 64 - STB 1.1
* 65 - Azteeg X1 * 65 - Azteeg X1
* 66 - MELZI 1284
****************************************************************************************/ ****************************************************************************************/
#if MB(STB_11) #if MB(SANGUINOLOLU_12) || MB(MELZI) || MB(STB_11) || MB(AZTEEG_X1) || MB(MELZI_1284)
#define STB
#endif
#if MB(MELZI) || MB(MELZI_1284)
#define MELZI
#endif
#if MB(AZTEEG_X1) #if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__)
#define AZTEEG_X1 #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif #endif
#if MB(SANGUINOLOLU_12) || MB(MELZI) || MB(STB_11) || MB(AZTEEG_X1) || MB(MELZI_1284)
#undef MOTHERBOARD #undef MOTHERBOARD
#define MOTHERBOARD BOARD_SANGUINOLOLU_11 #define MOTHERBOARD BOARD_SANGUINOLOLU_11
#define SANGUINOLOLU_V_1_2 #define SANGUINOLOLU_V_1_2
...@@ -2460,22 +2454,22 @@ ...@@ -2460,22 +2454,22 @@
#define LED_PIN -1 #define LED_PIN -1
#define ORIG_FAN_PIN -1 #define ORIG_FAN_PIN -1
#if ORIG_FAN_PIN == 12 || ORIG_FAN_PIN ==13 #if ORIG_FAN_PIN == 12 || ORIG_FAN_PIN ==13
#define FAN_SOFT_PWM #define FAN_SOFT_PWM
#endif #endif
#ifdef MELZI #if MB(MELZI)
#define LED_PIN 27 /* On some broken versions of the Sanguino libraries the pin definitions are wrong, which then needs LED_PIN as pin 28. But you better upgrade your Sanguino libraries! See #368. */ #define LED_PIN 27
#define ORIG_FAN_PIN 4 // Works for Panelolu2 too #define ORIG_FAN_PIN 4 // Works for Panelolu2 too
#endif #endif
#ifdef STB #if MB(STB_11)
#define ORIG_FAN_PIN 4 #define ORIG_FAN_PIN 4
// Uncomment this if you have the first generation (V1.10) of STBs board // Uncomment this if you have the first generation (V1.10) of STBs board
#define LCD_PIN_BL 17 // LCD backlight LED #define LCD_PIN_BL 17 // LCD backlight LED
#endif #endif
#ifdef AZTEEG_X1 #if MB(AZTEEG_X1)
#define ORIG_FAN_PIN 4 #define ORIG_FAN_PIN 4
#endif #endif
...@@ -4072,12 +4066,20 @@ ...@@ -4072,12 +4066,20 @@
#define Y_MIN_PIN 35 #define Y_MIN_PIN 35
#define Y_MAX_PIN 34 #define Y_MAX_PIN 34
#define Y2_STEP_PIN 26
#define Y2_DIR_PIN 25
#define Y2_ENABLE_PIN 27
#define ORIG_Z_STEP_PIN 57 #define ORIG_Z_STEP_PIN 57
#define ORIG_Z_DIR_PIN 56 #define ORIG_Z_DIR_PIN 56
#define ORIG_Z_ENABLE_PIN 62 #define ORIG_Z_ENABLE_PIN 62
#define Z_MIN_PIN 33 #define Z_MIN_PIN 33
#define Z_MAX_PIN 32 #define Z_MAX_PIN 32
#define Z2_STEP_PIN 26
#define Z2_DIR_PIN 25
#define Z2_ENABLE_PIN 27
#define ORIG_E0_STEP_PIN 23 #define ORIG_E0_STEP_PIN 23
#define ORIG_E0_DIR_PIN 22 #define ORIG_E0_DIR_PIN 22
#define ORIG_E0_ENABLE_PIN 24 #define ORIG_E0_ENABLE_PIN 24
......
...@@ -1059,7 +1059,7 @@ float junction_deviation = 0.1; ...@@ -1059,7 +1059,7 @@ float junction_deviation = 0.1;
st_set_position(nx, ny, nz, ne); st_set_position(nx, ny, nz, ne);
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
for (int i=0; i < NUM_AXIS; i++) previous_speed[i] = 0.0; for (int i = 0; i < NUM_AXIS; i++) previous_speed[i] = 0.0;
} }
void plan_set_e_position(const float &e) { void plan_set_e_position(const float &e) {
......
...@@ -1917,25 +1917,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } ...@@ -1917,25 +1917,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#endif // ULTIPANEL #endif // ULTIPANEL
#if HAS_BUZZER
void buzz(long duration, uint16_t freq) {
if (freq > 0) {
#ifdef LCD_USE_I2C_BUZZER
lcd.buzz(duration, freq);
#elif defined(BEEPER) && BEEPER >= 0
SET_OUTPUT(BEEPER);
tone(BEEPER, freq, duration);
delay(duration);
#else
delay(duration);
#endif
}
else {
delay(duration);
}
}
#endif
/*********************************/ /*********************************/
/** Number to string conversion **/ /** Number to string conversion **/
/*********************************/ /*********************************/
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define ULTRALCD_H #define ULTRALCD_H
#include "Marlin.h" #include "Marlin.h"
#include "buzzer.h"
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
int lcd_strlen(char *s); int lcd_strlen(char *s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment