Commit 8ccd9f2b authored by MagoKimbra's avatar MagoKimbra

Update Marlin_main.cpp

parent be098c85
......@@ -3,10 +3,10 @@
// This configuration file contains basic settings. Select your:
// - board type
// - temperature sensor type
// - Mechanism type (cartesian-corexy-delta-scara)
// - temperature sensor type
//
// Mechanisms-settings can be found in configuration_xxx.h
// Mechanisms-settings can be found in configuration_xxxxxx.h
// Advanced settings can be found in Configuration_adv.h
// Choose your board type.
......@@ -68,7 +68,7 @@
#endif
/***********************************************************************/
// This defines the number of extruders real or virtual
// This defines the number of extruder real or virtual
#define EXTRUDERS 1
// This is used for singlenozzled multiple extrusion configuration
......@@ -88,8 +88,8 @@
***********************************************************************/
//#define MKR4
#ifdef MKR4
#define DELAY_R 500 // Delay for switch rele
#define DRIVER_EXTRUDERS 1 // This defines the number of Driver extruders
#define DELAY_R 500 // Delay for switch rele
#define DRIVER_EXTRUDERS 2 // This defines the number of Driver extruder
#endif // END MKR4
//**********************************************************************
......@@ -107,21 +107,21 @@
***********************************************************************/
//#define NPR2
#ifdef NPR2
#define COLOR_STEP {120,25,-65,-155} // CARTER ANGLE
#define COLOR_SLOWRATE 170 // MICROSECOND delay for carter motor routine (Carter Motor Feedrate: upper value-slow feedrate)
#define COLOR_HOMERATE 4 // FEEDRATE for carter home
#define MOTOR_ANGLE 1.8 // Nema angle for single step
#define DRIVER_MICROSTEP 4 // Microstep moltiplicator driver (set jumper MS1-2-3) off-on-off 1/4 microstepping.
#define CARTER_MOLTIPLICATOR 14.22 // CARTER MOLTIPLICATOR (gear ratio 13/31-10/31)
#define DRIVER_EXTRUDERS 2 // This defines the number of Driver extruders
#define COLOR_STEP {120,25,-65,-155} // CARTER ANGLE
#define COLOR_SLOWRATE 170 // MICROSECOND delay for carter motor routine (Carter Motor Feedrate: upper value-slow feedrate)
#define COLOR_HOMERATE 4 // FEEDRATE for carter home
#define MOTOR_ANGLE 1.8 // Nema angle for single step
#define DRIVER_MICROSTEP 4 // Microstep moltiplicator driver (set jumper MS1-2-3) off-on-off 1/4 microstepping.
#define CARTER_MOLTIPLICATOR 14.22 // CARTER MOLTIPLICATOR (gear ratio 13/31-10/31)
#define DRIVER_EXTRUDERS 2 // This defines the number of Driver extruders
#endif
//**********************************************************************
#if !defined(MKR4) && !defined(NPR2)
#define DRIVER_EXTRUDERS EXTRUDERS // This defines the number of Driver extruders
#define DRIVER_EXTRUDERS EXTRUDERS // This defines the number of Driver extruder
#endif
// The following define selects which power supply you have. Please choose the one that matches your setup
// 0 = Normal power
// 1 = ATX
......@@ -182,7 +182,7 @@
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 // (degC)
#ifdef SINGLENOZZLE
#undef TEMP_SENSOR_1_AS_REDUNDANT
#undef TEMP_SENSOR_1_AS_REDUNDANT
#endif
// Actual temperature must be close to target for this long before M109 returns success
......@@ -220,8 +220,8 @@
//=============================== PID settings ==============================
// Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP
#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current
#define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current
#define PID_MAX BANG_MAX // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
#ifdef PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port.
......@@ -374,32 +374,32 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define ULTIPANEL
#define NEWPANEL
#define DEFAULT_LCD_CONTRAST 17
#endif
#endif //defined (MAKRPANEL)
#if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#define DOGLCD
#define U8GLIB_ST7920
#define REPRAP_DISCOUNT_SMART_CONTROLLER
#endif
#endif //defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#define ULTIPANEL
#define NEWPANEL
#endif
#endif //defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#if defined(REPRAPWORLD_KEYPAD)
#define NEWPANEL
#define ULTIPANEL
#endif
#endif //defined(REPRAPWORLD_KEYPAD)
#if defined(RA_CONTROL_PANEL)
#define ULTIPANEL
#define NEWPANEL
#define LCD_I2C_TYPE_PCA8574
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#endif
#endif //defined(RA_CONTROL_PANEL)
//I2C PANELS
//#define LCD_I2C_SAINSMART_YWROBOT
#ifdef LCD_I2C_SAINSMART_YWROBOT
// This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
......@@ -408,7 +408,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#define NEWPANEL
#define ULTIPANEL
#endif
#endif //LCD_I2C_SAINSMART_YWROBOT
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
//#define LCD_I2C_PANELOLU2
......@@ -432,13 +432,11 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define ENCODER_STEPS_PER_MENU_ITEM 1
#endif
#ifdef LCD_USE_I2C_BUZZER
#define LCD_FEEDBACK_FREQUENCY_HZ 1000
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
#endif
#endif
#endif //LCD_I2C_PANELOLU2
// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
//#define LCD_I2C_VIKI
......@@ -452,7 +450,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
#define NEWPANEL
#define ULTIPANEL
#endif
#endif //LCD_I2C_VIKI
// Shift register panels
// ---------------------
......@@ -464,38 +462,38 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define SR_LCD_2W_NL // Non latching 2 wire shiftregister
#define NEWPANEL
#define ULTIPANEL
#endif
#endif //SAV_3DLCD
#ifdef ULTIPANEL
// #define NEWPANEL //enable this if you have a click-encoder panel
//#define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT
#define ULTRA_LCD
#ifdef DOGLCD // Change number of lines to match the DOG graphic display
#define LCD_WIDTH 20
#define LCD_WIDTH 22
#define LCD_HEIGHT 5
#else
#else //NO DOGLCD
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#endif
#else //no panel but just LCD
#endif //DOGLCD
#else //no ULTIPANEL
#ifdef ULTRA_LCD
#ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
#define LCD_WIDTH 20
#define LCD_HEIGHT 5
#else
#define LCD_WIDTH 16
#define LCD_HEIGHT 2
#endif
#endif
#endif
#ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
#define LCD_WIDTH 22
#define LCD_HEIGHT 5
#else //NO DOGLCD
#define LCD_WIDTH 16
#define LCD_HEIGHT 2
#endif //DOGLCD
#endif //ULTRA_LCD
#endif //ULTIPANEL
// default LCD contrast for dogm-like LCD displays
#ifdef DOGLCD
#ifndef DEFAULT_LCD_CONTRAST
#define DEFAULT_LCD_CONTRAST 32
#endif
#endif
#endif //DOGLCD
// option for invert rotary switch
//#define INVERT_ROTARY_SWITCH
......@@ -543,7 +541,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define LCD_RETRACT_FEEDRATE 10 // mm/s
#define LCD_LOAD_FEEDRATE 8 // mm/s
#define LCD_UNLOAD_FEEDRATE 8 // mm/s
#endif
#endif //EASY_LOAD
//============================== Preheat Constants ==========================
......@@ -648,7 +646,5 @@ your extruder heater takes 2 minutes to hit the target on heating.
//#define LASERBEAM
#include "Configuration_adv.h"
#endif //__CONFIGURATION_H
......@@ -5,483 +5,258 @@
#include "ultralcd.h"
#include "ConfigurationStore.h"
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size)
{
uint8_t c;
while(size--) {
while(size--)
{
eeprom_write_byte((unsigned char*)pos, *value);
c = eeprom_read_byte((unsigned char*)pos);
if (c != *value) {
if (c != *value)
{
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ERR_EEPROM_WRITE);
}
pos++;
value++;
};
}
}
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
do {
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
{
do
{
*value = eeprom_read_byte((unsigned char*)pos);
pos++;
value++;
} while (--size);
}
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
//======================================================================================
#define DUMMY_PID_VALUE 3000.0f
#define EEPROM_OFFSET 100
// IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
// in the functions below, also increment the version number. This makes sure that
// the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V11"
#define EEPROM_VERSION "V12"
#ifdef EEPROM_SETTINGS
void Config_StoreSettings() {
float dummy = 0.0f;
char ver[4] = "000";
int i = EEPROM_OFFSET;
EEPROM_WRITE_VAR(i, ver); // invalidate data first
EEPROM_WRITE_VAR(i, baudrate);
EEPROM_WRITE_VAR(i, axis_steps_per_unit);
EEPROM_WRITE_VAR(i, max_feedrate);
EEPROM_WRITE_VAR(i, max_retraction_feedrate);
EEPROM_WRITE_VAR(i, max_acceleration_units_per_sq_second);
EEPROM_WRITE_VAR(i, acceleration);
EEPROM_WRITE_VAR(i, retract_acceleration);
EEPROM_WRITE_VAR(i, minimumfeedrate);
EEPROM_WRITE_VAR(i, mintravelfeedrate);
EEPROM_WRITE_VAR(i, minsegmenttime);
EEPROM_WRITE_VAR(i, max_xy_jerk);
EEPROM_WRITE_VAR(i, max_z_jerk);
EEPROM_WRITE_VAR(i, max_e_jerk);
EEPROM_WRITE_VAR(i, add_homing);
#ifdef DELTA
EEPROM_WRITE_VAR(i, delta_radius);
EEPROM_WRITE_VAR(i, delta_diagonal_rod);
EEPROM_WRITE_VAR(i, max_pos);
EEPROM_WRITE_VAR(i, endstop_adj);
EEPROM_WRITE_VAR(i, tower_adj);
EEPROM_WRITE_VAR(i, z_probe_offset);
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
EEPROM_WRITE_VAR(i, zprobe_zoffset);
#endif
#ifndef ULTIPANEL
int plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP, plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP, plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
int absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP, absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP, absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
int gumPreheatHotendTemp = GUM_PREHEAT_HOTEND_TEMP, gumPreheatHPBTemp = GUM_PREHEAT_HPB_TEMP, gumPreheatFanSpeed = GUM_PREHEAT_FAN_SPEED;
#endif
EEPROM_WRITE_VAR(i, plaPreheatHotendTemp);
EEPROM_WRITE_VAR(i, plaPreheatHPBTemp);
EEPROM_WRITE_VAR(i, plaPreheatFanSpeed);
EEPROM_WRITE_VAR(i, absPreheatHotendTemp);
EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
EEPROM_WRITE_VAR(i, gumPreheatHotendTemp);
EEPROM_WRITE_VAR(i, gumPreheatHPBTemp);
EEPROM_WRITE_VAR(i, gumPreheatFanSpeed);
#ifdef PIDTEMP
EEPROM_WRITE_VAR(i,Kp);
EEPROM_WRITE_VAR(i,Ki);
EEPROM_WRITE_VAR(i,Kd);
#endif // PIDTEMP
#ifndef DOGLCD
int lcd_contrast = 32;
#endif
EEPROM_WRITE_VAR(i, lcd_contrast);
#ifdef SCARA
EEPROM_WRITE_VAR(i, axis_scaling); // Add scaling for SCARA
#endif //SCARA
#ifdef FWRETRACT
EEPROM_WRITE_VAR(i, autoretract_enabled);
EEPROM_WRITE_VAR(i, retract_length);
#if EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_length_swap);
#endif //EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_feedrate);
EEPROM_WRITE_VAR(i, retract_zlift);
EEPROM_WRITE_VAR(i, retract_recover_length);
#if EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_recover_length_swap);
#endif //EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_recover_feedrate);
#endif // FWRETRACT
// Save filament sizes
EEPROM_WRITE_VAR(i, volumetric_enabled);
// Save filament sizes
for (int e = 0; e < EXTRUDERS; e++) EEPROM_WRITE_VAR(i, filament_size[e]);
int storageSize = i;
char ver2[4] = EEPROM_VERSION;
int j = EEPROM_OFFSET;
EEPROM_WRITE_VAR(j, ver2); // validate data
// Report storage size
SERIAL_ECHO_START;
SERIAL_ECHOPAIR("Settings Stored (", (unsigned long)i);
SERIAL_ECHOLNPGM(" bytes)");
}
#endif //EEPROM_SETTINGS
#ifdef EEPROM_CHITCHAT
void Config_PrintSettings() { // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
SERIAL_ECHO_START;
SERIAL_ECHOPAIR("Baudrate: ", baudrate);
SERIAL_ECHOLN("");
SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]);
SERIAL_ECHOPAIR(" E0 S",axis_steps_per_unit[E_AXIS + 0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 S",axis_steps_per_unit[E_AXIS + 1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 S",axis_steps_per_unit[E_AXIS + 2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 S",axis_steps_per_unit[E_AXIS + 3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
#ifdef SCARA
SERIAL_ECHOLNPGM("Scaling factors:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M365 X",axis_scaling[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
#endif
SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M203 X ",max_feedrate[X_AXIS]);
SERIAL_ECHOPAIR(" Y ",max_feedrate[Y_AXIS] );
SERIAL_ECHOPAIR(" Z ", max_feedrate[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 ", max_feedrate[E_AXIS + 0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 ", max_feedrate[E_AXIS + 1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 ", max_feedrate[E_AXIS + 2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 ", max_feedrate[E_AXIS + 3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Retraction Steps per unit:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" E0 ",max_retraction_feedrate[0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 ",max_retraction_feedrate[1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 ",max_retraction_feedrate[2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 ",max_retraction_feedrate[3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M201 X " ,max_acceleration_units_per_sq_second[X_AXIS] );
SERIAL_ECHOPAIR(" Y " , max_acceleration_units_per_sq_second[Y_AXIS] );
SERIAL_ECHOPAIR(" Z " ,max_acceleration_units_per_sq_second[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 " ,max_acceleration_units_per_sq_second[E_AXIS]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 " ,max_acceleration_units_per_sq_second[E_AXIS+1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 " ,max_acceleration_units_per_sq_second[E_AXIS+2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 " ,max_acceleration_units_per_sq_second[E_AXIS+3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M204 S",acceleration );
SERIAL_ECHOPAIR(" T" ,retract_acceleration);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
SERIAL_ECHOPAIR(" E" ,max_e_jerk);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Home offset (mm):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M206 X",add_homing[X_AXIS] );
SERIAL_ECHOPAIR(" Y" ,add_homing[Y_AXIS] );
SERIAL_ECHOPAIR(" Z" ,add_homing[Z_AXIS] );
SERIAL_ECHOLN("");
#ifdef DELTA
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 X",endstop_adj[0]);
SERIAL_ECHOPAIR(" Y" ,endstop_adj[1]);
SERIAL_ECHOPAIR(" Z" ,endstop_adj[2]);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Delta Geometry adjustment:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 A",tower_adj[0]);
SERIAL_ECHOPAIR(" B" ,tower_adj[1]);
SERIAL_ECHOPAIR(" C" ,tower_adj[2]);
SERIAL_ECHOPAIR(" E" ,tower_adj[3]);
SERIAL_ECHOPAIR(" F" ,tower_adj[4]);
SERIAL_ECHOPAIR(" G" ,tower_adj[5]);
SERIAL_ECHOPAIR(" R" ,delta_radius);
SERIAL_ECHOPAIR(" D" ,delta_diagonal_rod);
SERIAL_ECHOPAIR(" H" ,max_pos[2]);
SERIAL_ECHOPAIR(" P" ,z_probe_offset[3]);
SERIAL_ECHOLN("");
SERIAL_ECHOLN("Tower Positions");
SERIAL_ECHOPAIR("Tower1 X:",delta_tower1_x);
SERIAL_ECHOPAIR(" Y:",delta_tower1_y);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Tower2 X:",delta_tower2_x);
SERIAL_ECHOPAIR(" Y:",delta_tower2_y);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Tower3 X:",delta_tower3_x);
SERIAL_ECHOPAIR(" Y:",delta_tower3_y);
SERIAL_ECHOLN("");
#endif // DELTA
#ifdef ENABLE_AUTO_BED_LEVELING
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Z Probe offset (mm)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 P",zprobe_zoffset);
SERIAL_ECHOLN("");
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef PIDTEMP
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("PID settings:");
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif
void Config_StoreSettings()
{
float dummy = 0.0f;
char ver[4] = "000";
int i = EEPROM_OFFSET;
EEPROM_WRITE_VAR(i, ver); // invalidate data first
EEPROM_WRITE_VAR(i, baudrate);
EEPROM_WRITE_VAR(i, axis_steps_per_unit);
EEPROM_WRITE_VAR(i, max_feedrate);
EEPROM_WRITE_VAR(i, max_retraction_feedrate);
EEPROM_WRITE_VAR(i, max_acceleration_units_per_sq_second);
EEPROM_WRITE_VAR(i, acceleration);
EEPROM_WRITE_VAR(i, retract_acceleration);
EEPROM_WRITE_VAR(i, minimumfeedrate);
EEPROM_WRITE_VAR(i, mintravelfeedrate);
EEPROM_WRITE_VAR(i, minsegmenttime);
EEPROM_WRITE_VAR(i, max_xy_jerk);
EEPROM_WRITE_VAR(i, max_z_jerk);
EEPROM_WRITE_VAR(i, max_e_jerk);
EEPROM_WRITE_VAR(i, add_homing);
EEPROM_WRITE_VAR(i, zprobe_zoffset);
#ifdef DELTA
EEPROM_WRITE_VAR(i, delta_radius);
EEPROM_WRITE_VAR(i, delta_diagonal_rod);
EEPROM_WRITE_VAR(i, max_pos);
EEPROM_WRITE_VAR(i, endstop_adj);
EEPROM_WRITE_VAR(i, tower_adj);
EEPROM_WRITE_VAR(i, z_probe_offset);
#endif
#ifndef ULTIPANEL
int plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP, plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP, plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
int absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP, absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP, absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
int gumPreheatHotendTemp = GUM_PREHEAT_HOTEND_TEMP, gumPreheatHPBTemp = GUM_PREHEAT_HPB_TEMP, gumPreheatFanSpeed = GUM_PREHEAT_FAN_SPEED;
#endif
EEPROM_WRITE_VAR(i, plaPreheatHotendTemp);
EEPROM_WRITE_VAR(i, plaPreheatHPBTemp);
EEPROM_WRITE_VAR(i, plaPreheatFanSpeed);
EEPROM_WRITE_VAR(i, absPreheatHotendTemp);
EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
EEPROM_WRITE_VAR(i, gumPreheatHotendTemp);
EEPROM_WRITE_VAR(i, gumPreheatHPBTemp);
EEPROM_WRITE_VAR(i, gumPreheatFanSpeed);
#ifdef PIDTEMP
EEPROM_WRITE_VAR(i, Kp);
EEPROM_WRITE_VAR(i, Ki);
EEPROM_WRITE_VAR(i, Kd);
#endif //PIDTEMP
#ifndef DOGLCD
int lcd_contrast = 32;
#endif
EEPROM_WRITE_VAR(i, lcd_contrast);
#ifdef SCARA
EEPROM_WRITE_VAR(i, axis_scaling); // Add scaling for SCARA
#endif //SCARA
#ifdef FWRETRACT
EEPROM_WRITE_VAR(i, autoretract_enabled);
EEPROM_WRITE_VAR(i, retract_length);
#if EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_length_swap);
#endif //EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_feedrate);
EEPROM_WRITE_VAR(i, retract_zlift);
EEPROM_WRITE_VAR(i, retract_recover_length);
#if EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_recover_length_swap);
#endif //EXTRUDERS > 1
EEPROM_WRITE_VAR(i, retract_recover_feedrate);
#endif // FWRETRACT
EEPROM_WRITE_VAR(i, volumetric_enabled);
// Save filament sizes
for (int e = 0; e < EXTRUDERS; e++) EEPROM_WRITE_VAR(i, filament_size[e]);
int storageSize = i;
char ver2[4] = EEPROM_VERSION;
int j = EEPROM_OFFSET;
EEPROM_WRITE_VAR(j, ver2); // validate data
// Report storage size
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M301 E", (long unsigned int)e);
SERIAL_ECHOPAIR(" P", Kp[e]);
SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki[e]));
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[e]));
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Settings Stored (", (unsigned long)i);
SERIAL_ECHOLNPGM(" bytes)");
}
#endif // PIDTEMP
#ifdef FWRETRACT
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M207 S",retract_length);
SERIAL_ECHOPAIR(" F" ,retract_feedrate*60);
SERIAL_ECHOPAIR(" Z" ,retract_zlift);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M208 S",retract_recover_length);
SERIAL_ECHOPAIR(" F" ,retract_recover_feedrate*60);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
SERIAL_ECHOLN("");
#if EXTRUDERS > 1
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Multi-extruder settings:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" Swap retract length (mm): ", retract_length_swap);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" Swap rec. addl. length (mm): ", retract_recover_length_swap);
SERIAL_ECHOLN("");
#endif //EXTRUDERS > 1
SERIAL_ECHO_START;
if (volumetric_enabled) {
SERIAL_ECHOLNPGM("Filament settings:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
SERIAL_ECHOLN("");
#if EXTRUDERS > 1
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
SERIAL_ECHOLN("");
#if EXTRUDERS > 2
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
SERIAL_ECHOLN("");
#if EXTRUDERS > 3
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
SERIAL_ECHOLN("");
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
} else {
SERIAL_ECHOLNPGM("Filament settings: Disabled");
}
#endif //FWRETRACT
}
#endif //EEPROM_CHITCHAT
#ifdef EEPROM_SETTINGS
void Config_RetrieveSettings()
{
int i=EEPROM_OFFSET;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_READ_VAR(i,stored_ver); //read stored version
//SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
if (strncmp(ver,stored_ver,3) == 0)
void Config_RetrieveSettings()
{
// version number match
EEPROM_READ_VAR(i,baudrate);
if(baudrate!=9600 && baudrate!=14400 && baudrate!=19200 && baudrate!=28800 && baudrate!=38400 && baudrate!=56000 && baudrate!=115200 && baudrate!=250000) baudrate=BAUDRATE;
EEPROM_READ_VAR(i,axis_steps_per_unit);
EEPROM_READ_VAR(i,max_feedrate);
EEPROM_READ_VAR(i,max_retraction_feedrate);
EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second);
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
reset_acceleration_rates();
EEPROM_READ_VAR(i,acceleration);
EEPROM_READ_VAR(i,retract_acceleration);
EEPROM_READ_VAR(i,minimumfeedrate);
EEPROM_READ_VAR(i,mintravelfeedrate);
EEPROM_READ_VAR(i,minsegmenttime);
EEPROM_READ_VAR(i,max_xy_jerk);
EEPROM_READ_VAR(i,max_z_jerk);
EEPROM_READ_VAR(i,max_e_jerk);
EEPROM_READ_VAR(i,add_homing);
#ifdef DELTA
EEPROM_READ_VAR(i,delta_radius);
EEPROM_READ_VAR(i,delta_diagonal_rod);
EEPROM_READ_VAR(i,max_pos);
EEPROM_READ_VAR(i,endstop_adj);
EEPROM_READ_VAR(i,tower_adj);
EEPROM_READ_VAR(i,z_probe_offset);
// Update delta constants for updated delta_radius & tower_adj values
set_delta_constants();
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
EEPROM_READ_VAR(i,zprobe_zoffset);
#endif
#ifndef ULTIPANEL
int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed;
int absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed;
int gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed;
#endif
EEPROM_READ_VAR(i,plaPreheatHotendTemp);
EEPROM_READ_VAR(i,plaPreheatHPBTemp);
EEPROM_READ_VAR(i,plaPreheatFanSpeed);
EEPROM_READ_VAR(i,absPreheatHotendTemp);
EEPROM_READ_VAR(i,absPreheatHPBTemp);
EEPROM_READ_VAR(i,absPreheatFanSpeed);
EEPROM_READ_VAR(i,gumPreheatHotendTemp);
EEPROM_READ_VAR(i,gumPreheatHPBTemp);
EEPROM_READ_VAR(i,gumPreheatFanSpeed);
#ifdef PIDTEMP
// do not need to scale PID values as the values in EEPROM are already scaled
EEPROM_READ_VAR(i,Kp);
EEPROM_READ_VAR(i,Ki);
EEPROM_READ_VAR(i,Kd);
#endif // PIDTEMP
#ifndef DOGLCD
int lcd_contrast;
#endif
EEPROM_READ_VAR(i,lcd_contrast);
#ifdef SCARA
EEPROM_READ_VAR(i,axis_scaling);
#endif //SCARA
#ifdef FWRETRACT
EEPROM_READ_VAR(i,autoretract_enabled);
EEPROM_READ_VAR(i,retract_length);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_length_swap);
#endif //EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_feedrate);
EEPROM_READ_VAR(i,retract_zlift);
EEPROM_READ_VAR(i,retract_recover_length);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_length_swap);
#endif //EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_feedrate);
#endif
EEPROM_READ_VAR(i, volumetric_enabled);
EEPROM_READ_VAR(i, filament_size[0]);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i, filament_size[1]);
#if EXTRUDERS > 2
EEPROM_READ_VAR(i, filament_size[2]);
#if EXTRUDERS > 3
EEPROM_READ_VAR(i, filament_size[3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
calculate_volumetric_multipliers();
// Call updatePID (similar to when we have processed M301)
updatePID();
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retrieved");
}
else
{
Config_ResetDefault();
int i=EEPROM_OFFSET;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_READ_VAR(i,stored_ver); //read stored version
//SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
if (strncmp(ver,stored_ver,3) == 0)
{
// version number match
EEPROM_READ_VAR(i,baudrate);
if(baudrate!=9600 && baudrate!=14400 && baudrate!=19200 && baudrate!=28800 && baudrate!=38400 && baudrate!=56000 && baudrate!=115200 && baudrate!=250000) baudrate=BAUDRATE;
EEPROM_READ_VAR(i,axis_steps_per_unit);
EEPROM_READ_VAR(i,max_feedrate);
EEPROM_READ_VAR(i,max_retraction_feedrate);
EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second);
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
reset_acceleration_rates();
EEPROM_READ_VAR(i,acceleration);
EEPROM_READ_VAR(i,retract_acceleration);
EEPROM_READ_VAR(i,minimumfeedrate);
EEPROM_READ_VAR(i,mintravelfeedrate);
EEPROM_READ_VAR(i,minsegmenttime);
EEPROM_READ_VAR(i,max_xy_jerk);
EEPROM_READ_VAR(i,max_z_jerk);
EEPROM_READ_VAR(i,max_e_jerk);
EEPROM_READ_VAR(i,add_homing);
EEPROM_READ_VAR(i,zprobe_zoffset);
#ifdef DELTA
EEPROM_READ_VAR(i,delta_radius);
EEPROM_READ_VAR(i,delta_diagonal_rod);
EEPROM_READ_VAR(i,max_pos);
EEPROM_READ_VAR(i,endstop_adj);
EEPROM_READ_VAR(i,tower_adj);
EEPROM_READ_VAR(i,z_probe_offset);
// Update delta constants for updated delta_radius & tower_adj values
set_delta_constants();
#endif //DELTA
#ifndef ULTIPANEL
int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed;
int absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed;
int gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed;
#endif
EEPROM_READ_VAR(i,plaPreheatHotendTemp);
EEPROM_READ_VAR(i,plaPreheatHPBTemp);
EEPROM_READ_VAR(i,plaPreheatFanSpeed);
EEPROM_READ_VAR(i,absPreheatHotendTemp);
EEPROM_READ_VAR(i,absPreheatHPBTemp);
EEPROM_READ_VAR(i,absPreheatFanSpeed);
EEPROM_READ_VAR(i,gumPreheatHotendTemp);
EEPROM_READ_VAR(i,gumPreheatHPBTemp);
EEPROM_READ_VAR(i,gumPreheatFanSpeed);
#ifdef PIDTEMP
// do not need to scale PID values as the values in EEPROM are already scaled
EEPROM_READ_VAR(i,Kp);
EEPROM_READ_VAR(i,Ki);
EEPROM_READ_VAR(i,Kd);
#endif // PIDTEMP
#ifndef DOGLCD
int lcd_contrast;
#endif //DOGLCD
EEPROM_READ_VAR(i,lcd_contrast);
#ifdef SCARA
EEPROM_READ_VAR(i,axis_scaling);
#endif //SCARA
#ifdef FWRETRACT
EEPROM_READ_VAR(i,autoretract_enabled);
EEPROM_READ_VAR(i,retract_length);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_length_swap);
#endif //EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_feedrate);
EEPROM_READ_VAR(i,retract_zlift);
EEPROM_READ_VAR(i,retract_recover_length);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_length_swap);
#endif //EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_feedrate);
#endif //FWRETRACT
EEPROM_READ_VAR(i, volumetric_enabled);
EEPROM_READ_VAR(i, filament_size[0]);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i, filament_size[1]);
#if EXTRUDERS > 2
EEPROM_READ_VAR(i, filament_size[2]);
#if EXTRUDERS > 3
EEPROM_READ_VAR(i, filament_size[3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
calculate_volumetric_multipliers();
// Call updatePID (similar to when we have processed M301)
updatePID();
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retrieved");
}
else
{
Config_ResetDefault();
}
#ifdef EEPROM_CHITCHAT
Config_PrintSettings();
#endif //EEPROM_CHITCHAT
}
#ifdef EEPROM_CHITCHAT
Config_PrintSettings();
#endif
}
#endif
#endif //EEPROM_SETTINGS
void Config_ResetDefault()
{
......@@ -492,12 +267,12 @@ void Config_ResetDefault()
const static float tmp2[] = DEFAULT_MAX_FEEDRATE;
const static float tmp3[] = DEFAULT_RETRACTION_MAX_FEEDRATE;
const static long tmp4[] = DEFAULT_MAX_ACCELERATION;
#ifdef PIDTEMP
const static float tmp5[] = DEFAULT_Kp;
const static float tmp6[] = DEFAULT_Ki;
const static float tmp7[] = DEFAULT_Kd;
#endif // PIDTEMP
#ifdef PIDTEMP
const static float tmp5[] = DEFAULT_Kp;
const static float tmp6[] = DEFAULT_Ki;
const static float tmp7[] = DEFAULT_Kd;
#endif // PIDTEMP
for (short i=0;i<3+EXTRUDERS;i++)
{
axis_steps_per_unit[i] = tmp1[i];
......@@ -508,9 +283,9 @@ void Config_ResetDefault()
for (short i=0;i<EXTRUDERS;i++)
{
max_retraction_feedrate[i] = tmp3[i];
#ifdef SCARA
axis_scaling[i]=1;
#endif
#ifdef SCARA
axis_scaling[i] = 1;
#endif //SCARA
}
// steps per sq second need to be updated to agree with the units per sq second
......@@ -525,75 +300,308 @@ void Config_ResetDefault()
max_z_jerk=DEFAULT_ZJERK;
max_e_jerk=DEFAULT_EJERK;
add_homing[0] = add_homing[1] = add_homing[2] = 0;
#ifdef DELTA
delta_radius = DEFAULT_DELTA_RADIUS;
delta_diagonal_rod = DEFAULT_DELTA_DIAGONAL_ROD;
endstop_adj[0] = endstop_adj[1] = endstop_adj[2] = 0;
tower_adj[0] = tower_adj[1] = tower_adj[2] = tower_adj[3] = tower_adj[4] = tower_adj[5] = 0;
max_pos[2] = MANUAL_Z_HOME_POS;
set_default_z_probe_offset();
set_delta_constants();
#endif
#ifdef ULTIPANEL
plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
gumPreheatHotendTemp = GUM_PREHEAT_HOTEND_TEMP;
gumPreheatHPBTemp = GUM_PREHEAT_HPB_TEMP;
gumPreheatFanSpeed = GUM_PREHEAT_FAN_SPEED;
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif
#ifdef DOGLCD
lcd_contrast = DEFAULT_LCD_CONTRAST;
#endif
#ifdef PIDTEMP
#ifndef SINGLENOZZLE
for (short e=0;e<EXTRUDERS;e++)
#else
int e = 0; // only need to write once
#endif
{
Kp[e] = tmp5[e];
Ki[e] = scalePID_i(tmp6[e]);
Kd[e] = scalePID_d(tmp7[e]);
}
// call updatePID (similar to when we have processed M301)
updatePID();
#endif//PIDTEMP
#ifdef FWRETRACT
autoretract_enabled = false;
retract_length = RETRACT_LENGTH;
#if EXTRUDERS > 1
retract_length_swap = RETRACT_LENGTH_SWAP;
#endif //EXTRUDERS > 1
retract_feedrate = RETRACT_FEEDRATE;
retract_zlift = RETRACT_ZLIFT;
retract_recover_length = RETRACT_RECOVER_LENGTH;
#if EXTRUDERS > 1
retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
#endif //EXTRUDERS > 1
retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
#endif //FWRETRACT
#ifdef ENABLE_AUTO_BED_LEVELING
zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
#else
zprobe_zoffset = 0;
#endif //ENABLE_AUTO_BED_LEVELING
#ifdef DELTA
delta_radius = DEFAULT_DELTA_RADIUS;
delta_diagonal_rod = DEFAULT_DELTA_DIAGONAL_ROD;
endstop_adj[0] = endstop_adj[1] = endstop_adj[2] = 0;
tower_adj[0] = tower_adj[1] = tower_adj[2] = tower_adj[3] = tower_adj[4] = tower_adj[5] = 0;
max_pos[2] = MANUAL_Z_HOME_POS;
set_default_z_probe_offset();
set_delta_constants();
#endif //DELTA
#ifdef ULTIPANEL
plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
gumPreheatHotendTemp = GUM_PREHEAT_HOTEND_TEMP;
gumPreheatHPBTemp = GUM_PREHEAT_HPB_TEMP;
gumPreheatFanSpeed = GUM_PREHEAT_FAN_SPEED;
#endif
#ifdef DOGLCD
lcd_contrast = DEFAULT_LCD_CONTRAST;
#endif //DOGLCD
#ifdef PIDTEMP
#ifndef SINGLENOZZLE
for (short e=0;e<EXTRUDERS;e++)
#else
int e = 0; // only need to write once
#endif //SINGLENOZZLE
{
Kp[e] = tmp5[e];
Ki[e] = scalePID_i(tmp6[e]);
Kd[e] = scalePID_d(tmp7[e]);
}
// call updatePID (similar to when we have processed M301)
updatePID();
#endif//PIDTEMP
#ifdef FWRETRACT
autoretract_enabled = false;
retract_length = RETRACT_LENGTH;
#if EXTRUDERS > 1
retract_length_swap = RETRACT_LENGTH_SWAP;
#endif //EXTRUDERS > 1
retract_feedrate = RETRACT_FEEDRATE;
retract_zlift = RETRACT_ZLIFT;
retract_recover_length = RETRACT_RECOVER_LENGTH;
#if EXTRUDERS > 1
retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
#endif //EXTRUDERS > 1
retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
#endif //FWRETRACT
volumetric_enabled = false;
filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 1
filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 2
filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 3
filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA;
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
#if EXTRUDERS > 1
filament_size[1] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 2
filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 3
filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA;
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
calculate_volumetric_multipliers();
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
}
#ifdef EEPROM_CHITCHAT
void Config_PrintSettings()
{ // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
SERIAL_ECHO_START;
SERIAL_ECHOPAIR("Baudrate: ", baudrate);
SERIAL_ECHOLN("");
SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]);
SERIAL_ECHOPAIR(" E0 S",axis_steps_per_unit[E_AXIS + 0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 S",axis_steps_per_unit[E_AXIS + 1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 S",axis_steps_per_unit[E_AXIS + 2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 S",axis_steps_per_unit[E_AXIS + 3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
#ifdef SCARA
SERIAL_ECHOLNPGM("Scaling factors:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M365 X",axis_scaling[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
#endif
SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M203 X ",max_feedrate[X_AXIS]);
SERIAL_ECHOPAIR(" Y ",max_feedrate[Y_AXIS] );
SERIAL_ECHOPAIR(" Z ", max_feedrate[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 ", max_feedrate[E_AXIS + 0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 ", max_feedrate[E_AXIS + 1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 ", max_feedrate[E_AXIS + 2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 ", max_feedrate[E_AXIS + 3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Retraction Steps per unit:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" E0 ",max_retraction_feedrate[0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 ",max_retraction_feedrate[1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 ",max_retraction_feedrate[2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 ",max_retraction_feedrate[3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M201 X " ,max_acceleration_units_per_sq_second[X_AXIS] );
SERIAL_ECHOPAIR(" Y " , max_acceleration_units_per_sq_second[Y_AXIS] );
SERIAL_ECHOPAIR(" Z " ,max_acceleration_units_per_sq_second[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 " ,max_acceleration_units_per_sq_second[E_AXIS]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 " ,max_acceleration_units_per_sq_second[E_AXIS+1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 " ,max_acceleration_units_per_sq_second[E_AXIS+2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 " ,max_acceleration_units_per_sq_second[E_AXIS+3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M204 S",acceleration );
SERIAL_ECHOPAIR(" T" ,retract_acceleration);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
SERIAL_ECHOPAIR(" E" ,max_e_jerk);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Home offset (mm):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M206 X",add_homing[X_AXIS] );
SERIAL_ECHOPAIR(" Y" ,add_homing[Y_AXIS] );
SERIAL_ECHOPAIR(" Z" ,add_homing[Z_AXIS] );
SERIAL_ECHOLN("");
#ifdef DELTA
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 X",endstop_adj[0]);
SERIAL_ECHOPAIR(" Y" ,endstop_adj[1]);
SERIAL_ECHOPAIR(" Z" ,endstop_adj[2]);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Delta Geometry adjustment:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 A",tower_adj[0]);
SERIAL_ECHOPAIR(" B" ,tower_adj[1]);
SERIAL_ECHOPAIR(" C" ,tower_adj[2]);
SERIAL_ECHOPAIR(" E" ,tower_adj[3]);
SERIAL_ECHOPAIR(" F" ,tower_adj[4]);
SERIAL_ECHOPAIR(" G" ,tower_adj[5]);
SERIAL_ECHOPAIR(" R" ,delta_radius);
SERIAL_ECHOPAIR(" D" ,delta_diagonal_rod);
SERIAL_ECHOPAIR(" H" ,max_pos[2]);
SERIAL_ECHOPAIR(" P" ,z_probe_offset[3]);
SERIAL_ECHOLN("");
SERIAL_ECHOLN("Tower Positions");
SERIAL_ECHOPAIR("Tower1 X:",delta_tower1_x);
SERIAL_ECHOPAIR(" Y:",delta_tower1_y);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Tower2 X:",delta_tower2_x);
SERIAL_ECHOPAIR(" Y:",delta_tower2_y);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Tower3 X:",delta_tower3_x);
SERIAL_ECHOPAIR(" Y:",delta_tower3_y);
SERIAL_ECHOLN("");
#endif // DELTA
#ifdef ENABLE_AUTO_BED_LEVELING
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Z Probe offset (mm)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 P",zprobe_zoffset);
SERIAL_ECHOLN("");
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef PIDTEMP
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("PID settings:");
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif
{
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M301 E", (long unsigned int)e);
SERIAL_ECHOPAIR(" P", Kp[e]);
SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki[e]));
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[e]));
SERIAL_ECHOLN("");
}
#endif // PIDTEMP
#ifdef FWRETRACT
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M207 S",retract_length);
SERIAL_ECHOPAIR(" F" ,retract_feedrate*60);
SERIAL_ECHOPAIR(" Z" ,retract_zlift);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M208 S",retract_recover_length);
SERIAL_ECHOPAIR(" F" ,retract_recover_feedrate*60);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M209 S", (unsigned long)(autoretract_enabled ? 1 : 0));
SERIAL_ECHOLN("");
#if EXTRUDERS > 1
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Multi-extruder settings:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" Swap retract length (mm): ", retract_length_swap);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" Swap rec. addl. length (mm): ", retract_recover_length_swap);
SERIAL_ECHOLN("");
#endif //EXTRUDERS > 1
SERIAL_ECHO_START;
if (volumetric_enabled)
{
SERIAL_ECHOLNPGM("Filament settings:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 D", filament_size[0]);
SERIAL_ECHOLN("");
#if EXTRUDERS > 1
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 T1 D", filament_size[1]);
SERIAL_ECHOLN("");
#if EXTRUDERS > 2
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 T2 D", filament_size[2]);
SERIAL_ECHOLN("");
#if EXTRUDERS > 3
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M200 T3 D", filament_size[3]);
SERIAL_ECHOLN("");
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
} else
{
SERIAL_ECHOLNPGM("Filament settings: Disabled");
}
#endif //FWRETRACT
}
#endif //EEPROM_CHITCHAT
......@@ -174,11 +174,11 @@
// M351 - Toggle MS1 MS2 pins directly.
// ************ SCARA Specific - This can change to suit future G-code regulations
// M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration)
// M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree)
// M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration)
// M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree)
// M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position)
// M360 - SCARA calibration: Move to calc-position ThetaA (0 deg calibration)
// M361 - SCARA calibration: Move to calc-position ThetaB (90 deg calibration - steps per degree)
// M362 - SCARA calibration: Move to calc-position PsiA (0 deg calibration)
// M363 - SCARA calibration: Move to calc-position PsiB (90 deg calibration - steps per degree)
// M364 - SCARA calibration: Move to calc-position PSIC (90 deg to Theta calibration position)
// M365 - SCARA calibration: Scaling factor, X, Y, Z axis
//************* SCARA End ***************
......@@ -193,19 +193,7 @@
unsigned long baudrate;
float homing_feedrate[] = HOMING_FEEDRATE;
bool axis_known_position[3] = {false, false, false};
#ifdef DELTA
float probing_feedrate = PROBING_FEEDRATE;
float default_z_probe_offset[] = Z_PROBE_OFFSET;
float z_probe_offset[3];
float z_probe_deploy_start_location[] = Z_PROBE_DEPLOY_START_LOCATION;
float z_probe_deploy_end_location[] = Z_PROBE_DEPLOY_END_LOCATION;
float z_probe_retract_start_location[] = Z_PROBE_RETRACT_START_LOCATION;
float z_probe_retract_end_location[] = Z_PROBE_RETRACT_END_LOCATION;
#else // No Delta
float zprobe_zoffset;
#endif // No Delta
float zprobe_zoffset;
bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
int feedmultiply = 100; //100->1 200->2
int saved_feedmultiply;
......@@ -278,6 +266,13 @@ float add_homing[3]={ 0, 0, 0 };
};
float delta[3] = { 0.0, 0.0, 0.0 };
float delta_tmp[3] = { 0.0, 0.0, 0.0 };
float probing_feedrate = PROBING_FEEDRATE;
float default_z_probe_offset[] = Z_PROBE_OFFSET;
float z_probe_offset[3];
float z_probe_deploy_start_location[] = Z_PROBE_DEPLOY_START_LOCATION;
float z_probe_deploy_end_location[] = Z_PROBE_DEPLOY_END_LOCATION;
float z_probe_retract_start_location[] = Z_PROBE_RETRACT_START_LOCATION;
float z_probe_retract_end_location[] = Z_PROBE_RETRACT_END_LOCATION;
#endif // DELTA
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
......@@ -922,7 +917,6 @@ void get_command()
#endif //SDSUPPORT
}
float code_value()
{
return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL));
......@@ -2299,7 +2293,6 @@ void gcode_G28()
endstops_hit_on_purpose();
}
#ifdef ENABLE_AUTO_BED_LEVELING
// G29: Detailed Z-Probe, probes the bed at 3 or more points.
// Will fail if the printer has not been homed with G28.
......@@ -2493,7 +2486,6 @@ void gcode_G28()
#endif //Z_PROBE_SLED
#endif //ENABLE_AUTO_BED_LEVELING
#ifdef DELTA
// G29: Delta Z-Probe, probes the bed at more points.
void gcode_G29()
......@@ -3102,6 +3094,463 @@ void gcode_G92()
}
}
#ifdef ULTIPANEL
// M0: Unconditional stop - Wait for user button press on LCD
// M1: Conditional stop - Wait for user button press on LCD
void gcode_M0_M1()
{
unsigned long codenum; //throw away variable
char *starpos = NULL;
char *src = strchr_pointer + 2;
codenum = 0;
bool hasP = false, hasS = false;
if (code_seen('P'))
{
codenum = code_value(); // milliseconds to wait
hasP = codenum > 0;
}
if (code_seen('S'))
{
codenum = code_value() * 1000; // seconds to wait
hasS = codenum > 0;
}
starpos = strchr(src, '*');
if (starpos != NULL) *(starpos) = '\0';
while (*src == ' ') ++src;
if (!hasP && !hasS && *src != '\0')
{
lcd_setstatus(src);
}
else
{
LCD_MESSAGEPGM(MSG_USERWAIT);
}
lcd_ignore_click();
st_synchronize();
refresh_cmd_timeout();
if (codenum > 0)
{
codenum += millis(); // keep track of when we started waiting
while(millis() < codenum && !lcd_clicked())
{
manage_heater();
manage_inactivity();
lcd_update();
}
lcd_ignore_click(false);
}
else
{
while(!lcd_clicked())
{
manage_heater();
manage_inactivity();
lcd_update();
}
}
if (IS_SD_PRINTING)
LCD_MESSAGEPGM(MSG_RESUMING);
else
LCD_MESSAGEPGM(WELCOME_MSG);
}
#endif //ULTIPANEL
#ifdef LASERBEAM
// M3: S - Setting laser beam
void gcode_M3()
{
if(code_seen('S'))
{
laser_ttl_modulation = constrain(code_value(),0,255);
}
else
{
laser_ttl_modulation=0;
}
}
// M4: Turn on laser beam
void gcode_M4()
{
WRITE(LASER_PWR_PIN, HIGH);
laser_ttl_modulation = 0;
}
// M5: Turn off laser beam
void gcode_M5()
{
WRITE(LASER_PWR_PIN, LOW);
laser_ttl_modulation=0;
}
#endif //LASERBEAM
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
//M49: Z-Probe repeatability
void gcode_M49()
{
#if Z_MIN_PIN == -1
#error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability."
#endif
double sum = 0.0, mean = 0.0, sigma = 0.0;
double sample_set[50];
int verbose_level = 1, n = 0, j, n_samples = 10, n_legs = 0, engage_probe_for_each_reading = 0;
double X_current, Y_current, Z_current;
double X_probe_location, Y_probe_location, Z_start_location, ext_position;
if (code_seen('V') || code_seen('v'))
{
verbose_level = code_value();
if (verbose_level<0 || verbose_level>4 )
{
SERIAL_PROTOCOLPGM("?Verbose Level not plausible.\n");
return;
}
}
if (verbose_level > 0)
{
SERIAL_PROTOCOLPGM("M49 Z-Probe Repeatability test. Version 2.00\n");
SERIAL_PROTOCOLPGM("Full support at: http://3dprintboard.com/forum.php\n");
}
if (code_seen('n'))
{
n_samples = code_value();
if (n_samples<4 || n_samples>50 )
{
SERIAL_PROTOCOLPGM("?Specified sample size not plausable.\n");
return;
}
}
X_current = X_probe_location = st_get_position_mm(X_AXIS);
Y_current = Y_probe_location = st_get_position_mm(Y_AXIS);
Z_current = st_get_position_mm(Z_AXIS);
Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING;
ext_position = st_get_position_mm(E_AXIS);
if (code_seen('E') || code_seen('e')) engage_probe_for_each_reading++;
if (code_seen('X') || code_seen('x'))
{
X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
if (X_probe_location<X_MIN_POS || X_probe_location>X_MAX_POS)
{
SERIAL_PROTOCOLPGM("?Specified X position out of range.\n");
return;
}
}
if (code_seen('Y') || code_seen('y'))
{
Y_probe_location = code_value() - Y_PROBE_OFFSET_FROM_EXTRUDER;
if (Y_probe_location<Y_MIN_POS || Y_probe_location>Y_MAX_POS)
{
SERIAL_PROTOCOLPGM("?Specified Y position out of range.\n");
return;
}
}
if (code_seen('L') || code_seen('l'))
{
n_legs = code_value();
if (n_legs == 1) n_legs = 2;
if (n_legs<0 || n_legs>15)
{
SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausible.\n");
return;
}
}
//
// Do all the preliminary setup work. First raise the probe.
//
st_synchronize();
plan_bed_level_matrix.set_to_identity();
plan_buffer_line( X_current, Y_current, Z_start_location,
ext_position,
homing_feedrate[Z_AXIS]/60,
active_extruder, active_driver);
st_synchronize();
//
// Now get everything to the specified probe point So we can safely do a probe to
// get us close to the bed. If the Z-Axis is far from the bed, we don't want to
// use that as a starting point for each probe.
//
if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n");
plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, ext_position, homing_feedrate[X_AXIS]/60, active_extruder, active_driver);
st_synchronize();
current_position[X_AXIS] = X_current = st_get_position_mm(X_AXIS);
current_position[Y_AXIS] = Y_current = st_get_position_mm(Y_AXIS);
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS);
//
// OK, do the initial probe to get us close to the bed.
// Then retrace the right amount and use that in subsequent probes
//
engage_z_probe();
setup_for_endstop_move();
run_z_probe();
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING;
plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, ext_position, homing_feedrate[X_AXIS]/60, active_extruder, active_driver);
st_synchronize();
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
if (engage_probe_for_each_reading) retract_z_probe();
for (n=0; n<n_samples; n++)
{
do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
if (n_legs)
{
double radius=0.0, theta=0.0, x_sweep, y_sweep;
int rotational_direction, l;
rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise
radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go
theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians
//SERIAL_ECHOPAIR("starting radius: ",radius);
//SERIAL_ECHOPAIR(" theta: ",theta);
//SERIAL_ECHOPAIR(" direction: ",rotational_direction);
//SERIAL_PROTOCOLLNPGM("");
for( l=0; l<n_legs-1; l++)
{
if (rotational_direction==1) theta += (float) ((unsigned long) millis() % (long) 20) / (360.0/(2*3.1415926)); // turn into radians
else theta -= (float) ((unsigned long) millis() % (long) 20) / (360.0/(2*3.1415926)); // turn into radians
radius += (float) ( ((long) ((unsigned long) millis() % (long) 10)) - 5);
if (radius < 0.0) radius = -radius;
X_current = X_probe_location + cos(theta) * radius;
Y_current = Y_probe_location + sin(theta) * radius;
if (X_current < X_MIN_POS) X_current = X_MIN_POS; // Make sure our X & Y are sane
if (X_current > X_MAX_POS) X_current = X_MAX_POS;
if (Y_current < Y_MIN_POS) Y_current = Y_MIN_POS; // Make sure our X & Y are sane
if (Y_current > Y_MAX_POS) Y_current = Y_MAX_POS;
if (verbose_level > 3)
{
SERIAL_ECHOPAIR("x: ", X_current);
SERIAL_ECHOPAIR("y: ", Y_current);
SERIAL_PROTOCOLLNPGM("");
}
do_blocking_move_to( X_current, Y_current, Z_current );
}
do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Go back to the probe location
}
if (engage_probe_for_each_reading)
{
engage_z_probe();
delay(1000);
}
setup_for_endstop_move();
run_z_probe();
sample_set[n] = current_position[Z_AXIS];
//
// Get the current mean for the data points we have so far
//
sum = 0.0;
for (j=0; j<=n; j++)
{
sum = sum + sample_set[j];
}
mean = sum / (double (n+1));
//
// Now, use that mean to calculate the standard deviation for the
// data points we have so far
//
sum = 0.0;
for (j=0; j<=n; j++)
{
sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean);
}
sigma = sqrt( sum / (double (n+1)));
if (verbose_level > 1)
{
SERIAL_PROTOCOL(n+1);
SERIAL_PROTOCOL(" of ");
SERIAL_PROTOCOL(n_samples);
SERIAL_PROTOCOLPGM(" z: ");
SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6);
}
if (verbose_level > 2)
{
SERIAL_PROTOCOL(" mean: ");
SERIAL_PROTOCOL_F(mean,6);
SERIAL_PROTOCOL(" sigma: ");
SERIAL_PROTOCOL_F(sigma,6);
}
if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n");
plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder, active_driver);
st_synchronize();
if (engage_probe_for_each_reading)
{
retract_z_probe();
delay(1000);
}
}
retract_z_probe();
delay(1000);
clean_up_after_endstop_move();
if (verbose_level > 0)
{
SERIAL_PROTOCOLPGM("Mean: ");
SERIAL_PROTOCOL_F(mean, 6);
SERIAL_PROTOCOLPGM("\n");
}
SERIAL_PROTOCOLPGM("Standard Deviation: ");
SERIAL_PROTOCOL_F(sigma, 6);
SERIAL_PROTOCOLPGM("\n\n");
}
#endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
#ifdef ENABLE_AUTO_BED_LEVELING
void gcode_M666()
{
if (code_seen('P'))
{
zprobe_zoffset = code_value();
}
if (code_seen('L'))
{
SERIAL_ECHOPAIR("P (Z-Probe Offset):", zprobe_zoffset);
SERIAL_ECHOLN("");
}
}
#elif defined(DELTA)
void gcode_M666()
{
if ( !(code_seen('P')))
{
for(int8_t i=0; i < 3; i++)
{
if (code_seen(axis_codes[i])) endstop_adj[i] = code_value();
}
}
if (code_seen('A'))
{
tower_adj[0] = code_value();
set_delta_constants();
}
if (code_seen('B'))
{
tower_adj[1] = code_value();
set_delta_constants();
}
if (code_seen('C'))
{
tower_adj[2] = code_value();
set_delta_constants();
}
if (code_seen('I'))
{
tower_adj[3] = code_value();
set_delta_constants();
}
if (code_seen('J'))
{
tower_adj[4] = code_value();
set_delta_constants();
}
if (code_seen('K'))
{
tower_adj[5] = code_value();
set_delta_constants();
}
if (code_seen('R'))
{
delta_radius = code_value();
set_delta_constants();
}
if (code_seen('D'))
{
delta_diagonal_rod = code_value();
set_delta_constants();
}
if (code_seen('H'))
{
max_pos[Z_AXIS]= code_value();
set_delta_constants();
}
if (code_seen('P'))
{
float pz = code_value();
if (!(code_seen(axis_codes[0]) || code_seen(axis_codes[1]) || code_seen(axis_codes[2]))) // Allow direct set of Z offset without an axis code
{
z_probe_offset[Z_AXIS]= pz;
}
else
{
for(int8_t i=0; i < 3; i++)
{
if (code_seen(axis_codes[i])) z_probe_offset[i] = code_value();
}
}
}
if (code_seen('L'))
{
SERIAL_ECHOLN("Current Delta geometry values:");
SERIAL_ECHOPAIR("X (Endstop Adj): ",endstop_adj[0]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Y (Endstop Adj): ",endstop_adj[1]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Z (Endstop Adj): ",endstop_adj[2]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("P (Z-Probe Offset): X", z_probe_offset[0]);
SERIAL_ECHOPAIR(" Y", z_probe_offset[1]);
SERIAL_ECHOPAIR(" Z", z_probe_offset[2]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("A (Tower A Position Correction): ",tower_adj[0]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("B (Tower B Position Correction): ",tower_adj[1]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("C (Tower C Position Correction): ",tower_adj[2]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("I (Tower A Radius Correction): ",tower_adj[3]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("J (Tower B Radius Correction): ",tower_adj[4]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("K (Tower C Radius Correction): ",tower_adj[5]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("R (Delta Radius): ",delta_radius);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("D (Diagonal Rod Length): ",delta_diagonal_rod);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("H (Z-Height): ",max_pos[Z_AXIS]);
SERIAL_ECHOLN("");
}
}
#endif
// Process Commands and dispatch them to handlers
void process_commands()
......@@ -3126,12 +3575,12 @@ void process_commands()
{
gcode_G2_G3(true);
}
break;
break;
case 3: //G3 - CCW ARC
{
gcode_G2_G3(false);
}
break;
break;
#endif
//G4 Dwell
......@@ -3234,90 +3683,30 @@ void process_commands()
case 0: //M0 - Unconditional stop - Wait for user button press on LCD
case 1: //M1 - Conditional stop - Wait for user button press on LCD
{
char *src = strchr_pointer + 2;
codenum = 0;
bool hasP = false, hasS = false;
if (code_seen('P'))
{
codenum = code_value(); // milliseconds to wait
hasP = codenum > 0;
}
if (code_seen('S'))
{
codenum = code_value() * 1000; // seconds to wait
hasS = codenum > 0;
}
starpos = strchr(src, '*');
if (starpos != NULL) *(starpos) = '\0';
while (*src == ' ') ++src;
if (!hasP && !hasS && *src != '\0')
{
lcd_setstatus(src);
}
else
{
LCD_MESSAGEPGM(MSG_USERWAIT);
}
lcd_ignore_click();
st_synchronize();
refresh_cmd_timeout();
if (codenum > 0)
{
codenum += millis(); // keep track of when we started waiting
while(millis() < codenum && !lcd_clicked())
{
manage_heater();
manage_inactivity();
lcd_update();
}
lcd_ignore_click(false);
}
else
{
while(!lcd_clicked())
{
manage_heater();
manage_inactivity();
lcd_update();
}
}
if (IS_SD_PRINTING)
LCD_MESSAGEPGM(MSG_RESUMING);
else
LCD_MESSAGEPGM(WELCOME_MSG);
}
break;
#endif //ULTIPANEL
gcode_M0_M1();
}
break;
#endif //ULTIPANEL
#ifdef LASERBEAM
case 3: // M03 S - Setting laser beam
{
if(code_seen('S'))
{
laser_ttl_modulation=constrain(code_value(),0,255);
}
else
{
laser_ttl_modulation=0;
}
gcode_M3();
}
break;
case 4: // M04 - Turn on laser beam
{
WRITE(LASER_PWR_PIN, HIGH);
laser_ttl_modulation = 0;
gcode_M4();
}
break;
case 5: // M05 - Turn off laser beam
{
WRITE(LASER_PWR_PIN, LOW);
laser_ttl_modulation=0;
gcode_M5();
}
break;
#endif //LASERBEAM
case 17:
case 17: //M17 - Enable/Power all stepper motors
{
LCD_MESSAGEPGM(MSG_NO_MOVE);
enable_x();
......@@ -3503,255 +3892,7 @@ void process_commands()
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
case 49: //M49 Z-Probe repeatability
{
#if Z_MIN_PIN == -1
#error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability."
#endif
double sum=0.0;
double mean=0.0;
double sigma=0.0;
double sample_set[50];
int verbose_level=1, n=0, j, n_samples = 10, n_legs=0, engage_probe_for_each_reading=0 ;
double X_current, Y_current, Z_current;
double X_probe_location, Y_probe_location, Z_start_location, ext_position;
if (code_seen('V') || code_seen('v'))
{
verbose_level = code_value();
if (verbose_level<0 || verbose_level>4 )
{
SERIAL_PROTOCOLPGM("?Verbose Level not plausible.\n");
break;
}
}
if (verbose_level > 0)
{
SERIAL_PROTOCOLPGM("M49 Z-Probe Repeatability test. Version 2.00\n");
SERIAL_PROTOCOLPGM("Full support at: http://3dprintboard.com/forum.php\n");
}
if (code_seen('n'))
{
n_samples = code_value();
if (n_samples<4 || n_samples>50 )
{
SERIAL_PROTOCOLPGM("?Specified sample size not plausable.\n");
break;
}
}
X_current = X_probe_location = st_get_position_mm(X_AXIS);
Y_current = Y_probe_location = st_get_position_mm(Y_AXIS);
Z_current = st_get_position_mm(Z_AXIS);
Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING;
ext_position = st_get_position_mm(E_AXIS);
if (code_seen('E') || code_seen('e')) engage_probe_for_each_reading++;
if (code_seen('X') || code_seen('x'))
{
X_probe_location = code_value() - X_PROBE_OFFSET_FROM_EXTRUDER;
if (X_probe_location<X_MIN_POS || X_probe_location>X_MAX_POS)
{
SERIAL_PROTOCOLPGM("?Specified X position out of range.\n");
break;
}
}
if (code_seen('Y') || code_seen('y'))
{
Y_probe_location = code_value() - Y_PROBE_OFFSET_FROM_EXTRUDER;
if (Y_probe_location<Y_MIN_POS || Y_probe_location>Y_MAX_POS )
{
SERIAL_PROTOCOLPGM("?Specified Y position out of range.\n");
break;
}
}
if (code_seen('L') || code_seen('l'))
{
n_legs = code_value();
if (n_legs == 1) n_legs = 2;
if (n_legs<0 || n_legs>15)
{
SERIAL_PROTOCOLPGM("?Specified number of legs in movement not plausible.\n");
break;
}
}
//
// Do all the preliminary setup work. First raise the probe.
//
st_synchronize();
plan_bed_level_matrix.set_to_identity();
plan_buffer_line( X_current, Y_current, Z_start_location,
ext_position,
homing_feedrate[Z_AXIS]/60,
active_extruder, active_driver);
st_synchronize();
//
// Now get everything to the specified probe point So we can safely do a probe to
// get us close to the bed. If the Z-Axis is far from the bed, we don't want to
// use that as a starting point for each probe.
//
if (verbose_level > 2) SERIAL_PROTOCOL("Positioning probe for the test.\n");
plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, ext_position, homing_feedrate[X_AXIS]/60, active_extruder, active_driver);
st_synchronize();
current_position[X_AXIS] = X_current = st_get_position_mm(X_AXIS);
current_position[Y_AXIS] = Y_current = st_get_position_mm(Y_AXIS);
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS);
//
// OK, do the initial probe to get us close to the bed.
// Then retrace the right amount and use that in subsequent probes
//
engage_z_probe();
setup_for_endstop_move();
run_z_probe();
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING;
plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location,
ext_position,
homing_feedrate[X_AXIS]/60,
active_extruder, active_driver);
st_synchronize();
current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS);
if (engage_probe_for_each_reading) retract_z_probe();
for (n=0; n<n_samples; n++)
{
do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Make sure we are at the probe location
if (n_legs)
{
double radius=0.0, theta=0.0, x_sweep, y_sweep;
int rotational_direction, l;
rotational_direction = (unsigned long) millis() & 0x0001; // clockwise or counter clockwise
radius = (unsigned long) millis() % (long) (X_MAX_LENGTH/4); // limit how far out to go
theta = (float) ((unsigned long) millis() % (long) 360) / (360./(2*3.1415926)); // turn into radians
//SERIAL_ECHOPAIR("starting radius: ",radius);
//SERIAL_ECHOPAIR(" theta: ",theta);
//SERIAL_ECHOPAIR(" direction: ",rotational_direction);
//SERIAL_PROTOCOLLNPGM("");
for( l=0; l<n_legs-1; l++)
{
if (rotational_direction==1) theta += (float) ((unsigned long) millis() % (long) 20) / (360.0/(2*3.1415926)); // turn into radians
else theta -= (float) ((unsigned long) millis() % (long) 20) / (360.0/(2*3.1415926)); // turn into radians
radius += (float) ( ((long) ((unsigned long) millis() % (long) 10)) - 5);
if (radius < 0.0) radius = -radius;
X_current = X_probe_location + cos(theta) * radius;
Y_current = Y_probe_location + sin(theta) * radius;
if (X_current < X_MIN_POS) X_current = X_MIN_POS; // Make sure our X & Y are sane
if (X_current > X_MAX_POS) X_current = X_MAX_POS;
if (Y_current < Y_MIN_POS) Y_current = Y_MIN_POS; // Make sure our X & Y are sane
if (Y_current > Y_MAX_POS) Y_current = Y_MAX_POS;
if (verbose_level > 3)
{
SERIAL_ECHOPAIR("x: ", X_current);
SERIAL_ECHOPAIR("y: ", Y_current);
SERIAL_PROTOCOLLNPGM("");
}
do_blocking_move_to( X_current, Y_current, Z_current );
}
do_blocking_move_to( X_probe_location, Y_probe_location, Z_start_location); // Go back to the probe location
}
if (engage_probe_for_each_reading)
{
engage_z_probe();
delay(1000);
}
setup_for_endstop_move();
run_z_probe();
sample_set[n] = current_position[Z_AXIS];
//
// Get the current mean for the data points we have so far
//
sum=0.0;
for( j=0; j<=n; j++)
{
sum = sum + sample_set[j];
}
mean = sum / (double (n+1));
//
// Now, use that mean to calculate the standard deviation for the
// data points we have so far
//
sum=0.0;
for( j=0; j<=n; j++)
{
sum = sum + (sample_set[j]-mean) * (sample_set[j]-mean);
}
sigma = sqrt( sum / (double (n+1)));
if (verbose_level > 1)
{
SERIAL_PROTOCOL(n+1);
SERIAL_PROTOCOL(" of ");
SERIAL_PROTOCOL(n_samples);
SERIAL_PROTOCOLPGM(" z: ");
SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6);
}
if (verbose_level > 2)
{
SERIAL_PROTOCOL(" mean: ");
SERIAL_PROTOCOL_F(mean,6);
SERIAL_PROTOCOL(" sigma: ");
SERIAL_PROTOCOL_F(sigma,6);
}
if (verbose_level > 0) SERIAL_PROTOCOLPGM("\n");
plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location,
current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder, active_driver);
st_synchronize();
if (engage_probe_for_each_reading)
{
retract_z_probe();
delay(1000);
}
}
retract_z_probe();
delay(1000);
clean_up_after_endstop_move();
if (verbose_level > 0)
{
SERIAL_PROTOCOLPGM("Mean: ");
SERIAL_PROTOCOL_F(mean, 6);
SERIAL_PROTOCOLPGM("\n");
}
SERIAL_PROTOCOLPGM("Standard Deviation: ");
SERIAL_PROTOCOL_F(sigma, 6);
SERIAL_PROTOCOLPGM("\n\n");
gcode_M49();
}
break;
#endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
......@@ -4276,7 +4417,7 @@ void process_commands()
#endif
}
break;
//TODO: update for all axis, use for loop
#ifdef BLINKM
case 150: //M150
{
......@@ -4292,6 +4433,7 @@ void process_commands()
}
break;
#endif //BLINKM
case 200: //M200 D<millimetres> set filament diameter and set E axis units to cubic millimetres (use S0 to set back to millimetres).
{
tmp_extruder = active_extruder;
......@@ -4397,128 +4539,6 @@ void process_commands()
}
break;
#ifdef ENABLE_AUTO_BED_LEVELING
case 666: //M666 Set Z probe offset
{
if (code_seen('P'))
{
zprobe_zoffset = code_value();
}
if (code_seen('L'))
{
SERIAL_ECHOPAIR("P (Z-Probe Offset):", zprobe_zoffset);
SERIAL_ECHOLN("");
}
}
break;
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef DELTA
case 666: //M666 set delta endstop and geometry adjustment
{
if ( !(code_seen('P')))
{
for(int8_t i=0; i < 3; i++)
{
if (code_seen(axis_codes[i])) endstop_adj[i] = code_value();
}
}
if (code_seen('A'))
{
tower_adj[0] = code_value();
set_delta_constants();
}
if (code_seen('B'))
{
tower_adj[1] = code_value();
set_delta_constants();
}
if (code_seen('C'))
{
tower_adj[2] = code_value();
set_delta_constants();
}
if (code_seen('I'))
{
tower_adj[3] = code_value();
set_delta_constants();
}
if (code_seen('J'))
{
tower_adj[4] = code_value();
set_delta_constants();
}
if (code_seen('K'))
{
tower_adj[5] = code_value();
set_delta_constants();
}
if (code_seen('R'))
{
delta_radius = code_value();
set_delta_constants();
}
if (code_seen('D'))
{
delta_diagonal_rod = code_value();
set_delta_constants();
}
if (code_seen('H'))
{
max_pos[Z_AXIS]= code_value();
set_delta_constants();
}
if (code_seen('P'))
{
float pz = code_value();
if (!(code_seen(axis_codes[0]) || code_seen(axis_codes[1]) || code_seen(axis_codes[2]))) // Allow direct set of Z offset without an axis code
{
z_probe_offset[Z_AXIS]= pz;
}
else
{
for(int8_t i=0; i < 3; i++)
{
if (code_seen(axis_codes[i])) z_probe_offset[i] = code_value();
}
}
}
if (code_seen('L'))
{
SERIAL_ECHOLN("Current Delta geometry values:");
SERIAL_ECHOPAIR("X (Endstop Adj): ",endstop_adj[0]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Y (Endstop Adj): ",endstop_adj[1]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("Z (Endstop Adj): ",endstop_adj[2]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("P (Z-Probe Offset): X", z_probe_offset[0]);
SERIAL_ECHOPAIR(" Y", z_probe_offset[1]);
SERIAL_ECHOPAIR(" Z", z_probe_offset[2]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("A (Tower A Position Correction): ",tower_adj[0]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("B (Tower B Position Correction): ",tower_adj[1]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("C (Tower C Position Correction): ",tower_adj[2]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("I (Tower A Radius Correction): ",tower_adj[3]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("J (Tower B Radius Correction): ",tower_adj[4]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("K (Tower C Radius Correction): ",tower_adj[5]);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("R (Delta Radius): ",delta_radius);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("D (Diagonal Rod Length): ",delta_diagonal_rod);
SERIAL_ECHOLN("");
SERIAL_ECHOPAIR("H (Z-Height): ",max_pos[Z_AXIS]);
SERIAL_ECHOLN("");
}
}
break;
#endif //Delta
#ifdef FWRETRACT
case 207: //M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop]
{
......@@ -4706,7 +4726,47 @@ void process_commands()
}
}
break;
case 240: //M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
{
#ifdef CHDK
SET_OUTPUT(CHDK);
WRITE(CHDK, HIGH);
chdkHigh = millis();
chdkActive = true;
#else
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
const uint8_t NUM_PULSES=16;
const float PULSE_LENGTH=0.01524;
for(int i=0; i < NUM_PULSES; i++)
{
WRITE(PHOTOGRAPH_PIN, HIGH);
_delay_ms(PULSE_LENGTH);
WRITE(PHOTOGRAPH_PIN, LOW);
_delay_ms(PULSE_LENGTH);
}
delay(7.33);
for(int i=0; i < NUM_PULSES; i++) {
WRITE(PHOTOGRAPH_PIN, HIGH);
_delay_ms(PULSE_LENGTH);
WRITE(PHOTOGRAPH_PIN, LOW);
_delay_ms(PULSE_LENGTH);
}
#endif //defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
#endif //CHDK
}
break;
#ifdef DOGLCD
case 250: //M250 Set LCD contrast value: C<value> (value 0..63)
{
if (code_seen('C')) lcd_setcontrast(((int)code_value())&63);
SERIAL_PROTOCOLPGM("lcd contrast value: ");
SERIAL_PROTOCOL(lcd_contrast);
SERIAL_PROTOCOLLN("");
}
break;
#endif //DOGLCD
#if NUM_SERVOS > 0
case 280: //M280 - set servo position absolute. P: servo index, S: angle or microseconds
{
......@@ -4810,6 +4870,16 @@ void process_commands()
break;
#endif //PIDTEMP
#ifdef PREVENT_DANGEROUS_EXTRUDE
case 302: //M302 allow cold extrudes, or set the minimum extrude temperature
{
float temp = .0;
if (code_seen('S')) temp=code_value();
set_extrude_min_temp(temp);
}
break;
#endif //PREVENT_DANGEROUS_EXTRUDE
#ifdef PIDTEMPBED
case 304: // M304
{
......@@ -4829,56 +4899,7 @@ void process_commands()
}
break;
#endif //PIDTEMPBED
case 240: //M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
{
#ifdef CHDK
SET_OUTPUT(CHDK);
WRITE(CHDK, HIGH);
chdkHigh = millis();
chdkActive = true;
#else
#if defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
const uint8_t NUM_PULSES=16;
const float PULSE_LENGTH=0.01524;
for(int i=0; i < NUM_PULSES; i++)
{
WRITE(PHOTOGRAPH_PIN, HIGH);
_delay_ms(PULSE_LENGTH);
WRITE(PHOTOGRAPH_PIN, LOW);
_delay_ms(PULSE_LENGTH);
}
delay(7.33);
for(int i=0; i < NUM_PULSES; i++) {
WRITE(PHOTOGRAPH_PIN, HIGH);
_delay_ms(PULSE_LENGTH);
WRITE(PHOTOGRAPH_PIN, LOW);
_delay_ms(PULSE_LENGTH);
}
#endif //defined(PHOTOGRAPH_PIN) && PHOTOGRAPH_PIN > -1
#endif //CHDK
}
break;
#ifdef DOGLCD
case 250: //M250 Set LCD contrast value: C<value> (value 0..63)
{
if (code_seen('C')) lcd_setcontrast(((int)code_value())&63);
SERIAL_PROTOCOLPGM("lcd contrast value: ");
SERIAL_PROTOCOL(lcd_contrast);
SERIAL_PROTOCOLLN("");
}
break;
#endif
#ifdef PREVENT_DANGEROUS_EXTRUDE
case 302: //M302 allow cold extrudes, or set the minimum extrude temperature
{
float temp = .0;
if (code_seen('S')) temp=code_value();
set_extrude_min_temp(temp);
}
break;
#endif
case 303: //M303 PID autotune
{
float temp = 150.0;
......@@ -4891,6 +4912,34 @@ void process_commands()
PID_autotune(temp, e, c);
}
break;
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
{
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
if(code_seen('B')) microstep_mode(4,code_value());
microstep_readings();
#endif // X_MS1_PIN
}
break;
case 351: // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
{
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
if(code_seen('S')) switch((int)code_value())
{
case 1:
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,code_value(),-1);
if(code_seen('B')) microstep_ms(4,code_value(),-1);
break;
case 2:
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,-1,code_value());
if(code_seen('B')) microstep_ms(4,-1,code_value());
break;
}
microstep_readings();
#endif // X_MS1_PIN
}
break;
#ifdef SCARA
case 360: //M360 SCARA Theta pos1
......@@ -5338,6 +5387,14 @@ void process_commands()
break;
#endif //DUAL_X_CARRIAGE
#if defined(ENABLE_AUTO_BED_LEVELING) || defined(DELTA)
case 666: //M666 Set Z probe offset or set delta endstop and geometry adjustment
{
gcode_M666();
}
break;
#endif //defined(ENABLE_AUTO_BED_LEVELING) || defined(DELTA)
case 907: // M907 Set digital trim pot motor current using axis codes.
{
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
......@@ -5372,34 +5429,6 @@ void process_commands()
#endif // DIGIPOTSS_PIN
}
break;
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
{
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
if(code_seen('B')) microstep_mode(4,code_value());
microstep_readings();
#endif // X_MS1_PIN
}
break;
case 351: // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
{
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
if(code_seen('S')) switch((int)code_value())
{
case 1:
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,code_value(),-1);
if(code_seen('B')) microstep_ms(4,code_value(),-1);
break;
case 2:
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,-1,code_value());
if(code_seen('B')) microstep_ms(4,-1,code_value());
break;
}
microstep_readings();
#endif // X_MS1_PIN
}
break;
#ifdef NPR2
case 997: // M997 Cxx Move Carter xx gradi
......
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