Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
8ccd9f2b
Commit
8ccd9f2b
authored
Feb 03, 2015
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Marlin_main.cpp
parent
be098c85
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1135 additions
and
1102 deletions
+1135
-1102
Configuration.h
MarlinKimbra/Configuration.h
+43
-47
ConfigurationStore.cpp
MarlinKimbra/ConfigurationStore.cpp
+523
-515
Marlin_main.cpp
MarlinKimbra/Marlin_main.cpp
+569
-540
No files found.
MarlinKimbra/Configuration.h
View file @
8ccd9f2b
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
// This configuration file contains basic settings. Select your:
// This configuration file contains basic settings. Select your:
// - board type
// - board type
// - temperature sensor type
// - Mechanism type (cartesian-corexy-delta-scara)
// - 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_xxx
xxx
.h
// Advanced settings can be found in Configuration_adv.h
// Advanced settings can be found in Configuration_adv.h
// Choose your board type.
// Choose your board type.
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
#endif
#endif
/***********************************************************************/
/***********************************************************************/
// This defines the number of extruder
s
real or virtual
// This defines the number of extruder real or virtual
#define EXTRUDERS 1
#define EXTRUDERS 1
// This is used for singlenozzled multiple extrusion configuration
// This is used for singlenozzled multiple extrusion configuration
...
@@ -88,8 +88,8 @@
...
@@ -88,8 +88,8 @@
***********************************************************************/
***********************************************************************/
//#define MKR4
//#define MKR4
#ifdef MKR4
#ifdef MKR4
#define DELAY_R 500 // Delay for switch rele
#define DELAY_R 500 // Delay for switch rele
#define DRIVER_EXTRUDERS 1 // This defines the number of Driver extruders
#define DRIVER_EXTRUDERS 2 // This defines the number of Driver extruder
#endif // END MKR4
#endif // END MKR4
//**********************************************************************
//**********************************************************************
...
@@ -107,21 +107,21 @@
...
@@ -107,21 +107,21 @@
***********************************************************************/
***********************************************************************/
//#define NPR2
//#define NPR2
#ifdef NPR2
#ifdef NPR2
#define COLOR_STEP {120,25,-65,-155} // CARTER ANGLE
#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_SLOWRATE 170 // MICROSECOND delay for carter motor routine (Carter Motor Feedrate: upper value-slow feedrate)
#define COLOR_HOMERATE 4 // FEEDRATE for carter home
#define COLOR_HOMERATE 4 // FEEDRATE for carter home
#define MOTOR_ANGLE 1.8 // Nema angle for single step
#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 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 CARTER_MOLTIPLICATOR 14.22 // CARTER MOLTIPLICATOR (gear ratio 13/31-10/31)
#define DRIVER_EXTRUDERS 2 // This defines the number of Driver extruders
#define DRIVER_EXTRUDERS 2 // This defines the number of Driver extruders
#endif
#endif
//**********************************************************************
//**********************************************************************
#if !defined(MKR4) && !defined(NPR2)
#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
#endif
// The following define selects which power supply you have. Please choose the one that matches your setup
// The following define selects which power supply you have. Please choose the one that matches your setup
// 0 = Normal power
// 0 = Normal power
// 1 = ATX
// 1 = ATX
...
@@ -182,7 +182,7 @@
...
@@ -182,7 +182,7 @@
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 // (degC)
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10 // (degC)
#ifdef SINGLENOZZLE
#ifdef SINGLENOZZLE
#undef TEMP_SENSOR_1_AS_REDUNDANT
#undef TEMP_SENSOR_1_AS_REDUNDANT
#endif
#endif
// Actual temperature must be close to target for this long before M109 returns success
// Actual temperature must be close to target for this long before M109 returns success
...
@@ -374,32 +374,32 @@ your extruder heater takes 2 minutes to hit the target on heating.
...
@@ -374,32 +374,32 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define ULTIPANEL
#define ULTIPANEL
#define NEWPANEL
#define NEWPANEL
#define DEFAULT_LCD_CONTRAST 17
#define DEFAULT_LCD_CONTRAST 17
#endif
#endif
//defined (MAKRPANEL)
#if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
#define DOGLCD
#define DOGLCD
#define U8GLIB_ST7920
#define U8GLIB_ST7920
#define REPRAP_DISCOUNT_SMART_CONTROLLER
#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)
#if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#define ULTIPANEL
#define ULTIPANEL
#define NEWPANEL
#define NEWPANEL
#endif
#endif
//defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#if defined(REPRAPWORLD_KEYPAD)
#if defined(REPRAPWORLD_KEYPAD)
#define NEWPANEL
#define NEWPANEL
#define ULTIPANEL
#define ULTIPANEL
#endif
#endif //defined(REPRAPWORLD_KEYPAD)
#if defined(RA_CONTROL_PANEL)
#if defined(RA_CONTROL_PANEL)
#define ULTIPANEL
#define ULTIPANEL
#define NEWPANEL
#define NEWPANEL
#define LCD_I2C_TYPE_PCA8574
#define LCD_I2C_TYPE_PCA8574
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#endif
#endif
//defined(RA_CONTROL_PANEL)
//I2C PANELS
//I2C PANELS
//#define LCD_I2C_SAINSMART_YWROBOT
//#define LCD_I2C_SAINSMART_YWROBOT
#ifdef LCD_I2C_SAINSMART_YWROBOT
#ifdef LCD_I2C_SAINSMART_YWROBOT
// This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
// 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.
...
@@ -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 LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
#define NEWPANEL
#define NEWPANEL
#define ULTIPANEL
#define ULTIPANEL
#endif
#endif
//LCD_I2C_SAINSMART_YWROBOT
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
//#define LCD_I2C_PANELOLU2
//#define LCD_I2C_PANELOLU2
...
@@ -432,13 +432,11 @@ your extruder heater takes 2 minutes to hit the target on heating.
...
@@ -432,13 +432,11 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define ENCODER_STEPS_PER_MENU_ITEM 1
#define ENCODER_STEPS_PER_MENU_ITEM 1
#endif
#endif
#ifdef LCD_USE_I2C_BUZZER
#ifdef LCD_USE_I2C_BUZZER
#define LCD_FEEDBACK_FREQUENCY_HZ 1000
#define LCD_FEEDBACK_FREQUENCY_HZ 1000
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100
#endif
#endif
#endif //LCD_I2C_PANELOLU2
#endif
// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
//#define LCD_I2C_VIKI
//#define LCD_I2C_VIKI
...
@@ -452,7 +450,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
...
@@ -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 LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later)
#define NEWPANEL
#define NEWPANEL
#define ULTIPANEL
#define ULTIPANEL
#endif
#endif
//LCD_I2C_VIKI
// Shift register panels
// Shift register panels
// ---------------------
// ---------------------
...
@@ -464,38 +462,38 @@ your extruder heater takes 2 minutes to hit the target on heating.
...
@@ -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 SR_LCD_2W_NL // Non latching 2 wire shiftregister
#define NEWPANEL
#define NEWPANEL
#define ULTIPANEL
#define ULTIPANEL
#endif
#endif
//SAV_3DLCD
#ifdef ULTIPANEL
#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 SDSUPPORT
#define ULTRA_LCD
#define ULTRA_LCD
#ifdef DOGLCD // Change number of lines to match the DOG graphic display
#ifdef DOGLCD // Change number of lines to match the DOG graphic display
#define LCD_WIDTH 2
0
#define LCD_WIDTH 2
2
#define LCD_HEIGHT 5
#define LCD_HEIGHT 5
#else
#else
//NO DOGLCD
#define LCD_WIDTH 20
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#define LCD_HEIGHT 4
#endif
#endif
//DOGLCD
#else //no
panel but just LCD
#else //no
ULTIPANEL
#ifdef ULTRA_LCD
#ifdef ULTRA_LCD
#ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
#ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
#define LCD_WIDTH 20
#define LCD_WIDTH 22
#define LCD_HEIGHT 5
#define LCD_HEIGHT 5
#else
#else //NO DOGLCD
#define LCD_WIDTH 16
#define LCD_WIDTH 16
#define LCD_HEIGHT 2
#define LCD_HEIGHT 2
#endif
#endif //DOGLCD
#endif
#endif
//ULTRA_LCD
#endif
#endif
//ULTIPANEL
// default LCD contrast for dogm-like LCD displays
// default LCD contrast for dogm-like LCD displays
#ifdef DOGLCD
#ifdef DOGLCD
#ifndef DEFAULT_LCD_CONTRAST
#ifndef DEFAULT_LCD_CONTRAST
#define DEFAULT_LCD_CONTRAST 32
#define DEFAULT_LCD_CONTRAST 32
#endif
#endif
#endif
#endif
//DOGLCD
// option for invert rotary switch
// option for invert rotary switch
//#define INVERT_ROTARY_SWITCH
//#define INVERT_ROTARY_SWITCH
...
@@ -543,7 +541,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
...
@@ -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_RETRACT_FEEDRATE 10 // mm/s
#define LCD_LOAD_FEEDRATE 8 // mm/s
#define LCD_LOAD_FEEDRATE 8 // mm/s
#define LCD_UNLOAD_FEEDRATE 8 // mm/s
#define LCD_UNLOAD_FEEDRATE 8 // mm/s
#endif
#endif
//EASY_LOAD
//============================== Preheat Constants ==========================
//============================== Preheat Constants ==========================
...
@@ -648,7 +646,5 @@ your extruder heater takes 2 minutes to hit the target on heating.
...
@@ -648,7 +646,5 @@ your extruder heater takes 2 minutes to hit the target on heating.
//#define LASERBEAM
//#define LASERBEAM
#include "Configuration_adv.h"
#include "Configuration_adv.h"
#endif //__CONFIGURATION_H
#endif //__CONFIGURATION_H
MarlinKimbra/ConfigurationStore.cpp
View file @
8ccd9f2b
...
@@ -5,47 +5,50 @@
...
@@ -5,47 +5,50 @@
#include "ultralcd.h"
#include "ultralcd.h"
#include "ConfigurationStore.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
;
uint8_t
c
;
while
(
size
--
)
{
while
(
size
--
)
{
eeprom_write_byte
((
unsigned
char
*
)
pos
,
*
value
);
eeprom_write_byte
((
unsigned
char
*
)
pos
,
*
value
);
c
=
eeprom_read_byte
((
unsigned
char
*
)
pos
);
c
=
eeprom_read_byte
((
unsigned
char
*
)
pos
);
if
(
c
!=
*
value
)
{
if
(
c
!=
*
value
)
{
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
MSG_ERR_EEPROM_WRITE
);
SERIAL_ECHOLNPGM
(
MSG_ERR_EEPROM_WRITE
);
}
}
pos
++
;
pos
++
;
value
++
;
value
++
;
}
;
}
}
}
void
_EEPROM_readData
(
int
&
pos
,
uint8_t
*
value
,
uint8_t
size
)
{
void
_EEPROM_readData
(
int
&
pos
,
uint8_t
*
value
,
uint8_t
size
)
do
{
{
do
{
*
value
=
eeprom_read_byte
((
unsigned
char
*
)
pos
);
*
value
=
eeprom_read_byte
((
unsigned
char
*
)
pos
);
pos
++
;
pos
++
;
value
++
;
value
++
;
}
while
(
--
size
);
}
while
(
--
size
);
}
}
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
#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 EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
//======================================================================================
//======================================================================================
#define DUMMY_PID_VALUE 3000.0f
#define DUMMY_PID_VALUE 3000.0f
#define EEPROM_OFFSET 100
#define EEPROM_OFFSET 100
// IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
// 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
// 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
// the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables.
// wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V1
1
"
#define EEPROM_VERSION "V1
2
"
#ifdef EEPROM_SETTINGS
#ifdef EEPROM_SETTINGS
void
Config_StoreSettings
()
void
Config_StoreSettings
()
{
{
float
dummy
=
0.0
f
;
float
dummy
=
0.0
f
;
char
ver
[
4
]
=
"000"
;
char
ver
[
4
]
=
"000"
;
int
i
=
EEPROM_OFFSET
;
int
i
=
EEPROM_OFFSET
;
...
@@ -64,25 +67,22 @@ void Config_StoreSettings() {
...
@@ -64,25 +67,22 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR
(
i
,
max_z_jerk
);
EEPROM_WRITE_VAR
(
i
,
max_z_jerk
);
EEPROM_WRITE_VAR
(
i
,
max_e_jerk
);
EEPROM_WRITE_VAR
(
i
,
max_e_jerk
);
EEPROM_WRITE_VAR
(
i
,
add_homing
);
EEPROM_WRITE_VAR
(
i
,
add_homing
);
EEPROM_WRITE_VAR
(
i
,
zprobe_zoffset
);
#ifdef DELTA
#ifdef DELTA
EEPROM_WRITE_VAR
(
i
,
delta_radius
);
EEPROM_WRITE_VAR
(
i
,
delta_radius
);
EEPROM_WRITE_VAR
(
i
,
delta_diagonal_rod
);
EEPROM_WRITE_VAR
(
i
,
delta_diagonal_rod
);
EEPROM_WRITE_VAR
(
i
,
max_pos
);
EEPROM_WRITE_VAR
(
i
,
max_pos
);
EEPROM_WRITE_VAR
(
i
,
endstop_adj
);
EEPROM_WRITE_VAR
(
i
,
endstop_adj
);
EEPROM_WRITE_VAR
(
i
,
tower_adj
);
EEPROM_WRITE_VAR
(
i
,
tower_adj
);
EEPROM_WRITE_VAR
(
i
,
z_probe_offset
);
EEPROM_WRITE_VAR
(
i
,
z_probe_offset
);
#endif
#endif
#ifdef ENABLE_AUTO_BED_LEVELING
EEPROM_WRITE_VAR
(
i
,
zprobe_zoffset
);
#endif
#ifndef ULTIPANEL
#ifndef ULTIPANEL
int
plaPreheatHotendTemp
=
PLA_PREHEAT_HOTEND_TEMP
,
plaPreheatHPBTemp
=
PLA_PREHEAT_HPB_TEMP
,
plaPreheatFanSpeed
=
PLA_PREHEAT_FAN_SPEED
;
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
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
;
int
gumPreheatHotendTemp
=
GUM_PREHEAT_HOTEND_TEMP
,
gumPreheatHPBTemp
=
GUM_PREHEAT_HPB_TEMP
,
gumPreheatFanSpeed
=
GUM_PREHEAT_FAN_SPEED
;
#endif
#endif
EEPROM_WRITE_VAR
(
i
,
plaPreheatHotendTemp
);
EEPROM_WRITE_VAR
(
i
,
plaPreheatHotendTemp
);
EEPROM_WRITE_VAR
(
i
,
plaPreheatHPBTemp
);
EEPROM_WRITE_VAR
(
i
,
plaPreheatHPBTemp
);
...
@@ -94,38 +94,38 @@ void Config_StoreSettings() {
...
@@ -94,38 +94,38 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR
(
i
,
gumPreheatHPBTemp
);
EEPROM_WRITE_VAR
(
i
,
gumPreheatHPBTemp
);
EEPROM_WRITE_VAR
(
i
,
gumPreheatFanSpeed
);
EEPROM_WRITE_VAR
(
i
,
gumPreheatFanSpeed
);
#ifdef PIDTEMP
#ifdef PIDTEMP
EEPROM_WRITE_VAR
(
i
,
Kp
);
EEPROM_WRITE_VAR
(
i
,
Kp
);
EEPROM_WRITE_VAR
(
i
,
Ki
);
EEPROM_WRITE_VAR
(
i
,
Ki
);
EEPROM_WRITE_VAR
(
i
,
Kd
);
EEPROM_WRITE_VAR
(
i
,
Kd
);
#endif //
PIDTEMP
#endif //
PIDTEMP
#ifndef DOGLCD
#ifndef DOGLCD
int
lcd_contrast
=
32
;
int
lcd_contrast
=
32
;
#endif
#endif
EEPROM_WRITE_VAR
(
i
,
lcd_contrast
);
EEPROM_WRITE_VAR
(
i
,
lcd_contrast
);
#ifdef SCARA
#ifdef SCARA
EEPROM_WRITE_VAR
(
i
,
axis_scaling
);
// Add scaling for SCARA
EEPROM_WRITE_VAR
(
i
,
axis_scaling
);
// Add scaling for SCARA
#endif //SCARA
#endif //SCARA
#ifdef FWRETRACT
#ifdef FWRETRACT
EEPROM_WRITE_VAR
(
i
,
autoretract_enabled
);
EEPROM_WRITE_VAR
(
i
,
autoretract_enabled
);
EEPROM_WRITE_VAR
(
i
,
retract_length
);
EEPROM_WRITE_VAR
(
i
,
retract_length
);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
EEPROM_WRITE_VAR
(
i
,
retract_length_swap
);
EEPROM_WRITE_VAR
(
i
,
retract_length_swap
);
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
EEPROM_WRITE_VAR
(
i
,
retract_feedrate
);
EEPROM_WRITE_VAR
(
i
,
retract_feedrate
);
EEPROM_WRITE_VAR
(
i
,
retract_zlift
);
EEPROM_WRITE_VAR
(
i
,
retract_zlift
);
EEPROM_WRITE_VAR
(
i
,
retract_recover_length
);
EEPROM_WRITE_VAR
(
i
,
retract_recover_length
);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
EEPROM_WRITE_VAR
(
i
,
retract_recover_length_swap
);
EEPROM_WRITE_VAR
(
i
,
retract_recover_length_swap
);
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
EEPROM_WRITE_VAR
(
i
,
retract_recover_feedrate
);
EEPROM_WRITE_VAR
(
i
,
retract_recover_feedrate
);
#endif // FWRETRACT
#endif // FWRETRACT
// Save filament sizes
EEPROM_WRITE_VAR
(
i
,
volumetric_enabled
);
EEPROM_WRITE_VAR
(
i
,
volumetric_enabled
);
// Save filament sizes
// Save filament sizes
for
(
int
e
=
0
;
e
<
EXTRUDERS
;
e
++
)
EEPROM_WRITE_VAR
(
i
,
filament_size
[
e
]);
for
(
int
e
=
0
;
e
<
EXTRUDERS
;
e
++
)
EEPROM_WRITE_VAR
(
i
,
filament_size
[
e
]);
int
storageSize
=
i
;
int
storageSize
=
i
;
...
@@ -138,12 +138,251 @@ void Config_StoreSettings() {
...
@@ -138,12 +138,251 @@ void Config_StoreSettings() {
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
"Settings Stored ("
,
(
unsigned
long
)
i
);
SERIAL_ECHOPAIR
(
"Settings Stored ("
,
(
unsigned
long
)
i
);
SERIAL_ECHOLNPGM
(
" bytes)"
);
SERIAL_ECHOLNPGM
(
" bytes)"
);
}
}
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
)
{
// 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
}
#endif //EEPROM_SETTINGS
#endif //EEPROM_SETTINGS
void
Config_ResetDefault
()
{
//Setting default baudrate for serial
baudrate
=
BAUDRATE
;
const
static
float
tmp1
[]
=
DEFAULT_AXIS_STEPS_PER_UNIT
;
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
for
(
short
i
=
0
;
i
<
3
+
EXTRUDERS
;
i
++
)
{
axis_steps_per_unit
[
i
]
=
tmp1
[
i
];
max_feedrate
[
i
]
=
tmp2
[
i
];
max_acceleration_units_per_sq_second
[
i
]
=
tmp4
[
i
];
}
for
(
short
i
=
0
;
i
<
EXTRUDERS
;
i
++
)
{
max_retraction_feedrate
[
i
]
=
tmp3
[
i
];
#ifdef SCARA
axis_scaling
[
i
]
=
1
;
#endif //SCARA
}
// steps per sq second need to be updated to agree with the units per sq second
reset_acceleration_rates
();
acceleration
=
DEFAULT_ACCELERATION
;
retract_acceleration
=
DEFAULT_RETRACT_ACCELERATION
;
minimumfeedrate
=
DEFAULT_MINIMUMFEEDRATE
;
minsegmenttime
=
DEFAULT_MINSEGMENTTIME
;
mintravelfeedrate
=
DEFAULT_MINTRAVELFEEDRATE
;
max_xy_jerk
=
DEFAULT_XYJERK
;
max_z_jerk
=
DEFAULT_ZJERK
;
max_e_jerk
=
DEFAULT_EJERK
;
add_homing
[
0
]
=
add_homing
[
1
]
=
add_homing
[
2
]
=
0
;
#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
calculate_volumetric_multipliers
();
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Hardcoded Default Settings Loaded"
);
}
#ifdef EEPROM_CHITCHAT
#ifdef EEPROM_CHITCHAT
void
Config_PrintSettings
()
{
// Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
void
Config_PrintSettings
()
{
// Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
"Baudrate: "
,
baudrate
);
SERIAL_ECHOPAIR
(
"Baudrate: "
,
baudrate
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
...
@@ -153,19 +392,19 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -153,19 +392,19 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
" Y"
,
axis_steps_per_unit
[
Y_AXIS
]);
SERIAL_ECHOPAIR
(
" Y"
,
axis_steps_per_unit
[
Y_AXIS
]);
SERIAL_ECHOPAIR
(
" Z"
,
axis_steps_per_unit
[
Z_AXIS
]);
SERIAL_ECHOPAIR
(
" Z"
,
axis_steps_per_unit
[
Z_AXIS
]);
SERIAL_ECHOPAIR
(
" E0 S"
,
axis_steps_per_unit
[
E_AXIS
+
0
]);
SERIAL_ECHOPAIR
(
" E0 S"
,
axis_steps_per_unit
[
E_AXIS
+
0
]);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
SERIAL_ECHOPAIR
(
" E1 S"
,
axis_steps_per_unit
[
E_AXIS
+
1
]);
SERIAL_ECHOPAIR
(
" E1 S"
,
axis_steps_per_unit
[
E_AXIS
+
1
]);
#if EXTRUDERS > 2
#if EXTRUDERS > 2
SERIAL_ECHOPAIR
(
" E2 S"
,
axis_steps_per_unit
[
E_AXIS
+
2
]);
SERIAL_ECHOPAIR
(
" E2 S"
,
axis_steps_per_unit
[
E_AXIS
+
2
]);
#if EXTRUDERS > 3
#if EXTRUDERS > 3
SERIAL_ECHOPAIR
(
" E3 S"
,
axis_steps_per_unit
[
E_AXIS
+
3
]);
SERIAL_ECHOPAIR
(
" E3 S"
,
axis_steps_per_unit
[
E_AXIS
+
3
]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
#ifdef SCARA
#ifdef SCARA
SERIAL_ECHOLNPGM
(
"Scaling factors:"
);
SERIAL_ECHOLNPGM
(
"Scaling factors:"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M365 X"
,
axis_scaling
[
X_AXIS
]);
SERIAL_ECHOPAIR
(
" M365 X"
,
axis_scaling
[
X_AXIS
]);
...
@@ -173,7 +412,7 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -173,7 +412,7 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
" Z"
,
axis_scaling
[
Z_AXIS
]);
SERIAL_ECHOPAIR
(
" Z"
,
axis_scaling
[
Z_AXIS
]);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
#endif
#endif
SERIAL_ECHOLNPGM
(
"Maximum feedrates (mm/s):"
);
SERIAL_ECHOLNPGM
(
"Maximum feedrates (mm/s):"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
...
@@ -181,29 +420,29 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -181,29 +420,29 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
" Y "
,
max_feedrate
[
Y_AXIS
]
);
SERIAL_ECHOPAIR
(
" Y "
,
max_feedrate
[
Y_AXIS
]
);
SERIAL_ECHOPAIR
(
" Z "
,
max_feedrate
[
Z_AXIS
]
);
SERIAL_ECHOPAIR
(
" Z "
,
max_feedrate
[
Z_AXIS
]
);
SERIAL_ECHOPAIR
(
" E0 "
,
max_feedrate
[
E_AXIS
+
0
]);
SERIAL_ECHOPAIR
(
" E0 "
,
max_feedrate
[
E_AXIS
+
0
]);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
SERIAL_ECHOPAIR
(
" E1 "
,
max_feedrate
[
E_AXIS
+
1
]);
SERIAL_ECHOPAIR
(
" E1 "
,
max_feedrate
[
E_AXIS
+
1
]);
#if EXTRUDERS > 2
#if EXTRUDERS > 2
SERIAL_ECHOPAIR
(
" E2 "
,
max_feedrate
[
E_AXIS
+
2
]);
SERIAL_ECHOPAIR
(
" E2 "
,
max_feedrate
[
E_AXIS
+
2
]);
#if EXTRUDERS > 3
#if EXTRUDERS > 3
SERIAL_ECHOPAIR
(
" E3 "
,
max_feedrate
[
E_AXIS
+
3
]);
SERIAL_ECHOPAIR
(
" E3 "
,
max_feedrate
[
E_AXIS
+
3
]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Retraction Steps per unit:"
);
SERIAL_ECHOLNPGM
(
"Retraction Steps per unit:"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" E0 "
,
max_retraction_feedrate
[
0
]);
SERIAL_ECHOPAIR
(
" E0 "
,
max_retraction_feedrate
[
0
]);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
SERIAL_ECHOPAIR
(
" E1 "
,
max_retraction_feedrate
[
1
]);
SERIAL_ECHOPAIR
(
" E1 "
,
max_retraction_feedrate
[
1
]);
#if EXTRUDERS > 2
#if EXTRUDERS > 2
SERIAL_ECHOPAIR
(
" E2 "
,
max_retraction_feedrate
[
2
]);
SERIAL_ECHOPAIR
(
" E2 "
,
max_retraction_feedrate
[
2
]);
#if EXTRUDERS > 3
#if EXTRUDERS > 3
SERIAL_ECHOPAIR
(
" E3 "
,
max_retraction_feedrate
[
3
]);
SERIAL_ECHOPAIR
(
" E3 "
,
max_retraction_feedrate
[
3
]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Maximum Acceleration (mm/s2):"
);
SERIAL_ECHOLNPGM
(
"Maximum Acceleration (mm/s2):"
);
...
@@ -212,15 +451,15 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -212,15 +451,15 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
" Y "
,
max_acceleration_units_per_sq_second
[
Y_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
(
" Z "
,
max_acceleration_units_per_sq_second
[
Z_AXIS
]
);
SERIAL_ECHOPAIR
(
" E0 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
]);
SERIAL_ECHOPAIR
(
" E0 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
]);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
SERIAL_ECHOPAIR
(
" E1 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
+
1
]);
SERIAL_ECHOPAIR
(
" E1 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
+
1
]);
#if EXTRUDERS > 2
#if EXTRUDERS > 2
SERIAL_ECHOPAIR
(
" E2 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
+
2
]);
SERIAL_ECHOPAIR
(
" E2 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
+
2
]);
#if EXTRUDERS > 3
#if EXTRUDERS > 3
SERIAL_ECHOPAIR
(
" E3 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
+
3
]);
SERIAL_ECHOPAIR
(
" E3 "
,
max_acceleration_units_per_sq_second
[
E_AXIS
+
3
]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Acceleration: S=acceleration, T=retract acceleration"
);
SERIAL_ECHOLNPGM
(
"Acceleration: S=acceleration, T=retract acceleration"
);
...
@@ -248,7 +487,7 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -248,7 +487,7 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
" Z"
,
add_homing
[
Z_AXIS
]
);
SERIAL_ECHOPAIR
(
" Z"
,
add_homing
[
Z_AXIS
]
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#ifdef DELTA
#ifdef DELTA
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Endstop adjustment (mm):"
);
SERIAL_ECHOLNPGM
(
"Endstop adjustment (mm):"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
...
@@ -270,7 +509,6 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -270,7 +509,6 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
" H"
,
max_pos
[
2
]);
SERIAL_ECHOPAIR
(
" H"
,
max_pos
[
2
]);
SERIAL_ECHOPAIR
(
" P"
,
z_probe_offset
[
3
]);
SERIAL_ECHOPAIR
(
" P"
,
z_probe_offset
[
3
]);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
"Tower Positions"
);
SERIAL_ECHOLN
(
"Tower Positions"
);
SERIAL_ECHOPAIR
(
"Tower1 X:"
,
delta_tower1_x
);
SERIAL_ECHOPAIR
(
"Tower1 X:"
,
delta_tower1_x
);
SERIAL_ECHOPAIR
(
" Y:"
,
delta_tower1_y
);
SERIAL_ECHOPAIR
(
" Y:"
,
delta_tower1_y
);
...
@@ -281,25 +519,24 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -281,25 +519,24 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
"Tower3 X:"
,
delta_tower3_x
);
SERIAL_ECHOPAIR
(
"Tower3 X:"
,
delta_tower3_x
);
SERIAL_ECHOPAIR
(
" Y:"
,
delta_tower3_y
);
SERIAL_ECHOPAIR
(
" Y:"
,
delta_tower3_y
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#endif // DELTA
#endif // DELTA
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef ENABLE_AUTO_BED_LEVELING
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Z Probe offset (mm)"
);
SERIAL_ECHOLNPGM
(
"Z Probe offset (mm)"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M666 P"
,
zprobe_zoffset
);
SERIAL_ECHOPAIR
(
" M666 P"
,
zprobe_zoffset
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#endif // ENABLE_AUTO_BED_LEVELING
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef PIDTEMP
#ifdef PIDTEMP
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"PID settings:"
);
SERIAL_ECHOLNPGM
(
"PID settings:"
);
#ifndef SINGLENOZZLE
#ifndef SINGLENOZZLE
for
(
int
e
=
0
;
e
<
EXTRUDERS
;
e
++
)
for
(
int
e
=
0
;
e
<
EXTRUDERS
;
e
++
)
#else
#else
int
e
=
0
;
int
e
=
0
;
#endif
#endif
{
{
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M301 E"
,
(
long
unsigned
int
)
e
);
SERIAL_ECHOPAIR
(
" M301 E"
,
(
long
unsigned
int
)
e
);
...
@@ -308,9 +545,9 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -308,9 +545,9 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHOPAIR
(
" D"
,
unscalePID_d
(
Kd
[
e
]));
SERIAL_ECHOPAIR
(
" D"
,
unscalePID_d
(
Kd
[
e
]));
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
}
}
#endif // PIDTEMP
#endif // PIDTEMP
#ifdef FWRETRACT
#ifdef FWRETRACT
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"
);
SERIAL_ECHOLNPGM
(
"Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
...
@@ -329,7 +566,7 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -329,7 +566,7 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M209 S"
,
(
unsigned
long
)(
autoretract_enabled
?
1
:
0
));
SERIAL_ECHOPAIR
(
" M209 S"
,
(
unsigned
long
)(
autoretract_enabled
?
1
:
0
));
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Multi-extruder settings:"
);
SERIAL_ECHOLNPGM
(
"Multi-extruder settings:"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
...
@@ -338,262 +575,33 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
...
@@ -338,262 +575,33 @@ void Config_PrintSettings() { // Always have this function, even with EEPROM_SE
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" Swap rec. addl. length (mm): "
,
retract_recover_length_swap
);
SERIAL_ECHOPAIR
(
" Swap rec. addl. length (mm): "
,
retract_recover_length_swap
);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
if
(
volumetric_enabled
)
{
if
(
volumetric_enabled
)
{
SERIAL_ECHOLNPGM
(
"Filament settings:"
);
SERIAL_ECHOLNPGM
(
"Filament settings:"
);
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M200 D"
,
filament_size
[
0
]);
SERIAL_ECHOPAIR
(
" M200 D"
,
filament_size
[
0
]);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#if EXTRUDERS > 1
#if EXTRUDERS > 1
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M200 T1 D"
,
filament_size
[
1
]);
SERIAL_ECHOPAIR
(
" M200 T1 D"
,
filament_size
[
1
]);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#if EXTRUDERS > 2
#if EXTRUDERS > 2
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M200 T2 D"
,
filament_size
[
2
]);
SERIAL_ECHOPAIR
(
" M200 T2 D"
,
filament_size
[
2
]);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#if EXTRUDERS > 3
#if EXTRUDERS > 3
SERIAL_ECHO_START
;
SERIAL_ECHO_START
;
SERIAL_ECHOPAIR
(
" M200 T3 D"
,
filament_size
[
3
]);
SERIAL_ECHOPAIR
(
" M200 T3 D"
,
filament_size
[
3
]);
SERIAL_ECHOLN
(
""
);
SERIAL_ECHOLN
(
""
);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
#endif //EXTRUDERS > 1
}
else
{
}
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
)
{
{
// version number match
SERIAL_ECHOLNPGM
(
"Filament settings: Disabled"
);
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
();
}
#ifdef EEPROM_CHITCHAT
Config_PrintSettings
();
#endif
}
#endif
void
Config_ResetDefault
()
{
//Setting default baudrate for serial
baudrate
=
BAUDRATE
;
const
static
float
tmp1
[]
=
DEFAULT_AXIS_STEPS_PER_UNIT
;
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
for
(
short
i
=
0
;
i
<
3
+
EXTRUDERS
;
i
++
)
{
axis_steps_per_unit
[
i
]
=
tmp1
[
i
];
max_feedrate
[
i
]
=
tmp2
[
i
];
max_acceleration_units_per_sq_second
[
i
]
=
tmp4
[
i
];
}
for
(
short
i
=
0
;
i
<
EXTRUDERS
;
i
++
)
{
max_retraction_feedrate
[
i
]
=
tmp3
[
i
];
#ifdef SCARA
axis_scaling
[
i
]
=
1
;
#endif
}
}
#endif //FWRETRACT
// steps per sq second need to be updated to agree with the units per sq second
reset_acceleration_rates
();
acceleration
=
DEFAULT_ACCELERATION
;
retract_acceleration
=
DEFAULT_RETRACT_ACCELERATION
;
minimumfeedrate
=
DEFAULT_MINIMUMFEEDRATE
;
minsegmenttime
=
DEFAULT_MINSEGMENTTIME
;
mintravelfeedrate
=
DEFAULT_MINTRAVELFEEDRATE
;
max_xy_jerk
=
DEFAULT_XYJERK
;
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)
#endif //EEPROM_CHITCHAT
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
calculate_volumetric_multipliers
();
SERIAL_ECHO_START
;
SERIAL_ECHOLNPGM
(
"Hardcoded Default Settings Loaded"
);
}
MarlinKimbra/Marlin_main.cpp
View file @
8ccd9f2b
...
@@ -174,11 +174,11 @@
...
@@ -174,11 +174,11 @@
// M351 - Toggle MS1 MS2 pins directly.
// M351 - Toggle MS1 MS2 pins directly.
// ************ SCARA Specific - This can change to suit future G-code regulations
// ************ SCARA Specific - This can change to suit future G-code regulations
// M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration)
// M360 - SCARA calibration: Move to cal
c
-position ThetaA (0 deg calibration)
// M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree)
// M361 - SCARA calibration: Move to cal
c
-position ThetaB (90 deg calibration - steps per degree)
// M362 - SCARA calibration: Move to cal-position PsiA (0 deg calibration)
// M362 - SCARA calibration: Move to cal
c
-position PsiA (0 deg calibration)
// M363 - SCARA calibration: Move to cal-position PsiB (90 deg calibration - steps per degree)
// M363 - SCARA calibration: Move to cal
c
-position PsiB (90 deg calibration - steps per degree)
// M364 - SCARA calibration: Move to cal-position PSIC (90 deg to Theta calibration position)
// M364 - SCARA calibration: Move to cal
c
-position PSIC (90 deg to Theta calibration position)
// M365 - SCARA calibration: Scaling factor, X, Y, Z axis
// M365 - SCARA calibration: Scaling factor, X, Y, Z axis
//************* SCARA End ***************
//************* SCARA End ***************
...
@@ -193,19 +193,7 @@
...
@@ -193,19 +193,7 @@
unsigned
long
baudrate
;
unsigned
long
baudrate
;
float
homing_feedrate
[]
=
HOMING_FEEDRATE
;
float
homing_feedrate
[]
=
HOMING_FEEDRATE
;
bool
axis_known_position
[
3
]
=
{
false
,
false
,
false
};
bool
axis_known_position
[
3
]
=
{
false
,
false
,
false
};
float
zprobe_zoffset
;
#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
bool
axis_relative_modes
[]
=
AXIS_RELATIVE_MODES
;
bool
axis_relative_modes
[]
=
AXIS_RELATIVE_MODES
;
int
feedmultiply
=
100
;
//100->1 200->2
int
feedmultiply
=
100
;
//100->1 200->2
int
saved_feedmultiply
;
int
saved_feedmultiply
;
...
@@ -278,6 +266,13 @@ float add_homing[3]={ 0, 0, 0 };
...
@@ -278,6 +266,13 @@ float add_homing[3]={ 0, 0, 0 };
};
};
float
delta
[
3
]
=
{
0.0
,
0.0
,
0.0
};
float
delta
[
3
]
=
{
0.0
,
0.0
,
0.0
};
float
delta_tmp
[
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
#endif // DELTA
float
min_pos
[
3
]
=
{
X_MIN_POS
,
Y_MIN_POS
,
Z_MIN_POS
};
float
min_pos
[
3
]
=
{
X_MIN_POS
,
Y_MIN_POS
,
Z_MIN_POS
};
...
@@ -922,7 +917,6 @@ void get_command()
...
@@ -922,7 +917,6 @@ void get_command()
#endif //SDSUPPORT
#endif //SDSUPPORT
}
}
float
code_value
()
float
code_value
()
{
{
return
(
strtod
(
&
cmdbuffer
[
bufindr
][
strchr_pointer
-
cmdbuffer
[
bufindr
]
+
1
],
NULL
));
return
(
strtod
(
&
cmdbuffer
[
bufindr
][
strchr_pointer
-
cmdbuffer
[
bufindr
]
+
1
],
NULL
));
...
@@ -2299,7 +2293,6 @@ void gcode_G28()
...
@@ -2299,7 +2293,6 @@ void gcode_G28()
endstops_hit_on_purpose
();
endstops_hit_on_purpose
();
}
}
#ifdef ENABLE_AUTO_BED_LEVELING
#ifdef ENABLE_AUTO_BED_LEVELING
// G29: Detailed Z-Probe, probes the bed at 3 or more points.
// G29: Detailed Z-Probe, probes the bed at 3 or more points.
// Will fail if the printer has not been homed with G28.
// Will fail if the printer has not been homed with G28.
...
@@ -2493,7 +2486,6 @@ void gcode_G28()
...
@@ -2493,7 +2486,6 @@ void gcode_G28()
#endif //Z_PROBE_SLED
#endif //Z_PROBE_SLED
#endif //ENABLE_AUTO_BED_LEVELING
#endif //ENABLE_AUTO_BED_LEVELING
#ifdef DELTA
#ifdef DELTA
// G29: Delta Z-Probe, probes the bed at more points.
// G29: Delta Z-Probe, probes the bed at more points.
void
gcode_G29
()
void
gcode_G29
()
...
@@ -3102,139 +3094,15 @@ void gcode_G92()
...
@@ -3102,139 +3094,15 @@ void gcode_G92()
}
}
}
}
#ifdef ULTIPANEL
// Process Commands and dispatch them to handlers
// M0: Unconditional stop - Wait for user button press on LCD
void
process_commands
()
// M1: Conditional stop - Wait for user button press on LCD
{
void
gcode_M0_M1
()
{
unsigned
long
codenum
;
//throw away variable
unsigned
long
codenum
;
//throw away variable
char
*
starpos
=
NULL
;
char
*
starpos
=
NULL
;
if
(
code_seen
(
'G'
))
{
switch
((
int
)
code_value
())
{
//G0 -> G1
case
0
:
case
1
:
{
gcode_G0_G1
();
}
break
;
//G2, G3
#ifndef SCARA
case
2
:
//G2 - CW ARC
{
gcode_G2_G3
(
true
);
}
break
;
case
3
:
//G3 - CCW ARC
{
gcode_G2_G3
(
false
);
}
break
;
#endif
//G4 Dwell
case
4
:
{
gcode_G4
();
}
break
;
#ifdef FWRETRACT
case
10
:
//G10: retract
{
gcode_G10_G11
(
true
);
}
break
;
case
11
:
//G11: retract_recover
{
gcode_G10_G11
(
false
);
}
break
;
#endif //FWRETRACT
case
28
:
//G28: Home all axes, one at a time
{
gcode_G28
();
}
break
;
#ifdef ENABLE_AUTO_BED_LEVELING
case
29
:
// G29 Detailed Z-Probe, probes the bed at 3 or more points.
{
gcode_G29
();
}
break
;
#ifndef Z_PROBE_SLED
case
30
:
// G30 Single Z Probe
{
gcode_G30
();
}
break
;
#else // Z_PROBE_SLED
case
31
:
// G31: dock the sled
{
dock_sled
(
true
);
}
break
;
case
32
:
// G32: undock the sled
{
dock_sled
(
false
);
}
break
;
#endif // Z_PROBE_SLED
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef DELTA
case
29
:
// G29 Detailed Z-Probe, probes the bed at more points.
{
gcode_G29
();
}
break
;
case
30
:
// G30 Delta AutoCalibration
{
gcode_G30
();
}
break
;
#endif //DELTA
case
60
:
// G60 Store in memory actual position
{
gcode_G60
();
}
break
;
case
61
:
// G61 move to X Y Z in memory
{
gcode_G61
();
}
break
;
case
90
:
// G90
{
relative_mode
=
false
;
}
break
;
case
91
:
// G91
{
relative_mode
=
true
;
}
break
;
case
92
:
// G92
{
gcode_G92
();
}
break
;
}
}
else
if
(
code_seen
(
'M'
))
{
switch
((
int
)
code_value
())
{
#ifdef ULTIPANEL
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
;
char
*
src
=
strchr_pointer
+
2
;
codenum
=
0
;
codenum
=
0
;
bool
hasP
=
false
,
hasS
=
false
;
bool
hasP
=
false
,
hasS
=
false
;
if
(
code_seen
(
'P'
))
if
(
code_seen
(
'P'
))
...
@@ -3287,285 +3155,100 @@ void process_commands()
...
@@ -3287,285 +3155,100 @@ void process_commands()
else
else
LCD_MESSAGEPGM
(
WELCOME_MSG
);
LCD_MESSAGEPGM
(
WELCOME_MSG
);
}
}
break
;
#endif //ULTIPANEL
#endif //ULTIPANEL
#ifdef LASERBEAM
#ifdef LASERBEAM
case
3
:
// M03 S - Setting laser beam
// M3: S - Setting laser beam
void
gcode_M3
()
{
{
if
(
code_seen
(
'S'
))
if
(
code_seen
(
'S'
))
{
{
laser_ttl_modulation
=
constrain
(
code_value
(),
0
,
255
);
laser_ttl_modulation
=
constrain
(
code_value
(),
0
,
255
);
}
}
else
else
{
{
laser_ttl_modulation
=
0
;
laser_ttl_modulation
=
0
;
}
}
}
}
break
;
// M4: Turn on laser beam
case
4
:
// M04 - Turn on laser beam
void
gcode_M4
()
{
{
WRITE
(
LASER_PWR_PIN
,
HIGH
);
WRITE
(
LASER_PWR_PIN
,
HIGH
);
laser_ttl_modulation
=
0
;
laser_ttl_modulation
=
0
;
}
}
break
;
// M5: Turn off laser beam
case
5
:
// M05 - Turn off laser beam
void
gcode_M5
()
{
{
WRITE
(
LASER_PWR_PIN
,
LOW
);
WRITE
(
LASER_PWR_PIN
,
LOW
);
laser_ttl_modulation
=
0
;
laser_ttl_modulation
=
0
;
}
}
break
;
#endif //LASERBEAM
#endif //LASERBEAM
case
17
:
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
//M49: Z-Probe repeatability
void
gcode_M49
()
{
{
LCD_MESSAGEPGM
(
MSG_NO_MOVE
);
#if Z_MIN_PIN == -1
enable_x
();
#error "You must have a Z_MIN endstop in order to enable calculation of Z-Probe repeatability."
enable_y
();
#endif
enable_z
();
enable_e0
();
enable_e1
();
enable_e2
();
enable_e3
();
}
break
;
#ifdef SDSUPPORT
double
sum
=
0.0
,
mean
=
0.0
,
sigma
=
0.0
;
case
20
:
//M20 - list SD card
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'
))
{
{
SERIAL_PROTOCOLLNPGM
(
MSG_BEGIN_FILE_LIST
);
verbose_level
=
code_value
();
card
.
ls
();
if
(
verbose_level
<
0
||
verbose_level
>
4
)
SERIAL_PROTOCOLLNPGM
(
MSG_END_FILE_LIST
);
}
break
;
case
21
:
//M21 - init SD card
{
{
card
.
initsd
();
SERIAL_PROTOCOLPGM
(
"?Verbose Level not plausible.
\n
"
);
return
;
}
}
break
;
case
22
:
//M22 - release SD card
{
card
.
release
();
}
}
break
;
case
23
:
//M23 - Select file
if
(
verbose_level
>
0
)
{
{
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
SERIAL_PROTOCOLPGM
(
"M49 Z-Probe Repeatability test. Version 2.00
\n
"
);
if
(
starpos
!=
NULL
)
*
(
starpos
)
=
'\0'
;
SERIAL_PROTOCOLPGM
(
"Full support at: http://3dprintboard.com/forum.php
\n
"
);
card
.
openFile
(
strchr_pointer
+
4
,
true
);
}
}
break
;
case
24
:
//M24 - Start SD print
if
(
code_seen
(
'n'
))
{
{
card
.
startFileprint
();
n_samples
=
code_value
();
starttime
=
millis
();
if
(
n_samples
<
4
||
n_samples
>
50
)
}
break
;
case
25
:
//M25 - Pause SD print
{
{
card
.
pauseSDPrint
();
SERIAL_PROTOCOLPGM
(
"?Specified sample size not plausable.
\n
"
);
return
;
}
}
break
;
}
case
26
:
//M26 - Set SD index
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'
))
{
{
if
(
card
.
cardOK
&&
code_seen
(
'S'
))
X_probe_location
=
code_value
()
-
X_PROBE_OFFSET_FROM_EXTRUDER
;
if
(
X_probe_location
<
X_MIN_POS
||
X_probe_location
>
X_MAX_POS
)
{
{
card
.
setIndex
(
code_value_long
()
);
SERIAL_PROTOCOLPGM
(
"?Specified X position out of range.
\n
"
);
}
return
;
}
}
break
;
case
27
:
//M27 - Get SD status
{
card
.
getStatus
();
}
}
break
;
case
28
:
//M28 - Start SD write
if
(
code_seen
(
'Y'
)
||
code_seen
(
'y'
))
{
{
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
Y_probe_location
=
code_value
()
-
Y_PROBE_OFFSET_FROM_EXTRUDER
;
if
(
starpos
!=
NULL
)
if
(
Y_probe_location
<
Y_MIN_POS
||
Y_probe_location
>
Y_MAX_POS
)
{
char
*
npos
=
strchr
(
cmdbuffer
[
bufindr
],
'N'
);
strchr_pointer
=
strchr
(
npos
,
' '
)
+
1
;
*
(
starpos
)
=
'\0'
;
}
card
.
openFile
(
strchr_pointer
+
4
,
false
);
}
break
;
case
29
:
//M29 - Stop SD write
{
//processed in write to file routine above
//card,saving = false;
}
break
;
case
30
:
//M30 <filename> Delete File
{
if
(
card
.
cardOK
)
{
card
.
closefile
();
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
if
(
starpos
!=
NULL
)
{
char
*
npos
=
strchr
(
cmdbuffer
[
bufindr
],
'N'
);
strchr_pointer
=
strchr
(
npos
,
' '
)
+
1
;
*
(
starpos
)
=
'\0'
;
}
card
.
removeFile
(
strchr_pointer
+
4
);
}
}
break
;
case
32
:
//M32 - Select file and start SD print
{
if
(
card
.
sdprinting
)
{
st_synchronize
();
}
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
char
*
namestartpos
=
(
strchr
(
strchr_pointer
+
4
,
'!'
));
//find ! to indicate filename string start.
if
(
namestartpos
==
NULL
)
{
namestartpos
=
strchr_pointer
+
4
;
//default name position, 4 letters after the M
}
else
{
namestartpos
++
;
//to skip the '!'
}
if
(
starpos
!=
NULL
)
*
(
starpos
)
=
'\0'
;
bool
call_procedure
=
(
code_seen
(
'P'
));
if
(
strchr_pointer
>
namestartpos
)
call_procedure
=
false
;
//false alert, 'P' found within filename
if
(
card
.
cardOK
)
{
card
.
openFile
(
namestartpos
,
true
,
!
call_procedure
);
if
(
code_seen
(
'S'
))
if
(
strchr_pointer
<
namestartpos
)
//only if "S" is occurring _before_ the filename
card
.
setIndex
(
code_value_long
());
card
.
startFileprint
();
if
(
!
call_procedure
)
starttime
=
millis
();
//procedure calls count as normal print time.
}
}
break
;
case
928
:
//M928 - Start SD write
{
starpos
=
(
strchr
(
strchr_pointer
+
5
,
'*'
));
if
(
starpos
!=
NULL
){
char
*
npos
=
strchr
(
cmdbuffer
[
bufindr
],
'N'
);
strchr_pointer
=
strchr
(
npos
,
' '
)
+
1
;
*
(
starpos
)
=
'\0'
;
}
card
.
openLogFile
(
strchr_pointer
+
5
);
}
break
;
#endif //SDSUPPORT
case
31
:
//M31 take time since the start of the SD print or an M109 command
{
stoptime
=
millis
();
char
time
[
30
];
unsigned
long
t
=
(
stoptime
-
starttime
)
/
1000
;
int
sec
,
min
;
min
=
t
/
60
;
sec
=
t
%
60
;
sprintf_P
(
time
,
PSTR
(
"%i min, %i sec"
),
min
,
sec
);
SERIAL_ECHO_START
;
SERIAL_ECHOLN
(
time
);
lcd_setstatus
(
time
);
autotempShutdown
();
}
break
;
case
42
:
//M42 -Change pin status via gcode
{
if
(
code_seen
(
'S'
))
{
int
pin_status
=
code_value
();
int
pin_number
=
LED_PIN
;
if
(
code_seen
(
'P'
)
&&
pin_status
>=
0
&&
pin_status
<=
255
)
pin_number
=
code_value
();
for
(
int8_t
i
=
0
;
i
<
(
int8_t
)(
sizeof
(
sensitive_pins
)
/
sizeof
(
int
));
i
++
)
{
if
(
sensitive_pins
[
i
]
==
pin_number
)
{
pin_number
=
-
1
;
break
;
}
}
#if defined(FAN_PIN) && FAN_PIN > -1
if
(
pin_number
==
FAN_PIN
)
fanSpeed
=
pin_status
;
#endif
if
(
pin_number
>
-
1
)
{
pinMode
(
pin_number
,
OUTPUT
);
digitalWrite
(
pin_number
,
pin_status
);
analogWrite
(
pin_number
,
pin_status
);
}
}
}
break
;
#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
"
);
SERIAL_PROTOCOLPGM
(
"?Specified Y position out of range.
\n
"
);
break
;
return
;
}
}
}
}
...
@@ -3576,7 +3259,7 @@ void process_commands()
...
@@ -3576,7 +3259,7 @@ void process_commands()
if
(
n_legs
<
0
||
n_legs
>
15
)
if
(
n_legs
<
0
||
n_legs
>
15
)
{
{
SERIAL_PROTOCOLPGM
(
"?Specified number of legs in movement not plausible.
\n
"
);
SERIAL_PROTOCOLPGM
(
"?Specified number of legs in movement not plausible.
\n
"
);
break
;
return
;
}
}
}
}
...
@@ -3620,10 +3303,7 @@ void process_commands()
...
@@ -3620,10 +3303,7 @@ void process_commands()
current_position
[
Z_AXIS
]
=
Z_current
=
st_get_position_mm
(
Z_AXIS
);
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
;
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
,
plan_buffer_line
(
X_probe_location
,
Y_probe_location
,
Z_start_location
,
ext_position
,
homing_feedrate
[
X_AXIS
]
/
60
,
active_extruder
,
active_driver
);
ext_position
,
homing_feedrate
[
X_AXIS
]
/
60
,
active_extruder
,
active_driver
);
st_synchronize
();
st_synchronize
();
current_position
[
Z_AXIS
]
=
Z_current
=
st_get_position_mm
(
Z_AXIS
);
current_position
[
Z_AXIS
]
=
Z_current
=
st_get_position_mm
(
Z_AXIS
);
...
@@ -3648,110 +3328,571 @@ void process_commands()
...
@@ -3648,110 +3328,571 @@ void process_commands()
for
(
l
=
0
;
l
<
n_legs
-
1
;
l
++
)
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
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
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
);
radius
+=
(
float
)
(
((
long
)
((
unsigned
long
)
millis
()
%
(
long
)
10
))
-
5
);
if
(
radius
<
0.0
)
radius
=
-
radius
;
if
(
radius
<
0.0
)
radius
=
-
radius
;
X_current
=
X_probe_location
+
cos
(
theta
)
*
radius
;
X_current
=
X_probe_location
+
cos
(
theta
)
*
radius
;
Y_current
=
Y_probe_location
+
sin
(
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_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
(
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_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
(
Y_current
>
Y_MAX_POS
)
Y_current
=
Y_MAX_POS
;
if
(
verbose_level
>
3
)
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
()
{
unsigned
long
codenum
;
//throw away variable
char
*
starpos
=
NULL
;
if
(
code_seen
(
'G'
))
{
switch
((
int
)
code_value
())
{
//G0 -> G1
case
0
:
case
1
:
{
gcode_G0_G1
();
}
break
;
//G2, G3
#ifndef SCARA
case
2
:
//G2 - CW ARC
{
gcode_G2_G3
(
true
);
}
break
;
case
3
:
//G3 - CCW ARC
{
gcode_G2_G3
(
false
);
}
break
;
#endif
//G4 Dwell
case
4
:
{
gcode_G4
();
}
break
;
#ifdef FWRETRACT
case
10
:
//G10: retract
{
gcode_G10_G11
(
true
);
}
break
;
case
11
:
//G11: retract_recover
{
gcode_G10_G11
(
false
);
}
break
;
#endif //FWRETRACT
case
28
:
//G28: Home all axes, one at a time
{
gcode_G28
();
}
break
;
#ifdef ENABLE_AUTO_BED_LEVELING
case
29
:
// G29 Detailed Z-Probe, probes the bed at 3 or more points.
{
gcode_G29
();
}
break
;
#ifndef Z_PROBE_SLED
case
30
:
// G30 Single Z Probe
{
gcode_G30
();
}
break
;
#else // Z_PROBE_SLED
case
31
:
// G31: dock the sled
{
dock_sled
(
true
);
}
break
;
case
32
:
// G32: undock the sled
{
dock_sled
(
false
);
}
break
;
#endif // Z_PROBE_SLED
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef DELTA
case
29
:
// G29 Detailed Z-Probe, probes the bed at more points.
{
gcode_G29
();
}
break
;
case
30
:
// G30 Delta AutoCalibration
{
gcode_G30
();
}
break
;
#endif //DELTA
case
60
:
// G60 Store in memory actual position
{
gcode_G60
();
}
break
;
case
61
:
// G61 move to X Y Z in memory
{
gcode_G61
();
}
break
;
case
90
:
// G90
{
relative_mode
=
false
;
}
break
;
case
91
:
// G91
{
relative_mode
=
true
;
}
break
;
case
92
:
// G92
{
gcode_G92
();
}
break
;
}
}
else
if
(
code_seen
(
'M'
))
{
switch
((
int
)
code_value
())
{
#ifdef ULTIPANEL
case
0
:
//M0 - Unconditional stop - Wait for user button press on LCD
case
1
:
//M1 - Conditional stop - Wait for user button press on LCD
{
gcode_M0_M1
();
}
break
;
#endif //ULTIPANEL
#ifdef LASERBEAM
case
3
:
// M03 S - Setting laser beam
{
gcode_M3
();
}
break
;
case
4
:
// M04 - Turn on laser beam
{
gcode_M4
();
}
break
;
case
5
:
// M05 - Turn off laser beam
{
gcode_M5
();
}
break
;
#endif //LASERBEAM
case
17
:
//M17 - Enable/Power all stepper motors
{
LCD_MESSAGEPGM
(
MSG_NO_MOVE
);
enable_x
();
enable_y
();
enable_z
();
enable_e0
();
enable_e1
();
enable_e2
();
enable_e3
();
}
break
;
#ifdef SDSUPPORT
case
20
:
//M20 - list SD card
{
SERIAL_PROTOCOLLNPGM
(
MSG_BEGIN_FILE_LIST
);
card
.
ls
();
SERIAL_PROTOCOLLNPGM
(
MSG_END_FILE_LIST
);
}
break
;
case
21
:
//M21 - init SD card
{
card
.
initsd
();
}
break
;
case
22
:
//M22 - release SD card
{
card
.
release
();
}
break
;
case
23
:
//M23 - Select file
{
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
if
(
starpos
!=
NULL
)
*
(
starpos
)
=
'\0'
;
card
.
openFile
(
strchr_pointer
+
4
,
true
);
}
break
;
case
24
:
//M24 - Start SD print
{
card
.
startFileprint
();
starttime
=
millis
();
}
break
;
case
25
:
//M25 - Pause SD print
{
card
.
pauseSDPrint
();
}
break
;
case
26
:
//M26 - Set SD index
{
if
(
card
.
cardOK
&&
code_seen
(
'S'
))
{
card
.
setIndex
(
code_value_long
());
}
}
break
;
case
27
:
//M27 - Get SD status
{
card
.
getStatus
();
}
break
;
case
28
:
//M28 - Start SD write
{
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
if
(
starpos
!=
NULL
)
{
char
*
npos
=
strchr
(
cmdbuffer
[
bufindr
],
'N'
);
strchr_pointer
=
strchr
(
npos
,
' '
)
+
1
;
*
(
starpos
)
=
'\0'
;
}
card
.
openFile
(
strchr_pointer
+
4
,
false
);
}
break
;
case
29
:
//M29 - Stop SD write
{
//processed in write to file routine above
//card,saving = false;
}
break
;
case
30
:
//M30 <filename> Delete File
{
if
(
card
.
cardOK
)
{
{
SERIAL_ECHOPAIR
(
"x: "
,
X_current
);
card
.
closefile
();
SERIAL_ECHOPAIR
(
"y: "
,
Y_current
);
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
SERIAL_PROTOCOLLNPGM
(
""
);
if
(
starpos
!=
NULL
)
{
char
*
npos
=
strchr
(
cmdbuffer
[
bufindr
],
'N'
);
strchr_pointer
=
strchr
(
npos
,
' '
)
+
1
;
*
(
starpos
)
=
'\0'
;
}
}
card
.
removeFile
(
strchr_pointer
+
4
);
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
}
}
break
;
if
(
engage_probe_for_each_reading
)
case
32
:
//M32 - Select file and start SD print
{
{
engage_z_probe
();
if
(
card
.
sdprinting
)
delay
(
1000
);
{
st_synchronize
();
}
}
starpos
=
(
strchr
(
strchr_pointer
+
4
,
'*'
));
setup_for_endstop_move
();
char
*
namestartpos
=
(
strchr
(
strchr_pointer
+
4
,
'!'
));
//find ! to indicate filename string start.
run_z_probe
();
if
(
namestartpos
==
NULL
)
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
];
namestartpos
=
strchr_pointer
+
4
;
//default name position, 4 letters after the M
}
}
mean
=
sum
/
(
double
(
n
+
1
));
else
//
// 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
);
namestartpos
++
;
//to skip the '!'
}
}
sigma
=
sqrt
(
sum
/
(
double
(
n
+
1
)));
if
(
starpos
!=
NULL
)
*
(
starpos
)
=
'\0'
;
bool
call_procedure
=
(
code_seen
(
'P'
));
if
(
verbose_level
>
1
)
if
(
strchr_pointer
>
namestartpos
)
call_procedure
=
false
;
//false alert, 'P' found within filename
if
(
card
.
cardOK
)
{
{
SERIAL_PROTOCOL
(
n
+
1
);
card
.
openFile
(
namestartpos
,
true
,
!
call_procedure
);
SERIAL_PROTOCOL
(
" of "
);
if
(
code_seen
(
'S'
))
SERIAL_PROTOCOL
(
n_samples
);
if
(
strchr_pointer
<
namestartpos
)
//only if "S" is occurring _before_ the filename
SERIAL_PROTOCOLPGM
(
" z: "
);
card
.
setIndex
(
code_value_long
());
SERIAL_PROTOCOL_F
(
current_position
[
Z_AXIS
],
6
);
card
.
startFileprint
();
if
(
!
call_procedure
)
starttime
=
millis
();
//procedure calls count as normal print time.
}
}
}
if
(
verbose_level
>
2
)
break
;
case
928
:
//M928 - Start SD write
{
{
SERIAL_PROTOCOL
(
" mean: "
);
starpos
=
(
strchr
(
strchr_pointer
+
5
,
'*'
));
SERIAL_PROTOCOL_F
(
mean
,
6
);
if
(
starpos
!=
NULL
){
SERIAL_PROTOCOL
(
" sigma: "
);
char
*
npos
=
strchr
(
cmdbuffer
[
bufindr
],
'N'
);
SERIAL_PROTOCOL_F
(
sigma
,
6
);
strchr_pointer
=
strchr
(
npos
,
' '
)
+
1
;
*
(
starpos
)
=
'\0'
;
}
}
card
.
openLogFile
(
strchr_pointer
+
5
);
}
break
;
#endif //SDSUPPORT
if
(
verbose_level
>
0
)
SERIAL_PROTOCOLPGM
(
"
\n
"
);
case
31
:
//M31 take time since the start of the SD print or an M109 command
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
();
stoptime
=
millis
();
delay
(
1000
);
char
time
[
30
];
unsigned
long
t
=
(
stoptime
-
starttime
)
/
1000
;
int
sec
,
min
;
min
=
t
/
60
;
sec
=
t
%
60
;
sprintf_P
(
time
,
PSTR
(
"%i min, %i sec"
),
min
,
sec
);
SERIAL_ECHO_START
;
SERIAL_ECHOLN
(
time
);
lcd_setstatus
(
time
);
autotempShutdown
();
}
break
;
case
42
:
//M42 -Change pin status via gcode
{
if
(
code_seen
(
'S'
))
{
int
pin_status
=
code_value
();
int
pin_number
=
LED_PIN
;
if
(
code_seen
(
'P'
)
&&
pin_status
>=
0
&&
pin_status
<=
255
)
pin_number
=
code_value
();
for
(
int8_t
i
=
0
;
i
<
(
int8_t
)(
sizeof
(
sensitive_pins
)
/
sizeof
(
int
));
i
++
)
{
if
(
sensitive_pins
[
i
]
==
pin_number
)
{
pin_number
=
-
1
;
break
;
}
}
}
}
#if defined(FAN_PIN) && FAN_PIN > -1
retract_z_probe
();
if
(
pin_number
==
FAN_PIN
)
fanSpeed
=
pin_status
;
delay
(
1000
);
#endif
if
(
pin_number
>
-
1
)
clean_up_after_endstop_move
();
if
(
verbose_level
>
0
)
{
{
SERIAL_PROTOCOLPGM
(
"Mean: "
);
pinMode
(
pin_number
,
OUTPUT
);
SERIAL_PROTOCOL_F
(
mean
,
6
);
digitalWrite
(
pin_number
,
pin_status
);
SERIAL_PROTOCOLPGM
(
"
\n
"
);
analogWrite
(
pin_number
,
pin_status
);
}
}
}
}
break
;
SERIAL_PROTOCOLPGM
(
"Standard Deviation: "
);
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
SERIAL_PROTOCOL_F
(
sigma
,
6
);
case
49
:
//M49 Z-Probe repeatability
SERIAL_PROTOCOLPGM
(
"
\n\n
"
);
{
gcode_M49
();
}
}
break
;
break
;
#endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
#endif //defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
...
@@ -4276,7 +4417,7 @@ void process_commands()
...
@@ -4276,7 +4417,7 @@ void process_commands()
#endif
#endif
}
}
break
;
break
;
//TODO: update for all axis, use for loop
#ifdef BLINKM
#ifdef BLINKM
case
150
:
//M150
case
150
:
//M150
{
{
...
@@ -4292,6 +4433,7 @@ void process_commands()
...
@@ -4292,6 +4433,7 @@ void process_commands()
}
}
break
;
break
;
#endif //BLINKM
#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).
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
;
tmp_extruder
=
active_extruder
;
...
@@ -4338,186 +4480,64 @@ void process_commands()
...
@@ -4338,186 +4480,64 @@ void process_commands()
//reserved for setting filament diameter via UFID or filament measuring device
//reserved for setting filament diameter via UFID or filament measuring device
break
;
break
;
}
}
calculate_volumetric_multipliers
();
calculate_volumetric_multipliers
();
}
break
;
case
201
:
//M201
{
for
(
int8_t
i
=
0
;
i
<
NUM_AXIS
;
i
++
)
{
if
(
code_seen
(
axis_codes
[
i
]))
{
max_acceleration_units_per_sq_second
[
i
]
=
code_value
();
}
}
// 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
();
}
break
;
case
203
:
//M203 max feedrate mm/sec
{
for
(
int8_t
i
=
0
;
i
<
NUM_AXIS
;
i
++
)
{
if
(
code_seen
(
axis_codes
[
i
]))
max_feedrate
[
i
]
=
code_value
();
}
}
break
;
case
204
:
//M204 acceleration S normal moves T filament only moves
{
if
(
code_seen
(
'S'
))
acceleration
=
code_value
()
;
if
(
code_seen
(
'T'
))
retract_acceleration
=
code_value
()
;
}
break
;
case
205
:
//M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
{
if
(
code_seen
(
'S'
))
minimumfeedrate
=
code_value
();
if
(
code_seen
(
'T'
))
mintravelfeedrate
=
code_value
();
if
(
code_seen
(
'B'
))
minsegmenttime
=
code_value
()
;
if
(
code_seen
(
'X'
))
max_xy_jerk
=
code_value
()
;
if
(
code_seen
(
'Z'
))
max_z_jerk
=
code_value
()
;
if
(
code_seen
(
'E'
))
max_e_jerk
=
code_value
()
;
}
break
;
case
206
:
//M206 additional homing offset
{
for
(
int8_t
i
=
0
;
i
<
3
;
i
++
)
{
if
(
code_seen
(
axis_codes
[
i
]))
add_homing
[
i
]
=
code_value
();
}
#ifdef SCARA
if
(
code_seen
(
'T'
))
// Theta
{
add_homing
[
X_AXIS
]
=
code_value
()
;
}
if
(
code_seen
(
'P'
))
// Psi
{
add_homing
[
Y_AXIS
]
=
code_value
()
;
}
#endif
}
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'
))
break
;
case
201
:
//M201
{
{
tower_adj
[
2
]
=
code_value
();
for
(
int8_t
i
=
0
;
i
<
NUM_AXIS
;
i
++
)
set_delta_constants
();
}
if
(
code_seen
(
'I'
))
{
{
tower_adj
[
3
]
=
code_value
();
if
(
code_seen
(
axis_codes
[
i
]))
set_delta_constants
();
}
if
(
code_seen
(
'J'
))
{
{
tower_adj
[
4
]
=
code_value
();
max_acceleration_units_per_sq_second
[
i
]
=
code_value
();
set_delta_constants
();
}
}
if
(
code_seen
(
'K'
))
{
tower_adj
[
5
]
=
code_value
();
set_delta_constants
();
}
}
if
(
code_seen
(
'R'
))
// 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
();
delta_radius
=
code_value
();
set_delta_constants
();
}
}
if
(
code_seen
(
'D'
))
break
;
case
203
:
//M203 max feedrate mm/sec
{
{
delta_diagonal_rod
=
code_value
();
for
(
int8_t
i
=
0
;
i
<
NUM_AXIS
;
i
++
)
set_delta_constants
();
}
if
(
code_seen
(
'H'
))
{
{
max_pos
[
Z_AXIS
]
=
code_value
();
if
(
code_seen
(
axis_codes
[
i
]))
max_feedrate
[
i
]
=
code_value
();
set_delta_constants
();
}
}
if
(
code_seen
(
'P'
))
}
break
;
case
204
:
//M204 acceleration S normal moves T filament only moves
{
{
float
pz
=
code_value
();
if
(
code_seen
(
'S'
))
acceleration
=
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
if
(
code_seen
(
'T'
))
retract_acceleration
=
code_value
()
;
}
break
;
case
205
:
//M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
{
{
z_probe_offset
[
Z_AXIS
]
=
pz
;
if
(
code_seen
(
'S'
))
minimumfeedrate
=
code_value
();
if
(
code_seen
(
'T'
))
mintravelfeedrate
=
code_value
();
if
(
code_seen
(
'B'
))
minsegmenttime
=
code_value
()
;
if
(
code_seen
(
'X'
))
max_xy_jerk
=
code_value
()
;
if
(
code_seen
(
'Z'
))
max_z_jerk
=
code_value
()
;
if
(
code_seen
(
'E'
))
max_e_jerk
=
code_value
()
;
}
}
else
break
;
case
206
:
//M206 additional homing offset
{
{
for
(
int8_t
i
=
0
;
i
<
3
;
i
++
)
for
(
int8_t
i
=
0
;
i
<
3
;
i
++
)
{
{
if
(
code_seen
(
axis_codes
[
i
]))
z_probe_offset
[
i
]
=
code_value
();
if
(
code_seen
(
axis_codes
[
i
]))
add_homing
[
i
]
=
code_value
();
}
}
}
#ifdef SCARA
if
(
code_seen
(
'T'
))
// Theta
{
add_homing
[
X_AXIS
]
=
code_value
()
;
}
}
if
(
code_seen
(
'L'
))
if
(
code_seen
(
'P'
))
// Psi
{
{
SERIAL_ECHOLN
(
"Current Delta geometry values:"
);
add_homing
[
Y_AXIS
]
=
code_value
()
;
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
}
}
break
;
break
;
#endif //Delta
#ifdef FWRETRACT
#ifdef FWRETRACT
case
207
:
//M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop]
case
207
:
//M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop]
...
@@ -4706,6 +4726,46 @@ void process_commands()
...
@@ -4706,6 +4726,46 @@ void process_commands()
}
}
}
}
break
;
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
#if NUM_SERVOS > 0
case
280
:
//M280 - set servo position absolute. P: servo index, S: angle or microseconds
case
280
:
//M280 - set servo position absolute. P: servo index, S: angle or microseconds
...
@@ -4810,6 +4870,16 @@ void process_commands()
...
@@ -4810,6 +4870,16 @@ void process_commands()
break
;
break
;
#endif //PIDTEMP
#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
#ifdef PIDTEMPBED
case
304
:
// M304
case
304
:
// M304
{
{
...
@@ -4829,56 +4899,7 @@ void process_commands()
...
@@ -4829,56 +4899,7 @@ void process_commands()
}
}
break
;
break
;
#endif //PIDTEMPBED
#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
case
303
:
//M303 PID autotune
{
{
float
temp
=
150.0
;
float
temp
=
150.0
;
...
@@ -4891,6 +4912,34 @@ void process_commands()
...
@@ -4891,6 +4912,34 @@ void process_commands()
PID_autotune
(
temp
,
e
,
c
);
PID_autotune
(
temp
,
e
,
c
);
}
}
break
;
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
#ifdef SCARA
case
360
:
//M360 SCARA Theta pos1
case
360
:
//M360 SCARA Theta pos1
...
@@ -5338,6 +5387,14 @@ void process_commands()
...
@@ -5338,6 +5387,14 @@ void process_commands()
break
;
break
;
#endif //DUAL_X_CARRIAGE
#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.
case
907
:
// M907 Set digital trim pot motor current using axis codes.
{
{
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
...
@@ -5372,34 +5429,6 @@ void process_commands()
...
@@ -5372,34 +5429,6 @@ void process_commands()
#endif // DIGIPOTSS_PIN
#endif // DIGIPOTSS_PIN
}
}
break
;
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
#ifdef NPR2
case
997
:
// M997 Cxx Move Carter xx gradi
case
997
:
// M997 Cxx Move Carter xx gradi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment