Commit b0afb3e3 authored by MagoKimbra's avatar MagoKimbra

Update more fuction

parent 4c81e56a
......@@ -75,6 +75,11 @@
// This is used for single nozzle and multiple extrusion configuration
// Uncomment below to enable (One Hotend)
//#define SINGLENOZZLE
#ifdef SINGLENOZZLE
#define HOTENDS 1
#else
#define HOTENDS EXTRUDERS
#endif
/***********************************************************************
*********************** Multiextruder MKR4 ***************************
......
......@@ -63,10 +63,10 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, max_xy_jerk);
EEPROM_WRITE_VAR(i, max_z_jerk);
EEPROM_WRITE_VAR(i, max_e_jerk);
EEPROM_WRITE_VAR(i, add_homing);
EEPROM_WRITE_VAR(i, home_offset);
EEPROM_WRITE_VAR(i, zprobe_zoffset);
#if EXTRUDERS > 1 && !defined SINGLENOZZLE
#if HOTENDS > 1
EEPROM_WRITE_VAR(i, hotend_offset);
#endif
......@@ -150,39 +150,39 @@ void Config_RetrieveSettings()
if (strncmp(ver,stored_ver,3) == 0)
{
// version number match
EEPROM_READ_VAR(i,baudrate);
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);
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, acceleration);
EEPROM_READ_VAR(i, retract_acceleration);
EEPROM_READ_VAR(i, travel_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);
#if EXTRUDERS > 1 && !defined SINGLENOZZLE
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, home_offset);
EEPROM_READ_VAR(i, zprobe_zoffset);
#if HOTENDS > 1
EEPROM_READ_VAR(i, hotend_offset);
#endif
#ifdef DELTA
EEPROM_READ_VAR(i,endstop_adj);
EEPROM_READ_VAR(i,delta_radius);
EEPROM_READ_VAR(i,delta_diagonal_rod);
EEPROM_READ_VAR(i,max_pos);
EEPROM_READ_VAR(i,tower_adj);
EEPROM_READ_VAR(i,z_probe_offset);
EEPROM_READ_VAR(i, endstop_adj);
EEPROM_READ_VAR(i, delta_radius);
EEPROM_READ_VAR(i, delta_diagonal_rod);
EEPROM_READ_VAR(i, max_pos);
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
......@@ -193,46 +193,46 @@ void Config_RetrieveSettings()
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);
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);
EEPROM_READ_VAR(i, Kp);
EEPROM_READ_VAR(i, Ki);
EEPROM_READ_VAR(i, Kd);
#endif // PIDTEMP
#if !defined(DOGLCD) || LCD_CONTRAST < 0
int lcd_contrast;
#endif //DOGLCD
EEPROM_READ_VAR(i,lcd_contrast);
EEPROM_READ_VAR(i, lcd_contrast);
#ifdef SCARA
EEPROM_READ_VAR(i,axis_scaling);
EEPROM_READ_VAR(i, axis_scaling);
#endif //SCARA
#ifdef FWRETRACT
EEPROM_READ_VAR(i,autoretract_enabled);
EEPROM_READ_VAR(i,retract_length);
EEPROM_READ_VAR(i, autoretract_enabled);
EEPROM_READ_VAR(i, retract_length);
#if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_length_swap);
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);
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);
EEPROM_READ_VAR(i, retract_recover_length_swap);
#endif //EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_feedrate);
EEPROM_READ_VAR(i, retract_recover_feedrate);
#endif //FWRETRACT
EEPROM_READ_VAR(i, volumetric_enabled);
......@@ -294,7 +294,7 @@ void Config_ResetDefault()
for (int i = 0; i < EXTRUDERS; i++) {
max_retraction_feedrate[i] = tmp3[i];
#if EXTRUDERS > 1 && !defined SINGLENOZZLE
#if HOTENDS > 1
hotend_offset[X_AXIS][i] = tmp8[i];
hotend_offset[Y_AXIS][i] = tmp9[i];
#endif
......@@ -316,7 +316,7 @@ void Config_ResetDefault()
max_xy_jerk = DEFAULT_XYJERK;
max_z_jerk = DEFAULT_ZJERK;
max_e_jerk = DEFAULT_EJERK;
add_homing[X_AXIS] = add_homing[Y_AXIS] = add_homing[Z_AXIS] = 0;
home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
#ifdef ENABLE_AUTO_BED_LEVELING
zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
......@@ -351,11 +351,7 @@ void Config_ResetDefault()
#endif //DOGLCD
#ifdef PIDTEMP
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0; // only need to write once
#endif //SINGLENOZZLE
for (int e = 0; e < HOTENDS; e++)
{
Kp[e] = tmp5[e];
Ki[e] = scalePID_i(tmp6[e]);
......@@ -405,16 +401,16 @@ void Config_PrintSettings()
SERIAL_EOL;
SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[Z_AXIS]);
SERIAL_ECHOPAIR(" E0 S",axis_steps_per_unit[E_AXIS + 0]);
SERIAL_ECHOPAIR(" M92 X", axis_steps_per_unit[X_AXIS]);
SERIAL_ECHOPAIR(" Y", axis_steps_per_unit[Y_AXIS]);
SERIAL_ECHOPAIR(" Z", axis_steps_per_unit[Z_AXIS]);
SERIAL_ECHOPAIR(" E0 S", axis_steps_per_unit[E_AXIS + 0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 S",axis_steps_per_unit[E_AXIS + 1]);
SERIAL_ECHOPAIR(" E1 S", axis_steps_per_unit[E_AXIS + 1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 S",axis_steps_per_unit[E_AXIS + 2]);
SERIAL_ECHOPAIR(" E2 S", axis_steps_per_unit[E_AXIS + 2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 S",axis_steps_per_unit[E_AXIS + 3]);
SERIAL_ECHOPAIR(" E3 S", axis_steps_per_unit[E_AXIS + 3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
......@@ -424,17 +420,17 @@ void Config_PrintSettings()
#ifdef SCARA
SERIAL_ECHOLNPGM("Scaling factors:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M365 X",axis_scaling[X_AXIS]);
SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]);
SERIAL_ECHOPAIR(" M365 X", axis_scaling[X_AXIS]);
SERIAL_ECHOPAIR(" Y", axis_scaling[Y_AXIS]);
SERIAL_ECHOPAIR(" Z", axis_scaling[Z_AXIS]);
SERIAL_EOL;
SERIAL_ECHO_START;
#endif
SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M203 X",max_feedrate[X_AXIS]);
SERIAL_ECHOPAIR(" Y",max_feedrate[Y_AXIS] );
SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]);
SERIAL_ECHOPAIR(" Y", max_feedrate[Y_AXIS] );
SERIAL_ECHOPAIR(" Z", max_feedrate[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 S", max_feedrate[E_AXIS + 0]);
#if EXTRUDERS > 1
......@@ -452,11 +448,11 @@ void Config_PrintSettings()
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" E0 ",max_retraction_feedrate[0]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 ",max_retraction_feedrate[1]);
SERIAL_ECHOPAIR(" E1 ", max_retraction_feedrate[1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 ",max_retraction_feedrate[2]);
SERIAL_ECHOPAIR(" E2 ", max_retraction_feedrate[2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 ",max_retraction_feedrate[3]);
SERIAL_ECHOPAIR(" E3 ", max_retraction_feedrate[3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
......@@ -464,16 +460,16 @@ void Config_PrintSettings()
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_AXIS] );
SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[Y_AXIS] );
SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 S" ,max_acceleration_units_per_sq_second[E_AXIS]);
SERIAL_ECHOPAIR(" M201 X", max_acceleration_units_per_sq_second[X_AXIS] );
SERIAL_ECHOPAIR(" Y", max_acceleration_units_per_sq_second[Y_AXIS] );
SERIAL_ECHOPAIR(" Z", max_acceleration_units_per_sq_second[Z_AXIS] );
SERIAL_ECHOPAIR(" E0 S", max_acceleration_units_per_sq_second[E_AXIS]);
#if EXTRUDERS > 1
SERIAL_ECHOPAIR(" E1 S" ,max_acceleration_units_per_sq_second[E_AXIS+1]);
SERIAL_ECHOPAIR(" E1 S", max_acceleration_units_per_sq_second[E_AXIS+1]);
#if EXTRUDERS > 2
SERIAL_ECHOPAIR(" E2 S" ,max_acceleration_units_per_sq_second[E_AXIS+2]);
SERIAL_ECHOPAIR(" E2 S", max_acceleration_units_per_sq_second[E_AXIS+2]);
#if EXTRUDERS > 3
SERIAL_ECHOPAIR(" E3 S" ,max_acceleration_units_per_sq_second[E_AXIS+3]);
SERIAL_ECHOPAIR(" E3 S", max_acceleration_units_per_sq_second[E_AXIS+3]);
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
......@@ -481,7 +477,7 @@ void Config_PrintSettings()
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M204 P",acceleration );
SERIAL_ECHOPAIR(" M204 P", acceleration );
SERIAL_ECHOPAIR(" R", retract_acceleration);
SERIAL_ECHOPAIR(" T", travel_acceleration);
SERIAL_EOL;
......@@ -489,65 +485,65 @@ void Config_PrintSettings()
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
SERIAL_ECHOPAIR(" E" ,max_e_jerk);
SERIAL_EOL;
SERIAL_ECHOPAIR(" M205 S", minimumfeedrate );
SERIAL_ECHOPAIR(" T", mintravelfeedrate );
SERIAL_ECHOPAIR(" B", minsegmenttime );
SERIAL_ECHOPAIR(" X", max_xy_jerk );
SERIAL_ECHOPAIR(" Z", max_z_jerk);
SERIAL_ECHOPAIR(" E", max_e_jerk);
SERIAL_EOL;
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Home offset (mm):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M206 X",add_homing[X_AXIS] );
SERIAL_ECHOPAIR(" Y" ,add_homing[Y_AXIS] );
SERIAL_ECHOPAIR(" Z" ,add_homing[Z_AXIS] );
SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS] );
SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS] );
SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS] );
SERIAL_EOL;
#if EXTRUDERS > 1 && !defined SINGLENOZZLE
#if HOTENDS > 1
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Hotend offset (mm):");
for (int e = 0; e < EXTRUDERS; e++) {
for (int e = 0; e < HOTENDS; e++) {
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M218 T", (long unsigned int)e);
SERIAL_ECHOPAIR(" X", hotend_offset[X_AXIS][e]);
SERIAL_ECHOPAIR(" Y" ,hotend_offset[Y_AXIS][e]);
SERIAL_EOL;
}
#endif //EXTRUDERS > 1 && !defined SINGLENOZZLE
#endif //HOTENDS > 1
#ifdef DELTA
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Endstop adjustment (mm):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 X",endstop_adj[0]);
SERIAL_ECHOPAIR(" Y" ,endstop_adj[1]);
SERIAL_ECHOPAIR(" Z" ,endstop_adj[2]);
SERIAL_ECHOPAIR(" M666 X", endstop_adj[0]);
SERIAL_ECHOPAIR(" Y", endstop_adj[1]);
SERIAL_ECHOPAIR(" Z", endstop_adj[2]);
SERIAL_EOL;
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Delta Geometry adjustment:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 A",tower_adj[0]);
SERIAL_ECHOPAIR(" B" ,tower_adj[1]);
SERIAL_ECHOPAIR(" C" ,tower_adj[2]);
SERIAL_ECHOPAIR(" E" ,tower_adj[3]);
SERIAL_ECHOPAIR(" F" ,tower_adj[4]);
SERIAL_ECHOPAIR(" G" ,tower_adj[5]);
SERIAL_ECHOPAIR(" R" ,delta_radius);
SERIAL_ECHOPAIR(" D" ,delta_diagonal_rod);
SERIAL_ECHOPAIR(" H" ,max_pos[2]);
SERIAL_ECHOPAIR(" P" ,z_probe_offset[3]);
SERIAL_ECHOPAIR(" M666 A", tower_adj[0]);
SERIAL_ECHOPAIR(" B", tower_adj[1]);
SERIAL_ECHOPAIR(" C", tower_adj[2]);
SERIAL_ECHOPAIR(" E", tower_adj[3]);
SERIAL_ECHOPAIR(" F", tower_adj[4]);
SERIAL_ECHOPAIR(" G", tower_adj[5]);
SERIAL_ECHOPAIR(" R", delta_radius);
SERIAL_ECHOPAIR(" D", delta_diagonal_rod);
SERIAL_ECHOPAIR(" H", max_pos[2]);
SERIAL_ECHOPAIR(" P", z_probe_offset[3]);
SERIAL_EOL;
SERIAL_ECHOLN("Tower Positions");
SERIAL_ECHOPAIR("Tower1 X:",delta_tower1_x);
SERIAL_ECHOPAIR(" Y:",delta_tower1_y);
SERIAL_ECHOPAIR("Tower1 X:", delta_tower1_x);
SERIAL_ECHOPAIR(" Y:", delta_tower1_y);
SERIAL_EOL;
SERIAL_ECHOPAIR("Tower2 X:",delta_tower2_x);
SERIAL_ECHOPAIR(" Y:",delta_tower2_y);
SERIAL_ECHOPAIR("Tower2 X:", delta_tower2_x);
SERIAL_ECHOPAIR(" Y:", delta_tower2_y);
SERIAL_EOL;
SERIAL_ECHOPAIR("Tower3 X:",delta_tower3_x);
SERIAL_ECHOPAIR(" Y:",delta_tower3_y);
SERIAL_ECHOPAIR("Tower3 X:", delta_tower3_x);
SERIAL_ECHOPAIR(" Y:", delta_tower3_y);
SERIAL_EOL;
#endif // DELTA
......@@ -555,25 +551,21 @@ void Config_PrintSettings()
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Z Probe offset (mm)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 P",zprobe_zoffset);
SERIAL_ECHOPAIR(" M666 P", zprobe_zoffset);
SERIAL_EOL;
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef PIDTEMP
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("PID settings:");
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif
for (int e = 0; e < HOTENDS; e++)
{
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M301 E", (long unsigned int)e);
SERIAL_ECHOPAIR(" P", Kp[e]);
SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki[e]));
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[e]));
SERIAL_EOL;
SERIAL_ECHOPAIR(" I", unscalePID_i(Ki[e]));
SERIAL_ECHOPAIR(" D", unscalePID_d(Kd[e]));
SERIAL_EOL;
}
#endif // PIDTEMP
......@@ -581,15 +573,15 @@ void Config_PrintSettings()
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Retract: S=Length (mm) F:Speed (mm/m) Z: ZLift (mm)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M207 S",retract_length);
SERIAL_ECHOPAIR(" F" ,retract_feedrate*60);
SERIAL_ECHOPAIR(" Z" ,retract_zlift);
SERIAL_ECHOPAIR(" M207 S", retract_length);
SERIAL_ECHOPAIR(" F", retract_feedrate*60);
SERIAL_ECHOPAIR(" Z", retract_zlift);
SERIAL_EOL;
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M208 S",retract_recover_length);
SERIAL_ECHOPAIR(" F" ,retract_recover_feedrate*60);
SERIAL_ECHOPAIR(" M208 S", retract_recover_length);
SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
SERIAL_EOL;
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries");
......
......@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the log
#ifdef AUTO_BED_LEVELING_GRID
// Use one of these defines to specify the origin
// for a topographical map to be printed for your bed.
enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight };
#define TOPO_ORIGIN OriginFrontLeft
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension
......
......@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#ifdef AUTO_BED_LEVELING_GRID
// Use one of these defines to specify the origin
// for a topographical map to be printed for your bed.
enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight };
#define TOPO_ORIGIN OriginFrontLeft
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension
......
......@@ -150,11 +150,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the log
#ifdef AUTO_BED_LEVELING_GRID
// Use one of these defines to specify the origin
// for a topographical map to be printed for your bed.
enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight };
#define TOPO_ORIGIN OriginFrontLeft
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension
......
......@@ -252,19 +252,17 @@ extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in m
extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS];
extern float destination[NUM_AXIS];
extern float add_homing[3];
// Extruder offset
#if EXTRUDERS > 1
#ifndef SINGLENOZZLE
#ifndef DUAL_X_CARRIAGE
#define NUM_HOTEND_OFFSETS 2 // only in XY plane
#else
#define NUM_HOTEND_OFFSETS 3 // supports offsets in XYZ plane
#endif
extern float hotend_offset[NUM_HOTEND_OFFSETS][EXTRUDERS];
#endif // end SINGLENOZZLE
#endif // end EXTRUDERS
extern float home_offset[3];
// Hotend offset
#if HOTENDS > 1
#ifndef DUAL_X_CARRIAGE
#define NUM_HOTEND_OFFSETS 2 // only in XY plane
#else
#define NUM_HOTEND_OFFSETS 3 // supports offsets in XYZ plane
#endif
extern float hotend_offset[NUM_HOTEND_OFFSETS][HOTENDS];
#endif // HOTENDS > 1
#ifdef NPR2
extern int old_color; // old color for system NPR2
......
......@@ -245,7 +245,7 @@ float volumetric_multiplier[EXTRUDERS] = {1.0
};
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
float add_homing[3]={ 0, 0, 0 };
float home_offset[3] = { 0, 0, 0 };
int fanSpeed = 0;
bool cancel_heatup = false;
......@@ -294,29 +294,27 @@ bool axis_known_position[3] = { false, false, false };
float zprobe_zoffset;
float lastpos[4];
// Extruder offset
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
#ifndef DUAL_X_CARRIAGE
#define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
// Hotend offset
#if HOTENDS > 1
#ifndef DUAL_X_CARRIAGE
#define NUM_HOTENDS_OFFSETS 2 // only in XY plane
#else
#define NUM_HOTENDS_OFFSETS 3 // supports offsets in XYZ plane
#endif
float hotend_offset[NUM_HOTENDS_OFFSETS][HOTENDS] = {
#if defined(HOTEND_OFFSET_X)
HOTEND_OFFSET_X
#else
#define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
0
#endif
float hotend_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = {
#if defined(EXTRUDER_OFFSET_X)
EXTRUDER_OFFSET_X
#else
0
#endif
,
#if defined(EXTRUDER_OFFSET_Y)
EXTRUDER_OFFSET_Y
#else
0
#endif
};
#endif //EXTRUDERS > 1
#endif //SINGLENOZZLE
,
#if defined(HOTEND_OFFSET_Y)
HOTEND_OFFSET_Y
#else
0
#endif
};
#endif //HOTENDS > 1
uint8_t active_extruder = 0;
......@@ -1071,13 +1069,13 @@ static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
static float x_home_pos(int extruder) {
if (extruder == 0)
return base_home_pos(X_AXIS) + add_homing[X_AXIS];
return base_home_pos(X_AXIS) + home_offset[X_AXIS];
else
// In dual carriage mode the extruder offset provides an override of the
// second X-carriage offset when homed - otherwise X2_HOME_POS is used.
// This allow soft recalibration of the second extruder offset position without firmware reflash
// (through the M218 command).
return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
return (hotend_offset[X_AXIS][1] > 0) ? hotend_offset[X_AXIS][1] : X2_HOME_POS;
}
static int x_home_dir(int extruder) {
......@@ -1107,9 +1105,9 @@ bool extruder_duplication_enabled = false; // used in mode 2
}
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0)
{
current_position[X_AXIS] = base_home_pos(X_AXIS) + add_homing[X_AXIS];
min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homing[X_AXIS];
max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + add_homing[X_AXIS],
current_position[X_AXIS] = base_home_pos(X_AXIS) + home_offset[X_AXIS];
min_pos[X_AXIS] = base_min_pos(X_AXIS) + home_offset[X_AXIS];
max_pos[X_AXIS] = min(base_max_pos(X_AXIS) + home_offset[X_AXIS],
max(hotend_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
return;
}
......@@ -1134,11 +1132,11 @@ bool extruder_duplication_enabled = false; // used in mode 2
// SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]);
for (i=0; i<2; i++) {
delta[i] -= add_homing[i];
delta[i] -= home_offset[i];
}
// SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(add_homing[X_AXIS]);
// SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]);
// SERIAL_ECHOPGM("addhome X="); SERIAL_ECHO(home_offset[X_AXIS]);
// SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(home_offset[Y_AXIS]);
// SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]);
// SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]);
......@@ -1156,14 +1154,14 @@ bool extruder_duplication_enabled = false; // used in mode 2
}
else
{
current_position[axis] = base_home_pos(axis) + add_homing[axis];
min_pos[axis] = base_min_pos(axis) + add_homing[axis];
max_pos[axis] = base_max_pos(axis) + add_homing[axis];
current_position[axis] = base_home_pos(axis) + home_offset[axis];
min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos(axis) + home_offset[axis];
}
#else // NO SCARA
current_position[axis] = base_home_pos(axis) + add_homing[axis];
min_pos[axis] = base_min_pos(axis) + add_homing[axis];
max_pos[axis] = base_max_pos(axis) + add_homing[axis];
current_position[axis] = base_home_pos(axis) + home_offset[axis];
min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos(axis) + home_offset[axis];
#endif // SCARA
}
......@@ -1315,7 +1313,7 @@ bool extruder_duplication_enabled = false; // used in mode 2
#if SERVO_LEVELING
servos[servo_endstops[Z_AXIS]].attach(0);
#endif
servos[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2 + 1]);
servos[servo_endstops[Z_AXIS]].write(servo_endstop_angles[Z_AXIS * 2 + 1]);
#if SERVO_LEVELING
delay(PROBE_SERVO_DEACTIVATION_DELAY);
servos[servo_endstops[Z_AXIS]].detach();
......@@ -1324,10 +1322,15 @@ bool extruder_duplication_enabled = false; // used in mode 2
#endif //NUM_SERVOS > 0
}
enum ProbeAction { ProbeStay, ProbeEngage, ProbeRetract, ProbeEngageRetract };
enum ProbeAction {
ProbeStay = 0,
ProbeEngage = BIT(0),
ProbeRetract = BIT(1),
ProbeEngageAndRetract = (ProbeEngage | ProbeRetract)
};
// Probe bed height at position (x,y), returns the measured z value
static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeEngageRetract, int verbose_level=1) {
static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeEngageAndRetract, int verbose_level=1) {
// move to right place
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
......@@ -1436,9 +1439,9 @@ bool extruder_duplication_enabled = false; // used in mode 2
#ifdef DELTA
static void axis_is_at_home(int axis)
{
current_position[axis] = base_home_pos[axis] + add_homing[axis];
min_pos[axis] = base_min_pos(axis) + add_homing[axis];
max_pos[axis] = base_max_pos[axis] + add_homing[axis];
current_position[axis] = base_home_pos[axis] + home_offset[axis];
min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos[axis] + home_offset[axis];
}
static void homeaxis(int axis)
......@@ -2274,6 +2277,11 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#endif //DELTA
#ifdef SCARA
calculate_delta(current_position);
plan_set_position(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS]);
#endif
#if defined(CARTESIAN) || defined(COREXY) || defined(SCARA)
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
......@@ -2352,7 +2360,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#ifdef SCARA
current_position[X_AXIS]=code_value();
#else
current_position[X_AXIS]=code_value()+add_homing[X_AXIS];
current_position[X_AXIS]=code_value() + home_offset[X_AXIS];
#endif
}
......@@ -2360,7 +2368,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#ifdef SCARA
current_position[Y_AXIS]=code_value();
#else
current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS];
current_position[Y_AXIS]=code_value() + home_offset[Y_AXIS];
#endif
}
......@@ -2539,7 +2547,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#endif //Z_HOME_DIR < 0
if (code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0)
current_position[Z_AXIS] = code_value() + add_homing[Z_AXIS];
current_position[Z_AXIS] = code_value() + home_offset[Z_AXIS];
#ifdef ENABLE_AUTO_BED_LEVELING
if (home_all_axis || code_seen(axis_codes[Z_AXIS]))
......@@ -2660,7 +2668,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#ifdef AUTO_BED_LEVELING_GRID
bool topo_flag = code_seen('T') || code_seen('t');
bool do_topography_map = verbose_level > 2 || code_seen('T') || code_seen('t');
if (verbose_level > 0) SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
......@@ -2724,8 +2732,8 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
current_position[Y_AXIS] = uncorrected_position.y;
current_position[Z_AXIS] = uncorrected_position.z;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
setup_for_endstop_move();
setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
#ifdef AUTO_BED_LEVELING_GRID
......@@ -2772,7 +2780,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
// If topo_flag is set then don't zig-zag. Just scan in one direction.
// This gets the probe points in more readable order.
if (topo_flag) zig = !zig;
if (do_topography_map) zig = !zig;
for (int xCount=xStart; xCount != xStop; xCount += xInc)
{
double xProbe = left_probe_bed_position + xGridSpacing * xCount;
......@@ -2792,7 +2800,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
act = ProbeStay;
}
else
act = ProbeEngageRetract;
act = ProbeEngageAndRetract;
measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
......@@ -2829,49 +2837,30 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
}
}
if (topo_flag) {
int xx, yy;
if (do_topography_map) {
SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n");
#if TOPO_ORIGIN == OriginFrontLeft
SERIAL_PROTOCOLPGM("+-----------+\n");
SERIAL_PROTOCOLPGM("|...Back....|\n");
SERIAL_PROTOCOLPGM("|Left..Right|\n");
SERIAL_PROTOCOLPGM("|...Front...|\n");
SERIAL_PROTOCOLPGM("+-----------+\n");
for (yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--)
#else
for (yy = 0; yy < auto_bed_leveling_grid_points; yy++)
#endif
{
#if TOPO_ORIGIN == OriginBackRight
for (xx = 0; xx < auto_bed_leveling_grid_points; xx++)
#else
for (xx = auto_bed_leveling_grid_points - 1; xx >= 0; xx--)
#endif
{
int ind =
#if TOPO_ORIGIN == OriginBackRight || TOPO_ORIGIN == OriginFrontLeft
yy * auto_bed_leveling_grid_points + xx
#elif TOPO_ORIGIN == OriginBackLeft
xx * auto_bed_leveling_grid_points + yy
#elif TOPO_ORIGIN == OriginFrontRight
abl2 - xx * auto_bed_leveling_grid_points - yy - 1
#endif
;
float diff = eqnBVector[ind] - mean;
if (diff >= 0.0)
SERIAL_PROTOCOLPGM(" +"); // Include + for column alignment
else
SERIAL_PROTOCOLPGM(" ");
SERIAL_PROTOCOL_F(diff, 5);
} // xx
SERIAL_EOL;
} // yy
SERIAL_PROTOCOLPGM("+-----------+\n");
SERIAL_PROTOCOLPGM("|...Back....|\n");
SERIAL_PROTOCOLPGM("|Left..Right|\n");
SERIAL_PROTOCOLPGM("|...Front...|\n");
SERIAL_PROTOCOLPGM("+-----------+\n");
for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
for (int xx = auto_bed_leveling_grid_points - 1; xx >= 0; xx--) {
int ind = yy * auto_bed_leveling_grid_points + xx;
float diff = eqnBVector[ind] - mean;
if (diff >= 0.0)
SERIAL_PROTOCOLPGM(" +"); // Include + for column alignment
else
SERIAL_PROTOCOLPGM(" ");
SERIAL_PROTOCOL_F(diff, 5);
} // xx
SERIAL_EOL;
} // yy
SERIAL_EOL;
} //topo_flag
} //do_topography_map
set_bed_level_equation_lsq(plane_equation_coefficients);
......@@ -2898,9 +2887,6 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#endif // !AUTO_BED_LEVELING_GRID
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], Z_RAISE_AFTER_PROBING);
st_synchronize();
if (verbose_level > 0)
plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
......@@ -3483,9 +3469,9 @@ inline void gcode_G92() {
}
else {
#ifdef SCARA
current_position[i] = code_value() + ((i != X_AXIS && i != Y_AXIS) ? add_homing[i] : 0);
current_position[i] = code_value() + ((i != X_AXIS && i != Y_AXIS) ? home_offset[i] : 0);
#else
current_position[i] = code_value() + add_homing[i];
current_position[i] = code_value() + home_offset[i];
#endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
}
......@@ -3905,15 +3891,10 @@ inline void gcode_M204() {
boolean sleep = false;
int cnt = 0;
#ifndef SINGLENOZZLE
int old_target_temperature[EXTRUDERS] = { 0 };
for(int8_t e=0;e<EXTRUDERS;e++)
#else
int old_target_temperature[1] = { 0 };
int8_t e=0;
#endif
int old_target_temperature[HOTENDS] = { 0 };
for(int8_t e = 0; e < HOTENDS; e++)
{
old_target_temperature[e]=target_temperature[e];
old_target_temperature[e] = target_temperature[e];
}
int old_target_temperature_bed = target_temperature_bed;
timer.set_max_delay(60000); // 1 minute
......@@ -3947,11 +3928,7 @@ inline void gcode_M204() {
lcd_reset_alert_level();
if (sleep) {
#ifndef SINGLENOZZLE
for(int8_t e=0;e<EXTRUDERS;e++)
#else
int8_t e=0;
#endif
for(int8_t e = 0; e < HOTENDS; e++)
{
setTargetHotend(old_target_temperature[e], e);
CooldownNoWait = true;
......@@ -4572,7 +4549,7 @@ void process_commands()
{
if(setTargetedHotend(104)) break;
if(debugDryrun()) break;
#ifdef SINGLENOZZLE
#if HOTENDS == 1
if (tmp_extruder != active_extruder) break;
#endif
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
......@@ -4675,7 +4652,7 @@ void process_commands()
{
if(setTargetedHotend(109)) break;
if(debugDryrun()) break;
#ifdef SINGLENOZZLE
#if HOTENDS == 1
if (tmp_extruder != active_extruder) break;
#endif
LCD_MESSAGEPGM(MSG_HEATING);
......@@ -4758,9 +4735,9 @@ void process_commands()
SERIAL_PROTOCOLLN("");
SERIAL_PROTOCOLPGM("SCARA Cal - Theta:");
SERIAL_PROTOCOL(delta[X_AXIS]+add_homing[X_AXIS]);
SERIAL_PROTOCOL(delta[X_AXIS] + home_offset[X_AXIS]);
SERIAL_PROTOCOLPGM(" Psi+Theta (90):");
SERIAL_PROTOCOL(delta[Y_AXIS]-delta[X_AXIS]-90+add_homing[Y_AXIS]);
SERIAL_PROTOCOL(delta[Y_AXIS] - delta[X_AXIS] - 90 + home_offset[Y_AXIS]);
SERIAL_PROTOCOLLN("");
SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
......@@ -5030,16 +5007,16 @@ void process_commands()
{
for(int8_t i=0; i < 3; i++)
{
if(code_seen(axis_codes[i])) add_homing[i] = code_value();
if(code_seen(axis_codes[i])) home_offset[i] = code_value();
}
#ifdef SCARA
if(code_seen('T')) // Theta
{
add_homing[X_AXIS] = code_value() ;
home_offset[X_AXIS] = code_value() ;
}
if(code_seen('P')) // Psi
{
add_homing[Y_AXIS] = code_value() ;
home_offset[Y_AXIS] = code_value() ;
}
#endif
}
......@@ -5122,43 +5099,41 @@ void process_commands()
break;
#endif // FWRETRACT
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
case 218: //M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
#if HOTENDS > 1
case 218: //M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
{
if(setTargetedHotend(218)) break;
if(code_seen('X'))
{
if(setTargetedHotend(218)) break;
if(code_seen('X'))
{
hotend_offset[X_AXIS][tmp_extruder] = code_value();
}
if(code_seen('Y'))
hotend_offset[X_AXIS][tmp_extruder] = code_value();
}
if(code_seen('Y'))
{
hotend_offset[Y_AXIS][tmp_extruder] = code_value();
}
#ifdef DUAL_X_CARRIAGE
if(code_seen('Z'))
{
hotend_offset[Y_AXIS][tmp_extruder] = code_value();
hotend_offset[Z_AXIS][tmp_extruder] = code_value();
}
#endif
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
{
SERIAL_ECHO(" ");
SERIAL_ECHO(hotend_offset[X_AXIS][tmp_extruder]);
SERIAL_ECHO(",");
SERIAL_ECHO(hotend_offset[Y_AXIS][tmp_extruder]);
#ifdef DUAL_X_CARRIAGE
if(code_seen('Z'))
{
hotend_offset[Z_AXIS][tmp_extruder] = code_value();
}
#endif
SERIAL_ECHO_START;
SERIAL_ECHOPGM(MSG_HOTEND_OFFSET);
for(tmp_extruder = 0; tmp_extruder < EXTRUDERS; tmp_extruder++)
{
SERIAL_ECHO(" ");
SERIAL_ECHO(hotend_offset[X_AXIS][tmp_extruder]);
SERIAL_ECHO(",");
SERIAL_ECHO(hotend_offset[Y_AXIS][tmp_extruder]);
#ifdef DUAL_X_CARRIAGE
SERIAL_ECHO(",");
SERIAL_ECHO(hotend_offset[Z_AXIS][tmp_extruder]);
#endif
}
SERIAL_EOL;
SERIAL_ECHO(hotend_offset[Z_AXIS][tmp_extruder]);
#endif
}
break;
#endif //EXTRUDERS > 1
#endif // SINGLENOZZLE
SERIAL_EOL;
}
break;
#endif //EXTRUDERS > 1
case 220: //M220 S<factor in percent>- set speed factor override percentage
{
......@@ -5882,16 +5857,11 @@ void process_commands()
delayed_move_time = 0;
}
#else
// Offset extruder (only by XY)
#ifndef SINGLENOZZLE
int i;
for(i = 0; i < 2; i++)
{
current_position[i] = current_position[i] -
hotend_offset[i][active_extruder] +
hotend_offset[i][tmp_extruder];
}
#endif // SINGLENOZZLE
// Offset hotend (only by XY)
#if HOTENDS > 1
for (int i=X_AXIS; i<=Y_AXIS; i++)
current_position[i] += hotend_offset[i][tmp_extruder] - hotend_offset[i][active_extruder];
#endif // HOTENDS > 1
#if defined(MKR4) && (EXTRUDERS > 1)
#if (EXTRUDERS == 4) && (E0E2_CHOICE_PIN >1) && (E1E3_CHOICE_PIN > 1)
......@@ -6106,7 +6076,7 @@ void clamp_to_software_endstops(float target[3])
float negative_z_offset = 0;
#ifdef ENABLE_AUTO_BED_LEVELING
if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER;
if (add_homing[Z_AXIS] < 0) negative_z_offset = negative_z_offset + add_homing[Z_AXIS];
if (home_offset[Z_AXIS] < 0) negative_z_offset = negative_z_offset + home_offset[Z_AXIS];
#endif
if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset;
......
......@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() {
startFileprint();
}
else {
quickStop();
file.close();
sdprinting = false;
if (SD_FINISHED_STEPPERRELEASE) {
......
......@@ -4448,7 +4448,7 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
/****************************************************************************************
************************************* FEATURE *******************************************
/****************************************************************************************/
****************************************************************************************/
#ifdef SINGLENOZZLE
#undef HEATER_1_PIN
......
......@@ -107,11 +107,8 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
X_DIR_WRITE(v); \
X2_DIR_WRITE(v); \
} \
else{ \
if (current_block->active_driver) \
X2_DIR_WRITE(v); \
else \
X_DIR_WRITE(v); \
else { \
if (current_block->active_driver) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \
}
#define X_APPLY_STEP(v,ALWAYS) \
if (extruder_duplication_enabled || ALWAYS) { \
......@@ -119,10 +116,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
X2_STEP_WRITE(v); \
} \
else { \
if (current_block->active_driver != 0) \
X2_STEP_WRITE(v); \
else \
X_STEP_WRITE(v); \
if (current_block->active_driver != 0) X2_STEP_WRITE(v); else X_STEP_WRITE(v); \
}
#else
#define X_APPLY_DIR(v,Q) X_DIR_WRITE(v)
......@@ -130,16 +124,16 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
#endif
#ifdef Y_DUAL_STEPPER_DRIVERS
#define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v), Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR)
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v), Y2_STEP_WRITE(v)
#define Y_APPLY_DIR(v,Q) { Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }
#define Y_APPLY_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }
#else
#define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v)
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
#endif
#ifdef Z_DUAL_STEPPER_DRIVERS
#define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v), Z2_DIR_WRITE(v)
#define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v), Z2_STEP_WRITE(v)
#define Z_APPLY_DIR(v,Q) { Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }
#define Z_APPLY_STEP(v,Q) { Z_STEP_WRITE(v); Z2_STEP_WRITE(v); }
#else
#define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v)
#define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v)
......
......@@ -41,21 +41,17 @@
//================================== macros =================================
//===========================================================================
#ifndef SINGLENOZZLE
#if EXTRUDERS > 4
#error Unsupported number of extruders
#elif EXTRUDERS > 3
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3, v4 }
#elif EXTRUDERS > 2
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3 }
#elif EXTRUDERS > 1
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2 }
#else
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1 }
#endif
#if HOTENDS > 4
#error Unsupported number of hotends
#elif HOTENDS > 3
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2, v3, v4 }
#elif HOTENDS > 2
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2, v3 }
#elif HOTENDS > 1
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2 }
#else
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1 }
#endif //SINGLENOZZLE
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1 }
#endif
#define HAS_TEMP_0 (defined(TEMP_0_PIN) && TEMP_0_PIN >= 0)
#define HAS_TEMP_1 (defined(TEMP_1_PIN) && TEMP_1_PIN >= 0)
......@@ -85,15 +81,10 @@
#endif
#define PID_dT ((OVERSAMPLENR * 12.0)/(F_CPU / 64.0 / 256.0))
#ifndef SINGLENOZZLE
int target_temperature[EXTRUDERS] = { 0 };
int current_temperature_raw[EXTRUDERS] = { 0 };
float current_temperature[EXTRUDERS] = { 0.0 };
#else
int current_temperature_raw[1] = { 0 };
float current_temperature[1] = { 0.0 };
int target_temperature[1] = { 0 };
#endif //SINGLENOZZLE
int target_temperature[HOTENDS] = { 0 };
int current_temperature_raw[HOTENDS] = { 0 };
float current_temperature[HOTENDS] = { 0.0 };
int target_temperature_bed = 0;
int current_temperature_bed_raw = 0;
float current_temperature_bed = 0.0;
......@@ -102,11 +93,7 @@ float current_temperature_bed = 0.0;
float redundant_temperature = 0.0;
#endif
#ifdef PIDTEMP
#ifndef SINGLENOZZLE
float Kp[EXTRUDERS],Ki[EXTRUDERS],Kd[EXTRUDERS];
#else
float Kp[1],Ki[1],Kd[1];
#endif
float Kp[HOTENDS],Ki[HOTENDS],Kd[HOTENDS];
#endif //PIDTEMP
#ifdef PIDTEMPBED
......@@ -135,33 +122,16 @@ static volatile bool temp_meas_ready = false;
#ifdef PIDTEMP
//static cannot be external:
#ifndef SINGLENOZZLE
static float temp_iState[EXTRUDERS] = { 0 };
static float temp_dState[EXTRUDERS] = { 0 };
static float pTerm[EXTRUDERS];
static float iTerm[EXTRUDERS];
static float dTerm[EXTRUDERS];
//int output;
static float pid_error[EXTRUDERS];
static float temp_iState_min[EXTRUDERS];
static float temp_iState_max[EXTRUDERS];
// static float pid_input[EXTRUDERS];
// static float pid_output[EXTRUDERS];
static bool pid_reset[EXTRUDERS];
#else
static float temp_iState[1] = { 0 };
static float temp_dState[1] = { 0 };
static float pTerm[1];
static float iTerm[1];
static float dTerm[1];
//int output;
static float pid_error[1];
static float temp_iState_min[1];
static float temp_iState_max[1];
// static float pid_input[1];
// static float pid_output[1];
static bool pid_reset[1];
#endif //SINGLENOZZLE
static float temp_iState[HOTENDS] = { 0 };
static float temp_dState[HOTENDS] = { 0 };
static float pTerm[HOTENDS];
static float iTerm[HOTENDS];
static float dTerm[HOTENDS];
//int output;
static float pid_error[HOTENDS];
static float temp_iState_min[HOTENDS];
static float temp_iState_max[HOTENDS];
static bool pid_reset[HOTENDS];
#endif //PIDTEMP
#ifdef PIDTEMPBED
//static cannot be external:
......@@ -175,13 +145,11 @@ static volatile bool temp_meas_ready = false;
static float temp_iState_min_bed;
static float temp_iState_max_bed;
#else //PIDTEMPBED
static unsigned long previous_millis_bed_heater;
static unsigned long previous_millis_bed_heater;
#endif //PIDTEMPBED
#ifndef SINGLENOZZLE
static unsigned char soft_pwm[EXTRUDERS];
#else
static unsigned char soft_pwm[1];
#endif
static unsigned char soft_pwm[HOTENDS];
#ifdef FAN_SOFT_PWM
static unsigned char soft_pwm_fan;
#endif
......@@ -190,19 +158,11 @@ static volatile bool temp_meas_ready = false;
#endif
// Init min and max temp with extreme values to prevent false errors during startup
#ifndef SINGLENOZZLE
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 0, 0, 0, 0 );
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383, 16383 );
//static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; /* No bed mintemp error implemented?!? */
#else
static int minttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_LO_TEMP , HEATER_0_RAW_LO_TEMP , HEATER_0_RAW_LO_TEMP, HEATER_0_RAW_LO_TEMP );
static int maxttemp_raw[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_RAW_HI_TEMP , HEATER_0_RAW_HI_TEMP , HEATER_0_RAW_HI_TEMP, HEATER_0_RAW_HI_TEMP );
static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 0, 0, 0, 0 );
static int maxttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 16383, 16383, 16383, 16383 );
//static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; /* No bed mintemp error implemented?!? */
#endif
static int minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
static int maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
static int minttemp[HOTENDS] = ARRAY_BY_HOTENDS( 0, 0, 0, 0 );
static int maxttemp[HOTENDS] = ARRAY_BY_HOTENDS( 16383, 16383, 16383, 16383 );
//static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; /* No bed mintemp error implemented?!? */
#ifdef BED_MAXTEMP
static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
......@@ -212,8 +172,8 @@ static volatile bool temp_meas_ready = false;
static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE };
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
#else
static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE, (void *)HEATER_3_TEMPTABLE );
static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN, HEATER_3_TEMPTABLE_LEN );
static void *heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE, (void *)HEATER_3_TEMPTABLE );
static uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN, HEATER_3_TEMPTABLE_LEN );
#endif
static float analog2temp(int raw, uint8_t e);
......@@ -221,13 +181,8 @@ static float analog2tempBed(int raw);
static void updateTemperaturesFromRawValues();
#ifdef WATCH_TEMP_PERIOD
#ifndef SINGLENOZZLE
int watch_start_temp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0,0);
unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0,0);
#else
int watch_start_temp[1] = ARRAY_BY_EXTRUDERS(0,0,0,0);
unsigned long watchmillis[1] = ARRAY_BY_EXTRUDERS(0,0,0,0);
#endif
int watch_start_temp[HOTENDS] = ARRAY_BY_HOTENDS(0,0,0,0);
unsigned long watchmillis[HOTENDS] = ARRAY_BY_HOTENDS(0,0,0,0);
#endif //WATCH_TEMP_PERIOD
#ifndef SOFT_PWM_SCALE
......@@ -246,7 +201,8 @@ static void updateTemperaturesFromRawValues();
//============================= functions ============================
//===========================================================================
void PID_autotune(float temp, int extruder, int ncycles) {
void PID_autotune(float temp, int hotend, int ncycles)
{
float input = 0.0;
int cycles = 0;
bool heating = true;
......@@ -263,9 +219,9 @@ void PID_autotune(float temp, int extruder, int ncycles) {
unsigned long extruder_autofan_last_check = temp_millis;
#endif
if (extruder >= EXTRUDERS
if (hotend >= HOTENDS
#if !HAS_TEMP_BED
|| extruder < 0
|| hotend < 0
#endif
) {
SERIAL_ECHOLN(MSG_PID_BAD_EXTRUDER_NUM);
......@@ -276,10 +232,10 @@ void PID_autotune(float temp, int extruder, int ncycles) {
disable_heater(); // switch off all heaters.
if (extruder < 0)
if (hotend < 0)
soft_pwm_bed = bias = d = MAX_BED_POWER / 2;
else
soft_pwm[extruder] = bias = d = PID_MAX / 2;
soft_pwm[hotend] = bias = d = PID_MAX / 2;
// PID Tuning loop
for(;;) {
......@@ -289,7 +245,7 @@ void PID_autotune(float temp, int extruder, int ncycles) {
if (temp_meas_ready == true) { // temp sample ready
updateTemperaturesFromRawValues();
input = (extruder<0)?current_temperature_bed:current_temperature[extruder];
input = (hotend<0)?current_temperature_bed:current_temperature[hotend];
max = max(max, input);
min = min(min, input);
......@@ -304,10 +260,10 @@ void PID_autotune(float temp, int extruder, int ncycles) {
if (heating == true && input > temp) {
if (ms - t2 > 5000) {
heating = false;
if (extruder < 0)
if (hotend < 0)
soft_pwm_bed = (bias - d) >> 1;
else
soft_pwm[extruder] = (bias - d) >> 1;
soft_pwm[hotend] = (bias - d) >> 1;
t1 = ms;
t_high = t1 - t2;
max = temp;
......@@ -319,7 +275,7 @@ void PID_autotune(float temp, int extruder, int ncycles) {
t2 = ms;
t_low = t2 - t1;
if (cycles > 0) {
long max_pow = extruder < 0 ? MAX_BED_POWER : PID_MAX;
long max_pow = hotend < 0 ? MAX_BED_POWER : PID_MAX;
bias += (d*(t_high - t_low))/(t_low + t_high);
bias = constrain(bias, 20, max_pow - 20);
d = (bias > max_pow / 2) ? max_pow - 1 - bias : bias;
......@@ -358,10 +314,10 @@ void PID_autotune(float temp, int extruder, int ncycles) {
*/
}
}
if (extruder < 0)
if (hotend < 0)
soft_pwm_bed = (bias + d) >> 1;
else
soft_pwm[extruder] = (bias + d) >> 1;
soft_pwm[hotend] = (bias + d) >> 1;
cycles++;
min = temp;
}
......@@ -374,12 +330,12 @@ void PID_autotune(float temp, int extruder, int ncycles) {
// Every 2 seconds...
if (ms > temp_millis + 2000) {
int p;
if (extruder < 0) {
if (hotend < 0) {
p = soft_pwm_bed;
SERIAL_PROTOCOLPGM(MSG_OK_B);
}
else {
p = soft_pwm[extruder];
p = soft_pwm[hotend];
SERIAL_PROTOCOLPGM(MSG_OK_T);
}
......@@ -404,13 +360,9 @@ void PID_autotune(float temp, int extruder, int ncycles) {
void updatePID() {
#ifdef PIDTEMP
#ifndef SINGLENOZZLE
for(int e = 0; e < EXTRUDERS; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e];
}
#else
temp_iState_max[0] = PID_INTEGRAL_DRIVE_MAX / Ki[0];
#endif
for (int e = 0; e < HOTENDS; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e];
}
#endif
#ifdef PIDTEMPBED
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi;
......@@ -422,7 +374,6 @@ int getHeaterPower(int heater) {
}
#if HAS_AUTO_FAN
#if HAS_FAN
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
#error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
......@@ -438,113 +389,109 @@ int getHeaterPower(int heater) {
#endif
#endif
void setExtruderAutoFanState(int pin, bool state)
{
unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0;
// this idiom allows both digital and PWM fan outputs (see M42 handling).
pinMode(pin, OUTPUT);
digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed);
}
void checkExtruderAutoFans()
{
uint8_t fanState = 0;
void setExtruderAutoFanState(int pin, bool state)
{
unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0;
// this idiom allows both digital and PWM fan outputs (see M42 handling).
pinMode(pin, OUTPUT);
digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed);
}
// which fan pins need to be turned on?
#if HAS_AUTO_FAN_0
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
fanState |= 1;
#endif
void checkExtruderAutoFans()
{
uint8_t fanState = 0;
#ifndef SINGLENOZZLE
#if HAS_AUTO_FAN_1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else
fanState |= 2;
}
#endif
#if HAS_AUTO_FAN_2
if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) {
if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
// which fan pins need to be turned on?
#if HAS_AUTO_FAN_0
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
fanState |= 1;
else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else
fanState |= 4;
}
#endif
#if HAS_AUTO_FAN_3
if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE) {
if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN)
fanState |= 4;
else
fanState |= 8;
}
#endif
#endif // !SINLGENOZZE
#endif
// update extruder auto fan states
#if HAS_AUTO_FAN_0
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
#endif
#if HAS_AUTO_FAN_1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else
fanState |= 2;
}
#endif
#if HAS_AUTO_FAN_2
if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE) {
if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else
fanState |= 4;
}
#endif
#if HAS_AUTO_FAN_3
if (current_temperature[3] > EXTRUDER_AUTO_FAN_TEMPERATURE) {
if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_1_AUTO_FAN_PIN)
fanState |= 2;
else if (EXTRUDER_3_AUTO_FAN_PIN == EXTRUDER_2_AUTO_FAN_PIN)
fanState |= 4;
else
fanState |= 8;
}
#endif
#ifndef SINGLENOZZLE
#if HAS_AUTO_FAN_1
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
#endif
#if HAS_AUTO_FAN_2
if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0);
#endif
#if HAS_AUTO_FAN_3
if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0);
#endif
#endif //!SINGLENOZZLE
}
// update extruder auto fan states
#if HAS_AUTO_FAN_0
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
#endif
#if HAS_AUTO_FAN_1
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
#endif
#if HAS_AUTO_FAN_2
if (EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_2_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_2_AUTO_FAN_PIN, (fanState & 4) != 0);
#endif
#if HAS_AUTO_FAN_3
if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0);
#endif
}
#endif // any extruder auto fan pins set
//
// Error checking and Write Routines
//
#if EXTRUDERS > 0
#if HOTENDS > 0
#if !HAS_HEATER_0
#error HEATER_0_PIN not defined for this board
#endif
#define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, v)
#endif
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1 || defined(HEATERS_PARALLEL)
#if !HAS_HEATER_1
#error HEATER_1_PIN not defined for this board
#if HOTENDS > 1 || defined(HEATERS_PARALLEL)
#if !HAS_HEATER_1
#error HEATER_1_PIN not defined for this board
#endif
#define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, v)
#if HOTENDS > 2
#if !HAS_HEATER_2
#error HEATER_2_PIN not defined for this board
#endif
#define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, v)
#if EXTRUDERS > 2
#if !HAS_HEATER_2
#error HEATER_2_PIN not defined for this board
#endif
#define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, v)
#if EXTRUDERS > 3
#if !HAS_HEATER_3
#error HEATER_3_PIN not defined for this board
#endif
#define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, v)
#define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, v)
#if HOTENDS > 3
#if !HAS_HEATER_3
#error HEATER_3_PIN not defined for this board
#endif
#define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, v)
#endif
#endif
#endif //SINGLENOZZLE
#endif
#ifdef HEATERS_PARALLEL
#define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
#else
......@@ -603,14 +550,9 @@ void manage_heater() {
unsigned long ms = millis();
// Loop through all extruders
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
// Loop through all hotends
for (int e = 0; e < HOTENDS; e++)
{
#if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
#endif
......@@ -701,7 +643,7 @@ void manage_heater() {
_temp_error(-1, MSG_EXTRUDER_SWITCHED_OFF, MSG_ERR_REDUNDANT_TEMP);
}
#endif //TEMP_SENSOR_1_AS_REDUNDANT
} // Extruders Loop
} // Hotends Loop
#if HAS_AUTO_FAN
if (ms > extruder_autofan_last_check + 2500) { // only need to check fan state very infrequently
......@@ -795,8 +737,8 @@ void manage_heater() {
#ifdef FILAMENT_SENSOR
if (filament_sensor) {
meas_shift_index = delay_index1 - meas_delay_cm;
if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed
if (meas_shift_index < 0) meas_shift_index += MAX_MEASUREMENT_DELAY + 1; //loop around buffer if needed
// Get the delayed info and add 100 to reconstitute to a percent of
// the nominal filament diameter then square it to get an area
meas_shift_index = constrain(meas_shift_index, 0, MAX_MEASUREMENT_DELAY);
......@@ -853,7 +795,7 @@ static float analog2temp(int raw, uint8_t e) {
return celsius;
}
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
return ((raw * ((5.0 * 100) / 1024) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
}
// Derived from RepRap FiveD extruder::getTemperature()
......@@ -867,7 +809,7 @@ static float analog2tempBed(int raw) {
{
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw)
{
celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) +
celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) +
(raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) *
(float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) /
(float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i-1][0]));
......@@ -880,7 +822,7 @@ static float analog2tempBed(int raw) {
return celsius;
#elif defined BED_USES_AD595
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
return ((raw * ((5.0 * 100) / 1024) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
#else //NO BED_USES_THERMISTOR
return 0;
#endif //BED_USES_THERMISTOR
......@@ -893,11 +835,7 @@ static void updateTemperaturesFromRawValues() {
current_temperature_raw[0] = read_max6675();
#endif
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
for (int e = 0; e < HOTENDS; e++)
{
current_temperature[e] = analog2temp(current_temperature_raw[e], e);
}
......@@ -921,7 +859,7 @@ static void updateTemperaturesFromRawValues() {
// Convert raw Filament Width to millimeters
float analog2widthFil() {
return current_raw_filwidth / 16383.0 * 5.0;
return current_raw_filwidth / (1024 * OVERSAMPLENR) * 5.0;
//return current_raw_filwidth;
}
......@@ -935,6 +873,7 @@ static void updateTemperaturesFromRawValues() {
#endif
void tp_init()
{
#if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
......@@ -943,14 +882,10 @@ void tp_init()
MCUCR=BIT(JTD);
#endif
// Finish init of mult extruder arrays
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
// Finish init of mult hotends arrays
for (int e = 0; e < HOTENDS; e++)
{
// populate with the first value
// populate with the first value
maxttemp[e] = maxttemp[0];
#ifdef PIDTEMP
temp_iState_min[e] = 0.0;
......@@ -1065,32 +1000,30 @@ void tp_init()
TEMP_MAX_ROUTINE(0);
#endif
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
#if HOTENDS > 1
#ifdef HEATER_1_MINTEMP
TEMP_MIN_ROUTINE(1);
#endif
#ifdef HEATER_1_MAXTEMP
TEMP_MAX_ROUTINE(1);
#endif
#if EXTRUDERS > 2
#if HOTENDS > 2
#ifdef HEATER_2_MINTEMP
TEMP_MIN_ROUTINE(2);
#endif
#ifdef HEATER_2_MAXTEMP
TEMP_MAX_ROUTINE(2);
#endif
#if EXTRUDERS > 3
#if HOTENDS > 3
#ifdef HEATER_3_MINTEMP
TEMP_MIN_ROUTINE(3);
#endif
#ifdef HEATER_3_MAXTEMP
TEMP_MAX_ROUTINE(3);
#endif
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1
#endif //SINGLENOZZLE
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#ifdef BED_MINTEMP
/* No bed MINTEMP error implemented?!? */ /*
......@@ -1117,11 +1050,7 @@ void tp_init()
void setWatch() {
#ifdef WATCH_TEMP_PERIOD
unsigned long ms = millis();
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
for (int e = 0; e < HOTENDS; e++)
{
if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) {
watch_start_temp[e] = degHotend(e);
......@@ -1197,11 +1126,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat
void disable_heater() {
#ifndef SINGLENOZZLE
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
for (int e = 0; e < HOTENDS; e++)
setTargetHotend(0, e);
setTargetBed(0);
#if HAS_TEMP_0
......@@ -1210,19 +1135,19 @@ void disable_heater() {
WRITE_HEATER_0P(LOW); // If HEATERS_PARALLEL should apply, change to WRITE_HEATER_0
#endif
#if EXTRUDERS > 1 && HAS_TEMP_1
#if HOTENDS > 1 && HAS_TEMP_1
target_temperature[1] = 0;
soft_pwm[1] = 0;
WRITE_HEATER_1(LOW);
#endif
#if EXTRUDERS > 2 && HAS_TEMP_2
#if HOTENDS > 2 && HAS_TEMP_2
target_temperature[2] = 0;
soft_pwm[2] = 0;
WRITE_HEATER_2(LOW);
#endif
#if EXTRUDERS > 3 && HAS_TEMP_3
#if HOTENDS > 3 && HAS_TEMP_3
target_temperature[3] = 0;
soft_pwm[3] = 0;
WRITE_HEATER_3(LOW);
......@@ -1313,10 +1238,7 @@ enum TempState {
ISR(TIMER0_COMPB_vect) {
//these variables are only accessible from the ISR, but static, so they don't lose their value
static unsigned char temp_count = 0;
static unsigned long raw_temp_0_value = 0;
static unsigned long raw_temp_1_value = 0;
static unsigned long raw_temp_2_value = 0;
static unsigned long raw_temp_3_value = 0;
static unsigned long raw_temp_value[HOTENDS] = { 0 };
static unsigned long raw_temp_bed_value = 0;
static TempState temp_state = StartupDelay;
static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
......@@ -1334,17 +1256,16 @@ ISR(TIMER0_COMPB_vect) {
// Statics per heater
ISR_STATICS(0);
#ifndef SINGLENOZZLE
#if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL)
#if (HOTENDS > 1) || defined(HEATERS_PARALLEL)
ISR_STATICS(1);
#if EXTRUDERS > 2
#if HOTENDS > 2
ISR_STATICS(2);
#if EXTRUDERS > 3
#if HOTENDS > 3
ISR_STATICS(3);
#endif
#endif
#endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED
ISR_STATICS(BED);
#endif
......@@ -1363,20 +1284,20 @@ ISR(TIMER0_COMPB_vect) {
WRITE_HEATER_0(1);
}
else WRITE_HEATER_0P(0); // If HEATERS_PARALLEL should apply, change to WRITE_HEATER_0
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
#if HOTENDS > 1
soft_pwm_1 = soft_pwm[1];
WRITE_HEATER_1(soft_pwm_1 > 0 ? 1 : 0);
#if EXTRUDERS > 2
#if HOTENDS > 2
soft_pwm_2 = soft_pwm[2];
WRITE_HEATER_2(soft_pwm_2 > 0 ? 1 : 0);
#if EXTRUDERS > 3
#if HOTENDS > 3
soft_pwm_3 = soft_pwm[3];
WRITE_HEATER_3(soft_pwm_3 > 0 ? 1 : 0);
#endif
#endif
#endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED
soft_pwm_BED = soft_pwm_bed;
WRITE_HEATER_BED(soft_pwm_BED > 0 ? 1 : 0);
......@@ -1388,17 +1309,17 @@ ISR(TIMER0_COMPB_vect) {
}
if (soft_pwm_0 < pwm_count) { WRITE_HEATER_0(0); }
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
#if HOTENDS > 1
if (soft_pwm_1 < pwm_count) WRITE_HEATER_1(0);
#if EXTRUDERS > 2
#if HOTENDS > 2
if (soft_pwm_2 < pwm_count) WRITE_HEATER_2(0);
#if EXTRUDERS > 3
#if HOTENDS > 3
if (soft_pwm_3 < pwm_count) WRITE_HEATER_3(0);
#endif
#endif
#endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED
if (soft_pwm_BED < pwm_count) WRITE_HEATER_BED(0);
#endif
......@@ -1450,36 +1371,34 @@ ISR(TIMER0_COMPB_vect) {
if (slow_pwm_count == 0) {
SLOW_PWM_ROUTINE(0); // EXTRUDER 0
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
SLOW_PWM_ROUTINE(1); // EXTRUDER 1
#if EXTRUDERS > 2
SLOW_PWM_ROUTINE(2); // EXTRUDER 2
#if EXTRUDERS > 3
SLOW_PWM_ROUTINE(3); // EXTRUDER 3
SLOW_PWM_ROUTINE(0); // HOTEND 0
#if HOTENDS > 1
SLOW_PWM_ROUTINE(1); // HOTEND 1
#if HOTENDS > 2
SLOW_PWM_ROUTINE(2); // HOTEND 2
#if HOTENDS > 3
SLOW_PWM_ROUTINE(3); // HOTEND 3
#endif
#endif
#endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED
_SLOW_PWM_ROUTINE(BED, soft_pwm_bed); // BED
#endif
} // slow_pwm_count == 0
PWM_OFF_ROUTINE(0); // EXTRUDER 0
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
PWM_OFF_ROUTINE(1); // EXTRUDER 1
#if EXTRUDERS > 2
PWM_OFF_ROUTINE(2); // EXTRUDER 2
#if EXTRUDERS > 3
PWM_OFF_ROUTINE(3); // EXTRUDER 3
PWM_OFF_ROUTINE(0); // HOTEND 0
#if HOTENDS > 1
PWM_OFF_ROUTINE(1); // HOTEND 1
#if HOTENDS > 2
PWM_OFF_ROUTINE(2); // HOTEND 2
#if HOTENDS > 3
PWM_OFF_ROUTINE(3); // HOTEND 3
#endif
#endif
#endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED
PWM_OFF_ROUTINE(BED); // BED
#endif
......@@ -1500,19 +1419,18 @@ ISR(TIMER0_COMPB_vect) {
slow_pwm_count++;
slow_pwm_count &= 0x7f;
// EXTRUDER 0
// HOTEND 0
if (state_timer_heater_0 > 0) state_timer_heater_0--;
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1 // EXTRUDER 1
#if HOTENDS > 1 // HOTEND 1
if (state_timer_heater_1 > 0) state_timer_heater_1--;
#if EXTRUDERS > 2 // EXTRUDER 2
#if HOTENDS > 2 // HOTEND 2
if (state_timer_heater_2 > 0) state_timer_heater_2--;
#if EXTRUDERS > 3 // EXTRUDER 3
#if HOTENDS > 3 // HOTEND 3
if (state_timer_heater_3 > 0) state_timer_heater_3--;
#endif
#endif
#endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED
if (state_timer_heater_BED > 0) state_timer_heater_BED--;
#endif
......@@ -1537,7 +1455,7 @@ ISR(TIMER0_COMPB_vect) {
break;
case MeasureTemp_0:
#if HAS_TEMP_0
raw_temp_0_value += ADC;
raw_temp_value[0] += ADC;
#endif
temp_state = PrepareTemp_BED;
break;
......@@ -1563,7 +1481,7 @@ ISR(TIMER0_COMPB_vect) {
break;
case MeasureTemp_1:
#if HAS_TEMP_1
raw_temp_1_value += ADC;
raw_temp_value[1] += ADC;
#endif
temp_state = PrepareTemp_2;
break;
......@@ -1576,7 +1494,7 @@ ISR(TIMER0_COMPB_vect) {
break;
case MeasureTemp_2:
#if HAS_TEMP_2
raw_temp_2_value += ADC;
raw_temp_value[2] += ADC;
#endif
temp_state = PrepareTemp_3;
break;
......@@ -1589,7 +1507,7 @@ ISR(TIMER0_COMPB_vect) {
break;
case MeasureTemp_3:
#if HAS_TEMP_3
raw_temp_3_value += ADC;
raw_temp_value[3] += ADC;
#endif
temp_state = Prepare_FILWIDTH;
break;
......@@ -1624,21 +1542,20 @@ ISR(TIMER0_COMPB_vect) {
if (temp_count >= OVERSAMPLENR) { // 12 * 16 * 1/(16000000/64/256) = 164ms.
if (!temp_meas_ready) { //Only update the raw values if they have been read. Else we could be updating them during reading.
#ifndef HEATER_0_USES_MAX6675
current_temperature_raw[0] = raw_temp_0_value;
current_temperature_raw[0] = raw_temp_value[0];
#endif
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
current_temperature_raw[1] = raw_temp_1_value;
#if EXTRUDERS > 2
current_temperature_raw[2] = raw_temp_2_value;
#if EXTRUDERS > 3
current_temperature_raw[3] = raw_temp_3_value;
#if HOTENDS > 1
current_temperature_raw[1] = raw_temp_value[1];
#if HOTENDS > 2
current_temperature_raw[2] = raw_temp_value[2];
#if HOTENDS > 3
current_temperature_raw[3] = raw_temp_value[3];
#endif
#endif
#endif
#endif //SINGLENOZZLE
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
redundant_temperature_raw = raw_temp_1_value;
redundant_temperature_raw = raw_temp_value[1];
#endif
current_temperature_bed_raw = raw_temp_bed_value;
} //!temp_meas_ready
......@@ -1650,35 +1567,65 @@ ISR(TIMER0_COMPB_vect) {
temp_meas_ready = true;
temp_count = 0;
raw_temp_0_value = 0;
raw_temp_1_value = 0;
raw_temp_2_value = 0;
raw_temp_3_value = 0;
for (int i = 0; i < HOTENDS; i++) raw_temp_value[i] = 0;
raw_temp_bed_value = 0;
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
#define MAXTEST <=
#define MINTEST >=
#define GE0 <=
#define LE0 >=
#else
#define MAXTEST >=
#define MINTEST <=
#define GE0 >=
#define LE0 <=
#endif
if (current_temperature_raw[0] GE0 maxttemp_raw[0]) max_temp_error(0);
if (current_temperature_raw[0] LE0 minttemp_raw[0]) min_temp_error(0);
#if HOTENDS > 1
#if HEATER_1_RAW_LO_TEMP > HEATER_1_RAW_HI_TEMP
#define GE1 <=
#define LE1 >=
#else
#define GE1 >=
#define LE1 <=
#endif
if (current_temperature_raw[1] GE1 maxttemp_raw[1]) max_temp_error(1);
if (current_temperature_raw[1] LE1 minttemp_raw[1]) min_temp_error(1);
#if HOTENDS > 2
#if HEATER_2_RAW_LO_TEMP > HEATER_2_RAW_HI_TEMP
#define GE2 <=
#define LE2 >=
#else
#define GE2 >=
#define LE2 <=
#endif
if (current_temperature_raw[2] GE2 maxttemp_raw[2]) max_temp_error(2);
if (current_temperature_raw[2] LE2 minttemp_raw[2]) min_temp_error(2);
#if HOTENDS > 3
#if HEATER_3_RAW_LO_TEMP > HEATER_3_RAW_HI_TEMP
#define GE3 <=
#define LE3 >=
#else
#define GE3 >=
#define LE3 <=
#endif
if (current_temperature_raw[3] GE3 maxttemp_raw[3]) max_temp_error(3);
if (current_temperature_raw[3] LE3 minttemp_raw[3]) min_temp_error(3);
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#ifndef SINGLENOZZLE
for (int i = 0; i < EXTRUDERS; i++)
#else
int i = 0;
#endif
{
if (current_temperature_raw[i] MAXTEST maxttemp_raw[i]) max_temp_error(i);
else if (current_temperature_raw[i] MINTEST minttemp_raw[i]) min_temp_error(i);
}
/* No bed MINTEMP error? */
#if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0)
if (current_temperature_bed_raw MAXTEST bed_maxttemp_raw) {
target_temperature_bed = 0;
bed_max_temp_error();
}
#if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP
#define GEBED <=
#define LEBED >=
#else
#define GEBED >=
#define LEBED <=
#endif
if (current_temperature_bed_raw GEBED bed_maxttemp_raw) {
target_temperature_bed = 0;
bed_max_temp_error();
}
#endif
} // temp_count >= OVERSAMPLENR
......
......@@ -40,21 +40,12 @@ void manage_heater(); //it is critical that this is called periodically.
// low level conversion routines
// do not use these routines and variables outside of temperature.cpp
#ifndef SINGLENOZZLE
extern int target_temperature[EXTRUDERS];
extern float current_temperature[EXTRUDERS];
#ifdef SHOW_TEMP_ADC_VALUES
extern int current_temperature_raw[EXTRUDERS];
extern int current_temperature_bed_raw;
#endif
#else
extern int target_temperature[1];
extern float current_temperature[1];
#ifdef SHOW_TEMP_ADC_VALUES
extern int current_temperature_raw[1];
extern int current_temperature_bed_raw;
#endif
#endif //SINGLENOZZLE
extern int target_temperature[HOTENDS];
extern float current_temperature[HOTENDS];
#ifdef SHOW_TEMP_ADC_VALUES
extern int current_temperature_raw[HOTENDS];
extern int current_temperature_bed_raw;
#endif
extern int target_temperature_bed;
extern float current_temperature_bed;
......@@ -67,11 +58,7 @@ extern float current_temperature_bed;
#endif
#ifdef PIDTEMP
#ifndef SINGLENOZZLE
extern float Kp[EXTRUDERS],Ki[EXTRUDERS],Kd[EXTRUDERS];
#else
extern float Kp[1],Ki[1],Kd[1];
#endif
extern float Kp[HOTENDS],Ki[HOTENDS],Kd[HOTENDS];
float scalePID_i(float i);
float scalePID_d(float d);
float unscalePID_i(float i);
......@@ -89,64 +76,33 @@ extern float current_temperature_bed;
//high level conversion routines, for use outside of temperature.cpp
//inline so that there is no performance decrease.
//deg=degreeCelsius
FORCE_INLINE float degHotend(uint8_t extruder) {
#ifndef SINGLENOZZLE
return current_temperature[extruder];
#if HOTENDS <= 1
#define HOTEND_ARG 0
#else
return current_temperature[0];
#define HOTEND_ARG hotend
#endif
}
#ifdef SHOW_TEMP_ADC_VALUES
FORCE_INLINE float rawHotendTemp(uint8_t extruder) {
#ifndef SINGLENOZZLE
return current_temperature_raw[extruder];
#else
return current_temperature_raw[0];
#endif
}
FORCE_INLINE float degHotend(uint8_t hotend) { return current_temperature[HOTEND_ARG]; }
FORCE_INLINE float degBed() { return current_temperature_bed; }
#ifdef SHOW_TEMP_ADC_VALUES
FORCE_INLINE float rawHotendTemp(uint8_t hotend) { return current_temperature_raw[HOTEND_ARG]; }
FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
#endif //SHOW_TEMP_ADC_VALUES
FORCE_INLINE float degBed() { return current_temperature_bed; }
FORCE_INLINE float degTargetHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG]; }
FORCE_INLINE float degTargetHotend(uint8_t extruder) {
#ifndef SINGLENOZZLE
return target_temperature[extruder];
#else
return target_temperature[0];
#endif
}
FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {
#ifndef SINGLENOZZLE
target_temperature[extruder] = celsius;
#else
target_temperature[0] = celsius;
#endif
}
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t hotend) { target_temperature[HOTEND_ARG] = celsius; }
FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }
FORCE_INLINE bool isHeatingHotend(uint8_t extruder) {
#ifndef SINGLENOZZLE
return target_temperature[extruder] > current_temperature[extruder];
#else
return target_temperature[0] > current_temperature[0];
#endif
}
FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; }
FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {
#ifndef SINGLENOZZLE
return target_temperature[extruder] < current_temperature[extruder];
#else
return target_temperature[0] < current_temperature[0];
#endif
}
FORCE_INLINE bool isCoolingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] < current_temperature[HOTEND_ARG]; }
FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
......@@ -155,7 +111,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
#define isHeatingHotend0() isHeatingHotend(0)
#define isCoolingHotend0() isCoolingHotend(0)
#if EXTRUDERS > 1 && !defined(SINGLENOZZLE)
#if HOTENDS > 1
#define degHotend1() degHotend(1)
#define degTargetHotend1() degTargetHotend(1)
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
......@@ -164,7 +120,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else
#define setTargetHotend1(_celsius) do{}while(0)
#endif
#if EXTRUDERS > 2 && !defined(SINGLENOZZLE)
#if HOTENDS > 2
#define degHotend2() degHotend(2)
#define degTargetHotend2() degTargetHotend(2)
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
......@@ -173,7 +129,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else
#define setTargetHotend2(_celsius) do{}while(0)
#endif
#if EXTRUDERS > 3 && !defined(SINGLENOZZLE)
#if HOTENDS > 3
#define degHotend3() degHotend(3)
#define degTargetHotend3() degTargetHotend(3)
#define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3)
......@@ -182,8 +138,8 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else
#define setTargetHotend3(_celsius) do{}while(0)
#endif
#if EXTRUDERS > 4
#error Invalid number of extruders
#if HOTENDS > 4
#error Invalid number of hotend
#endif
int getHeaterPower(int heater);
......@@ -212,7 +168,7 @@ FORCE_INLINE void autotempShutdown() {
#endif
}
void PID_autotune(float temp, int extruder, int ncycles);
void PID_autotune(float temp, int hotend, int ncycles);
void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans();
......
......@@ -214,8 +214,8 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
#endif //!ENCODER_RATE_MULTIPLIER
#define END_MENU() \
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
if ((uint8_t)(encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
if (encoderLine >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
} } while(0)
/** Used variables to keep track of the menu */
......@@ -446,7 +446,7 @@ static void lcd_main_menu() {
void lcd_set_home_offsets() {
for(int8_t i=0; i < NUM_AXIS; i++) {
if (i != E_AXIS) {
add_homing[i] -= current_position[i];
home_offset[i] -= current_position[i];
current_position[i] = 0.0;
}
}
......@@ -971,21 +971,21 @@ static void lcd_control_temperature_menu() {
#if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
#endif
#if EXTRUDERS > 1
#if HOTENDS > 1
#if TEMP_SENSOR_1 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
#endif
#if EXTRUDERS > 2
#if HOTENDS > 2
#if TEMP_SENSOR_2 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
#endif
#if EXTRUDERS > 3
#if HOTENDS > 3
#if TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
#endif
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
#endif //HOTENDS > 3
#endif //HOTENDS > 2
#endif //HOTENDS > 1
#if TEMP_SENSOR_BED != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
#endif
......@@ -997,42 +997,40 @@ static void lcd_control_temperature_menu() {
MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0);
#endif
#ifdef PIDTEMP
// set up temp variables - undo the default scaling
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[0]);
raw_Kd = unscalePID_d(Kd[0]);
MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp[0], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[1]);
raw_Kd = unscalePID_d(Kd[1]);
MENU_ITEM_EDIT(float52, MSG_PID_P " E2", &Kp[1], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E2", &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E2", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 1
#if EXTRUDERS > 2
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[2]);
raw_Kd = unscalePID_d(Kd[2]);
MENU_ITEM_EDIT(float52, MSG_PID_P " E3", &Kp[2], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E3", &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E3", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 2
#if EXTRUDERS > 3
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[3]);
raw_Kd = unscalePID_d(Kd[3]);
MENU_ITEM_EDIT(float52, MSG_PID_P " E4", &Kp[3], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E4", &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E4", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 2
#endif //SINGLENOZZLE
#if HOTENDS > 1
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[1]);
raw_Kd = unscalePID_d(Kd[1]);
MENU_ITEM_EDIT(float52, MSG_PID_P " E2", &Kp[1], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E2", &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E2", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //HOTENDS > 1
#if HOTENDS > 2
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[2]);
raw_Kd = unscalePID_d(Kd[2]);
MENU_ITEM_EDIT(float52, MSG_PID_P " E3", &Kp[2], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E3", &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E3", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //HOTENDS > 2
#if HOTENDS > 3
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[3]);
raw_Kd = unscalePID_d(Kd[3]);
MENU_ITEM_EDIT(float52, MSG_PID_P " E4", &Kp[3], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I " E4", &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E4", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //HOTENDS > 2
#endif //PIDTEMP
MENU_ITEM(submenu, MSG_PREHEAT_PLA_SETTINGS, lcd_control_temperature_preheat_pla_settings_menu);
MENU_ITEM(submenu, MSG_PREHEAT_ABS_SETTINGS, lcd_control_temperature_preheat_abs_settings_menu);
......
......@@ -380,57 +380,55 @@ static void lcd_set_custom_characters(
#endif
}
static void lcd_implementation_init(
static void lcd_implementation_init (
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
bool progress_bar_set=true
bool progress_bar_set = true
#endif
) {
){
#if defined(LCD_I2C_TYPE_PCF8575)
#if defined(LCD_I2C_TYPE_PCF8575)
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#ifdef LCD_I2C_PIN_BL
lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
lcd.setBacklight(HIGH);
#endif
#elif defined(LCD_I2C_TYPE_MCP23017)
#elif defined(LCD_I2C_TYPE_MCP23017)
lcd.setMCPType(LTI_TYPE_MCP23017);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.setBacklight(0); //set all the LEDs off to begin with
#elif defined(LCD_I2C_TYPE_MCP23008)
#elif defined(LCD_I2C_TYPE_MCP23008)
lcd.setMCPType(LTI_TYPE_MCP23008);
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#elif defined(LCD_I2C_TYPE_PCA8574)
lcd.init();
lcd.backlight();
#else
#elif defined(LCD_I2C_TYPE_PCA8574)
lcd.init();
lcd.backlight();
#else
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#endif
#endif
lcd_set_custom_characters(
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
progress_bar_set
#endif
);
lcd_set_custom_characters(
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
progress_bar_set
#endif
);
lcd.clear();
lcd.clear();
}
static void lcd_implementation_clear()
{
lcd.clear();
static void lcd_implementation_clear() {
lcd.clear();
}
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
static void lcd_printPGM(const char* str)
{
char c;
while((c = pgm_read_byte(str++)) != '\0')
{
lcd.write(c);
}
static void lcd_printPGM(const char* str) {
char c;
while((c = pgm_read_byte(str++)) != '\0')
{
lcd.write(c);
}
}
/*
Possible status screens:
16x2 |0123456789012345|
......@@ -459,145 +457,143 @@ Possible status screens:
|F100% SD100% T--:--|
|Status line.........|
*/
static void lcd_implementation_status_screen()
{
int tHotend=int(degHotend(0) + 0.5);
int tTarget=int(degTargetHotend(0) + 0.5);
#if LCD_WIDTH < 20
lcd.setCursor(0, 0);
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
static void lcd_implementation_status_screen() {
int tHotend=int(degHotend(0) + 0.5);
int tTarget=int(degTargetHotend(0) + 0.5);
# if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(8, 0);
# if EXTRUDERS > 1 && !defined(SINGLENOZZLE)
tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]);
# else//Heated bed
tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]);
# endif
#if LCD_WIDTH < 20
lcd.setCursor(0, 0);
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
# endif (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
#else//LCD_WIDTH > 19
#if HOTENDS > 1 || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(8, 0);
#if HOTENDS > 1
tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]);
#else//Heated bed
tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]);
#endif
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
#endif //HOTENDS > 1 || TEMP_SENSOR_BED != 0
#else//LCD_WIDTH > 19
lcd.setCursor(0, 0);
lcd.print(LCD_STR_THERMOMETER[0]);
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10)
lcd.print(' ');
# if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(10, 0);
# if EXTRUDERS > 1 && !defined(SINGLENOZZLE)
tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]);
# else//Heated bed
tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]);
# endif
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10)
lcd.print(' ');
# endif//(EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0
#endif//LCD_WIDTH > 19
#if LCD_HEIGHT > 2
//Lines 2 for 4 line LCD
# if LCD_WIDTH < 20
# ifdef SDSUPPORT
lcd.setCursor(0, 2);
lcd_printPGM(PSTR("SD"));
if (IS_SD_PRINTING)
lcd.print(itostr3(card.percentDone()));
else
lcd_printPGM(PSTR("---"));
lcd.print('%');
# endif//SDSUPPORT
# else//LCD_WIDTH > 19
# if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0 && !defined(SINGLENOZZLE)
//If we both have a 2nd extruder and a heated bed, show the heated bed temp on the 2nd line on the left, as the first line is filled with extruder temps
tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5);
lcd.setCursor(0, 1);
lcd.print(LCD_STR_BEDTEMP[0]);
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10)
lcd.print(' ');
# else
lcd.setCursor(0,1);
# ifdef DELTA
lcd.print('X');
lcd.print(ftostr30(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr30(current_position[Y_AXIS]));
# else
lcd.print('X');
lcd.print(ftostr3(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr3(current_position[Y_AXIS]));
# endif // DELTA
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
# endif//LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 8, 1);
lcd.print('Z');
lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
#endif//LCD_HEIGHT > 2
#if LCD_HEIGHT > 3
if (tTarget < 10) lcd.print(' ');
#if HOTENDS > 1 || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(10, 0);
#if HOTENDS > 1
tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]);
#else//Heated bed
tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]);
#endif
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10) lcd.print(' ');
#endif//HOTENDS > 1 || TEMP_SENSOR_BED != 0
#endif//LCD_WIDTH > 19
#if LCD_HEIGHT > 2
//Lines 2 for 4 line LCD
#if LCD_WIDTH < 20
#ifdef SDSUPPORT
lcd.setCursor(0, 2);
lcd_printPGM(PSTR("SD"));
if (IS_SD_PRINTING)
lcd.print(itostr3(card.percentDone()));
else
lcd_printPGM(PSTR("---"));
lcd.print('%');
#endif//SDSUPPORT
#else //LCD_WIDTH > 19
#if HOTENDS > 1 && TEMP_SENSOR_BED != 0
//If we both have a 2nd extruder and a heated bed, show the heated bed temp on the 2nd line on the left, as the first line is filled with extruder temps
tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5);
lcd.setCursor(0, 1);
lcd.print(LCD_STR_BEDTEMP[0]);
lcd.print(itostr3(tHotend));
lcd.print('/');
lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10) lcd.print(' ');
#else
lcd.setCursor(0,1);
#ifdef DELTA
lcd.print('X');
lcd.print(ftostr30(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr30(current_position[Y_AXIS]));
#else
lcd.print('X');
lcd.print(ftostr3(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr3(current_position[Y_AXIS]));
#endif // DELTA
#endif //HOTENDS > 1 || TEMP_SENSOR_BED != 0
#endif //LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 8, 1);
lcd.print('Z');
lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
#endif //LCD_HEIGHT > 2
#if LCD_HEIGHT > 3
lcd.setCursor(0, 2);
lcd.print(LCD_STR_FEEDRATE[0]);
lcd.print(itostr3(feedmultiply));
lcd.print('%');
# if LCD_WIDTH > 19
# ifdef SDSUPPORT
lcd.setCursor(7, 2);
lcd_printPGM(PSTR("SD"));
if (IS_SD_PRINTING)
lcd.print(itostr3(card.percentDone()));
else
lcd_printPGM(PSTR("---"));
lcd.print('%');
# endif//SDSUPPORT
# endif//LCD_WIDTH > 19
#if LCD_WIDTH > 19
#ifdef SDSUPPORT
lcd.setCursor(7, 2);
lcd_printPGM(PSTR("SD"));
if (IS_SD_PRINTING)
lcd.print(itostr3(card.percentDone()));
else
lcd_printPGM(PSTR("---"));
lcd.print('%');
#endif //SDSUPPORT
#endif //LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 6, 2);
lcd.print(LCD_STR_CLOCK[0]);
if(starttime != 0)
{
uint16_t time = millis()/60000 - starttime/60000;
lcd.print(itostr2(time/60));
lcd.print(':');
lcd.print(itostr2(time%60));
}else{
lcd_printPGM(PSTR("--:--"));
uint16_t time = millis()/60000 - starttime/60000;
lcd.print(itostr2(time/60));
lcd.print(':');
lcd.print(itostr2(time%60));
}
#endif
else
{
lcd_printPGM(PSTR("--:--"));
}
#endif
// Status message line at the bottom
lcd.setCursor(0, LCD_HEIGHT - 1);
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
if (card.isFileOpen()) {
uint16_t mil = millis(), diff = mil - progressBarTick;
if (diff >= PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
......@@ -627,8 +623,8 @@ static void lcd_implementation_status_screen()
lcd.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" V"));
lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
lcd.print('%');
return;
lcd.print('%');
return;
}
#endif //FILAMENT_LCD_DISPLAY
......@@ -649,6 +645,7 @@ static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const cha
lcd.print(post_char);
lcd.print(' ');
}
static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) {
char c;
uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen(data);
......@@ -663,6 +660,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t r
while (n--) lcd.print(' ');
lcd.print(data);
}
static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) {
char c;
uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen_P(data);
......@@ -677,6 +675,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t
while (n--) lcd.print(' ');
lcd_printPGM(data);
}
#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', itostr3(*(data)))
#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr3(*(data)))
#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, '>', ftostr32(*(data)))
......@@ -705,6 +704,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
lcd.setCursor(LCD_WIDTH - (LCD_WIDTH < 20 ? 0 : 1) - lcd_strlen(value), 1);
lcd.print(value);
}
static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat) {
char c;
uint8_t n = LCD_WIDTH - concat;
......@@ -725,9 +725,11 @@ static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* ps
static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 1);
}
static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2);
}
#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
......@@ -769,7 +771,7 @@ static void lcd_implementation_update_indicators()
if (target_temperature_bed > 0) leds |= LED_A;
if (target_temperature[0] > 0) leds |= LED_B;
if (fanSpeed) leds |= LED_C;
#if EXTRUDERS > 1 && !defined(SINGLENOZZLE)
#if HOTENDS > 1
if (target_temperature[1] > 0) leds |= LED_C;
#endif
if (leds != ledsprev) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment