Commit 398d211d authored by MagoKimbra's avatar MagoKimbra

Add Buzzer routine

parent dc39cc40
......@@ -226,18 +226,18 @@
// Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP
#ifdef PIDTEMP
//#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 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
// 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_INTEGRAL_DRIVE_MAX PID_MAX // Limit for the integral term
// HotEnd{HE0,HE1,HE2,HE3}
#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_Kd {60, 60, 60, 60} // Kd for E0, E1, E2, E3
//#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 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
// 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_INTEGRAL_DRIVE_MAX PID_MAX // Limit for the integral term
// HotEnd{HE0,HE1,HE2,HE3}
#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_Kd {60, 60, 60, 60} // Kd for E0, E1, E2, E3
#endif // PIDTEMP
//===========================================================================
......@@ -265,12 +265,12 @@
//#define PID_BED_DEBUG // Sends debug data to the serial port.
#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+)
//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_bedKi .023
#define DEFAULT_bedKd 305.4
#define DEFAULT_bedKp 10.00
#define DEFAULT_bedKi .023
#define DEFAULT_bedKd 305.4
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from pidautotune
......@@ -620,9 +620,9 @@
// It is assumed that when logic high = filament available
// when logic low = filament run out
#ifdef FILAMENT_RUNOUT_SENSOR
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 FILAMENT_RUNOUT_SCRIPT "M600" // Script execute when filament run out
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 FILAMENT_RUNOUT_SCRIPT "M600" // Script execute when filament run out
#endif
//===========================================================================
......
......@@ -47,6 +47,7 @@
#include "language.h"
#include "pins_arduino.h"
#include "math.h"
#include "buzzer.h"
#ifdef BLINKM
#include "blinkm.h"
......@@ -1840,7 +1841,7 @@ static void clean_up_after_endstop_move() {
float probe_bed(float x, float y) {
//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;
// feedrate = homing_feedrate[Z_AXIS];
destination[X_AXIS] = x - z_probe_offset[X_AXIS];
......@@ -1855,14 +1856,9 @@ static void clean_up_after_endstop_move() {
probe_count = 0;
probe_z = -100;
probe_h = -100;
probe_l = 100;
do
{
do {
probe_bed_z = probe_z;
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 ++;
} while ((probe_z != probe_bed_z) and (probe_count < 21));
......@@ -6250,7 +6246,7 @@ void process_next_command() {
#if defined(DELTA) && defined(Z_PROBE_ENDSTOP)
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
gcode_G30(); break;
#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 @@
#define DOUBLE_STEP_FREQUENCY MAX_STEP_FREQUENCY
#else
#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
#else
#if defined(CONFIG_STEPPERS_TOSHIBA) || !defined(ENABLE_HIGH_SPEED_STEPPING)
......
......@@ -2410,21 +2410,15 @@
* 63 - Melzi
* 64 - STB 1.1
* 65 - Azteeg X1
* 66 - MELZI 1284
****************************************************************************************/
#if MB(STB_11)
#define STB
#endif
#if MB(MELZI) || MB(MELZI_1284)
#define MELZI
#endif
#if MB(SANGUINOLOLU_12) || MB(MELZI) || MB(STB_11) || MB(AZTEEG_X1) || MB(MELZI_1284)
#if MB(AZTEEG_X1)
#define AZTEEG_X1
#endif
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__)
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#if MB(SANGUINOLOLU_12) || MB(MELZI) || MB(STB_11) || MB(AZTEEG_X1) || MB(MELZI_1284)
#undef MOTHERBOARD
#define MOTHERBOARD BOARD_SANGUINOLOLU_11
#define SANGUINOLOLU_V_1_2
......@@ -2444,38 +2438,38 @@
#define ORIG_X_STEP_PIN 15
#define ORIG_X_DIR_PIN 21
#define X_STOP_PIN 18
#define X_STOP_PIN 18
#define ORIG_Y_STEP_PIN 22
#define ORIG_Y_DIR_PIN 23
#define Y_STOP_PIN 19
#define Y_STOP_PIN 19
#define ORIG_Z_STEP_PIN 3
#define ORIG_Z_DIR_PIN 2
#define Z_STOP_PIN 20
#define ORIG_Z_STEP_PIN 3
#define ORIG_Z_DIR_PIN 2
#define Z_STOP_PIN 20
#define ORIG_E0_STEP_PIN 1
#define ORIG_E0_DIR_PIN 0
#define LED_PIN -1
#define LED_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
#endif
#ifdef 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. */
#if MB(MELZI)
#define LED_PIN 27
#define ORIG_FAN_PIN 4 // Works for Panelolu2 too
#endif
#ifdef STB
#if MB(STB_11)
#define ORIG_FAN_PIN 4
// Uncomment this if you have the first generation (V1.10) of STBs board
#define LCD_PIN_BL 17 // LCD backlight LED
#endif
#ifdef AZTEEG_X1
#if MB(AZTEEG_X1)
#define ORIG_FAN_PIN 4
#endif
......@@ -2504,11 +2498,11 @@
#ifdef SANGUINOLOLU_V_1_2
#define HEATER_BED_PIN 12 // (bed)
#define ORIG_X_ENABLE_PIN 14
#define ORIG_Y_ENABLE_PIN 14
#define ORIG_Z_ENABLE_PIN 26
#define ORIG_E0_ENABLE_PIN 14
#define HEATER_BED_PIN 12 // (bed)
#define ORIG_X_ENABLE_PIN 14
#define ORIG_Y_ENABLE_PIN 14
#define ORIG_Z_ENABLE_PIN 26
#define ORIG_E0_ENABLE_PIN 14
#ifdef LCD_I2C_PANELOLU2
#define ORIG_FAN_PIN 4 // Uses Transistor1 (PWM) on Panelolu2's Sanguino Adapter Board to drive the fan
......@@ -2516,7 +2510,7 @@
#else
#define HEATER_BED_PIN 14 // (bed)
#define HEATER_BED_PIN 14 // (bed)
#define ORIG_X_ENABLE_PIN -1
#define ORIG_Y_ENABLE_PIN -1
#define ORIG_Z_ENABLE_PIN -1
......@@ -4063,20 +4057,28 @@
#define ORIG_X_STEP_PIN 17
#define ORIG_X_DIR_PIN 16
#define ORIG_X_ENABLE_PIN 48
#define X_MIN_PIN 37
#define X_MAX_PIN 36
#define X_MIN_PIN 37
#define X_MAX_PIN 36
#define ORIG_Y_STEP_PIN 54
#define ORIG_Y_DIR_PIN 47
#define ORIG_Y_ENABLE_PIN 55
#define Y_MIN_PIN 35
#define Y_MAX_PIN 34
#define Y_MIN_PIN 35
#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_DIR_PIN 56
#define ORIG_Z_ENABLE_PIN 62
#define Z_MIN_PIN 33
#define Z_MAX_PIN 32
#define Z_MIN_PIN 33
#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_DIR_PIN 22
......@@ -4090,35 +4092,35 @@
#define ORIG_E2_DIR_PIN 28
#define ORIG_E2_ENABLE_PIN 39
#define LED_PIN 13
#define LED_PIN 13
#define ORIG_FAN_PIN 7
//additional FAN1 PIN (e.g. useful for electronics fan or light on/off) on PIN 8
#define PS_ON_PIN 45
#define KILL_PIN 46
#define PS_ON_PIN 45
#define KILL_PIN 46
#if (TEMP_SENSOR_0==0)
#define TEMP_0_PIN -1
#define HEATER_0_PIN -1
#define TEMP_0_PIN -1
#define HEATER_0_PIN -1
#else
#define HEATER_0_PIN 2 // EXTRUDER 1
#define HEATER_0_PIN 2 // EXTRUDER 1
#if (TEMP_SENSOR_0==-1)
#define TEMP_0_PIN 6 // ANALOG NUMBERING - connector *K1* on RUMBA thermocouple ADD ON is used
#define TEMP_0_PIN 6 // ANALOG NUMBERING - connector *K1* on RUMBA thermocouple ADD ON is used
#else
#define TEMP_0_PIN 15 // ANALOG NUMBERING - default connector for thermistor *T0* on rumba board is used
#define TEMP_0_PIN 15 // ANALOG NUMBERING - default connector for thermistor *T0* on rumba board is used
#endif
#endif
#if (TEMP_SENSOR_1==0)
#define TEMP_1_PIN -1
#define HEATER_1_PIN -1
#define TEMP_1_PIN -1
#define HEATER_1_PIN -1
#else
#define HEATER_1_PIN 3 // EXTRUDER 2
#define HEATER_1_PIN 3 // EXTRUDER 2
#if (TEMP_SENSOR_1==-1)
#define TEMP_1_PIN 5 // ANALOG NUMBERING - connector *K2* on RUMBA thermocouple ADD ON is used
#define TEMP_1_PIN 5 // ANALOG NUMBERING - connector *K2* on RUMBA thermocouple ADD ON is used
#else
#define TEMP_1_PIN 14 // ANALOG NUMBERING - default connector for thermistor *T1* on rumba board is used
#define TEMP_1_PIN 14 // ANALOG NUMBERING - default connector for thermistor *T1* on rumba board is used
#endif
#endif
......
......@@ -1059,7 +1059,7 @@ float junction_deviation = 0.1;
st_set_position(nx, ny, nz, ne);
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) {
......
......@@ -1917,25 +1917,6 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#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 **/
/*********************************/
......
......@@ -2,6 +2,7 @@
#define ULTRALCD_H
#include "Marlin.h"
#include "buzzer.h"
#ifdef ULTRA_LCD
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