Commit 046d5eff authored by MagoKimbra's avatar MagoKimbra

Update more function

parent 72c7bdc1
...@@ -75,6 +75,11 @@ ...@@ -75,6 +75,11 @@
// This is used for single nozzle and multiple extrusion configuration // This is used for single nozzle and multiple extrusion configuration
// Uncomment below to enable (One Hotend) // Uncomment below to enable (One Hotend)
//#define SINGLENOZZLE //#define SINGLENOZZLE
#ifdef SINGLENOZZLE
#define HOTENDS 1
#else
#define HOTENDS EXTRUDERS
#endif
/*********************************************************************** /***********************************************************************
*********************** Multiextruder MKR4 *************************** *********************** Multiextruder MKR4 ***************************
...@@ -646,6 +651,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -646,6 +651,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec.
//#define FILAMENT_LCD_DISPLAY //#define FILAMENT_LCD_DISPLAY
/**********************************************************************\ /**********************************************************************\
* Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption * Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption
* Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable. * Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable.
...@@ -653,7 +659,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -653,7 +659,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
* With this module we measure the Printer power consumption ignoring the Power Supply power consumption, so we consider the EFFICIENCY of our supply to be 100% so without * With this module we measure the Printer power consumption ignoring the Power Supply power consumption, so we consider the EFFICIENCY of our supply to be 100% so without
* any power dispersion. If you want to approximately add the supply consumption you can decrease the EFFICIENCY to a value less than 100. Eg: 85 is a good value. * any power dispersion. If you want to approximately add the supply consumption you can decrease the EFFICIENCY to a value less than 100. Eg: 85 is a good value.
* You can find a better value measuring the AC current with a good multimeter and moltiple it with the mains voltage. * You can find a better value measuring the AC current with a good multimeter and moltiple it with the mains voltage.
* MULTIMETER_WATT := MULTIMETER_CURRENT*MAINS_VOLTAGE * MULTIMETER_WATT := MULTIMETER_CURRENT * MAINS_VOLTAGE
* Now you have a Wattage value that you can compare with the one measured from ACS712. * Now you have a Wattage value that you can compare with the one measured from ACS712.
* NEW_EFFICENCY := (SENSOR_WATT*EFFICIENCY)/MULTIMETER_WATT * NEW_EFFICENCY := (SENSOR_WATT*EFFICIENCY)/MULTIMETER_WATT
* For now this feature is to be consider BETA as i'll have to do some accurate test to see the affidability * For now this feature is to be consider BETA as i'll have to do some accurate test to see the affidability
...@@ -668,6 +674,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -668,6 +674,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
//When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec. //When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec.
//#define POWER_CONSUMPTION_LCD_DISPLAY //#define POWER_CONSUMPTION_LCD_DISPLAY
//=================================== Misc ================================= //=================================== Misc =================================
// Temperature status LEDs that display the hotend and bet temperature. // Temperature status LEDs that display the hotend and bet temperature.
......
...@@ -63,10 +63,10 @@ void Config_StoreSettings() { ...@@ -63,10 +63,10 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, max_xy_jerk); EEPROM_WRITE_VAR(i, max_xy_jerk);
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, home_offset);
EEPROM_WRITE_VAR(i, zprobe_zoffset); EEPROM_WRITE_VAR(i, zprobe_zoffset);
#if EXTRUDERS > 1 && !defined SINGLENOZZLE #if HOTENDS > 1
EEPROM_WRITE_VAR(i, hotend_offset); EEPROM_WRITE_VAR(i, hotend_offset);
#endif #endif
...@@ -150,39 +150,39 @@ void Config_RetrieveSettings() ...@@ -150,39 +150,39 @@ void Config_RetrieveSettings()
if (strncmp(ver,stored_ver,3) == 0) if (strncmp(ver,stored_ver,3) == 0)
{ {
// version number match // 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; 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, axis_steps_per_unit);
EEPROM_READ_VAR(i,max_feedrate); EEPROM_READ_VAR(i, max_feedrate);
EEPROM_READ_VAR(i,max_retraction_feedrate); EEPROM_READ_VAR(i, max_retraction_feedrate);
EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second); 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) // 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(); reset_acceleration_rates();
EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i, acceleration);
EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i, retract_acceleration);
EEPROM_READ_VAR(i, travel_acceleration); EEPROM_READ_VAR(i, travel_acceleration);
EEPROM_READ_VAR(i,minimumfeedrate); EEPROM_READ_VAR(i, minimumfeedrate);
EEPROM_READ_VAR(i,mintravelfeedrate); EEPROM_READ_VAR(i, mintravelfeedrate);
EEPROM_READ_VAR(i,minsegmenttime); EEPROM_READ_VAR(i, minsegmenttime);
EEPROM_READ_VAR(i,max_xy_jerk); EEPROM_READ_VAR(i, max_xy_jerk);
EEPROM_READ_VAR(i,max_z_jerk); EEPROM_READ_VAR(i, max_z_jerk);
EEPROM_READ_VAR(i,max_e_jerk); EEPROM_READ_VAR(i, max_e_jerk);
EEPROM_READ_VAR(i,add_homing); EEPROM_READ_VAR(i, home_offset);
EEPROM_READ_VAR(i,zprobe_zoffset); EEPROM_READ_VAR(i, zprobe_zoffset);
#if EXTRUDERS > 1 && !defined SINGLENOZZLE #if HOTENDS > 1
EEPROM_READ_VAR(i, hotend_offset); EEPROM_READ_VAR(i, hotend_offset);
#endif #endif
#ifdef DELTA #ifdef DELTA
EEPROM_READ_VAR(i,endstop_adj); EEPROM_READ_VAR(i, endstop_adj);
EEPROM_READ_VAR(i,delta_radius); EEPROM_READ_VAR(i, delta_radius);
EEPROM_READ_VAR(i,delta_diagonal_rod); EEPROM_READ_VAR(i, delta_diagonal_rod);
EEPROM_READ_VAR(i,max_pos); EEPROM_READ_VAR(i, max_pos);
EEPROM_READ_VAR(i,tower_adj); EEPROM_READ_VAR(i, tower_adj);
EEPROM_READ_VAR(i,z_probe_offset); EEPROM_READ_VAR(i, z_probe_offset);
// Update delta constants for updated delta_radius & tower_adj values // Update delta constants for updated delta_radius & tower_adj values
set_delta_constants(); set_delta_constants();
#endif //DELTA #endif //DELTA
...@@ -193,46 +193,46 @@ void Config_RetrieveSettings() ...@@ -193,46 +193,46 @@ void Config_RetrieveSettings()
int gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed; int gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed;
#endif #endif
EEPROM_READ_VAR(i,plaPreheatHotendTemp); EEPROM_READ_VAR(i, plaPreheatHotendTemp);
EEPROM_READ_VAR(i,plaPreheatHPBTemp); EEPROM_READ_VAR(i, plaPreheatHPBTemp);
EEPROM_READ_VAR(i,plaPreheatFanSpeed); EEPROM_READ_VAR(i, plaPreheatFanSpeed);
EEPROM_READ_VAR(i,absPreheatHotendTemp); EEPROM_READ_VAR(i, absPreheatHotendTemp);
EEPROM_READ_VAR(i,absPreheatHPBTemp); EEPROM_READ_VAR(i, absPreheatHPBTemp);
EEPROM_READ_VAR(i,absPreheatFanSpeed); EEPROM_READ_VAR(i, absPreheatFanSpeed);
EEPROM_READ_VAR(i,gumPreheatHotendTemp); EEPROM_READ_VAR(i, gumPreheatHotendTemp);
EEPROM_READ_VAR(i,gumPreheatHPBTemp); EEPROM_READ_VAR(i, gumPreheatHPBTemp);
EEPROM_READ_VAR(i,gumPreheatFanSpeed); EEPROM_READ_VAR(i, gumPreheatFanSpeed);
#ifdef PIDTEMP #ifdef PIDTEMP
// do not need to scale PID values as the values in EEPROM are already scaled // do not need to scale PID values as the values in EEPROM are already scaled
EEPROM_READ_VAR(i,Kp); EEPROM_READ_VAR(i, Kp);
EEPROM_READ_VAR(i,Ki); EEPROM_READ_VAR(i, Ki);
EEPROM_READ_VAR(i,Kd); EEPROM_READ_VAR(i, Kd);
#endif // PIDTEMP #endif // PIDTEMP
#if !defined(DOGLCD) || LCD_CONTRAST < 0 #if !defined(DOGLCD) || LCD_CONTRAST < 0
int lcd_contrast; int lcd_contrast;
#endif //DOGLCD #endif //DOGLCD
EEPROM_READ_VAR(i,lcd_contrast); EEPROM_READ_VAR(i, lcd_contrast);
#ifdef SCARA #ifdef SCARA
EEPROM_READ_VAR(i,axis_scaling); EEPROM_READ_VAR(i, axis_scaling);
#endif //SCARA #endif //SCARA
#ifdef FWRETRACT #ifdef FWRETRACT
EEPROM_READ_VAR(i,autoretract_enabled); EEPROM_READ_VAR(i, autoretract_enabled);
EEPROM_READ_VAR(i,retract_length); EEPROM_READ_VAR(i, retract_length);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_length_swap); EEPROM_READ_VAR(i, retract_length_swap);
#endif //EXTRUDERS > 1 #endif //EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_feedrate); EEPROM_READ_VAR(i, retract_feedrate);
EEPROM_READ_VAR(i,retract_zlift); EEPROM_READ_VAR(i, retract_zlift);
EEPROM_READ_VAR(i,retract_recover_length); EEPROM_READ_VAR(i, retract_recover_length);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_length_swap); EEPROM_READ_VAR(i, retract_recover_length_swap);
#endif //EXTRUDERS > 1 #endif //EXTRUDERS > 1
EEPROM_READ_VAR(i,retract_recover_feedrate); EEPROM_READ_VAR(i, retract_recover_feedrate);
#endif //FWRETRACT #endif //FWRETRACT
EEPROM_READ_VAR(i, volumetric_enabled); EEPROM_READ_VAR(i, volumetric_enabled);
...@@ -294,7 +294,7 @@ void Config_ResetDefault() ...@@ -294,7 +294,7 @@ void Config_ResetDefault()
for (int i = 0; i < EXTRUDERS; i++) { for (int i = 0; i < EXTRUDERS; i++) {
max_retraction_feedrate[i] = tmp3[i]; max_retraction_feedrate[i] = tmp3[i];
#if EXTRUDERS > 1 && !defined SINGLENOZZLE #if HOTENDS > 1
hotend_offset[X_AXIS][i] = tmp8[i]; hotend_offset[X_AXIS][i] = tmp8[i];
hotend_offset[Y_AXIS][i] = tmp9[i]; hotend_offset[Y_AXIS][i] = tmp9[i];
#endif #endif
...@@ -316,7 +316,7 @@ void Config_ResetDefault() ...@@ -316,7 +316,7 @@ void Config_ResetDefault()
max_xy_jerk = DEFAULT_XYJERK; max_xy_jerk = DEFAULT_XYJERK;
max_z_jerk = DEFAULT_ZJERK; max_z_jerk = DEFAULT_ZJERK;
max_e_jerk = DEFAULT_EJERK; 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 #ifdef ENABLE_AUTO_BED_LEVELING
zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER; zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
...@@ -351,11 +351,7 @@ void Config_ResetDefault() ...@@ -351,11 +351,7 @@ void Config_ResetDefault()
#endif //DOGLCD #endif //DOGLCD
#ifdef PIDTEMP #ifdef PIDTEMP
#ifndef SINGLENOZZLE for (int e = 0; e < HOTENDS; e++)
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0; // only need to write once
#endif //SINGLENOZZLE
{ {
Kp[e] = tmp5[e]; Kp[e] = tmp5[e];
Ki[e] = scalePID_i(tmp6[e]); Ki[e] = scalePID_i(tmp6[e]);
...@@ -405,16 +401,16 @@ void Config_PrintSettings() ...@@ -405,16 +401,16 @@ void Config_PrintSettings()
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHOLNPGM("Steps per unit:"); SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]); SERIAL_ECHOPAIR(" M92 X", axis_steps_per_unit[X_AXIS]);
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
...@@ -424,17 +420,17 @@ void Config_PrintSettings() ...@@ -424,17 +420,17 @@ void Config_PrintSettings()
#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]);
SERIAL_ECHOPAIR(" Y",axis_scaling[Y_AXIS]); SERIAL_ECHOPAIR(" Y", axis_scaling[Y_AXIS]);
SERIAL_ECHOPAIR(" Z",axis_scaling[Z_AXIS]); SERIAL_ECHOPAIR(" Z", axis_scaling[Z_AXIS]);
SERIAL_EOL; SERIAL_EOL;
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;
SERIAL_ECHOPAIR(" M203 X",max_feedrate[X_AXIS]); SERIAL_ECHOPAIR(" M203 X", max_feedrate[X_AXIS]);
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 S", max_feedrate[E_AXIS + 0]); SERIAL_ECHOPAIR(" E0 S", max_feedrate[E_AXIS + 0]);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
...@@ -452,11 +448,11 @@ void Config_PrintSettings() ...@@ -452,11 +448,11 @@ void Config_PrintSettings()
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
...@@ -464,16 +460,16 @@ void Config_PrintSettings() ...@@ -464,16 +460,16 @@ void Config_PrintSettings()
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[X_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(" 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 S" ,max_acceleration_units_per_sq_second[E_AXIS]); SERIAL_ECHOPAIR(" E0 S", max_acceleration_units_per_sq_second[E_AXIS]);
#if EXTRUDERS > 1 #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 #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 #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 > 3
#endif //EXTRUDERS > 2 #endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1 #endif //EXTRUDERS > 1
...@@ -481,7 +477,7 @@ void Config_PrintSettings() ...@@ -481,7 +477,7 @@ void Config_PrintSettings()
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel"); SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M204 P",acceleration ); SERIAL_ECHOPAIR(" M204 P", acceleration );
SERIAL_ECHOPAIR(" R", retract_acceleration); SERIAL_ECHOPAIR(" R", retract_acceleration);
SERIAL_ECHOPAIR(" T", travel_acceleration); SERIAL_ECHOPAIR(" T", travel_acceleration);
SERIAL_EOL; SERIAL_EOL;
...@@ -489,65 +485,65 @@ void Config_PrintSettings() ...@@ -489,65 +485,65 @@ void Config_PrintSettings()
SERIAL_ECHO_START; 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_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_ECHO_START;
SERIAL_ECHOPAIR(" M205 S",minimumfeedrate ); SERIAL_ECHOPAIR(" M205 S", minimumfeedrate );
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate ); SERIAL_ECHOPAIR(" T", mintravelfeedrate );
SERIAL_ECHOPAIR(" B" ,minsegmenttime ); SERIAL_ECHOPAIR(" B", minsegmenttime );
SERIAL_ECHOPAIR(" X" ,max_xy_jerk ); SERIAL_ECHOPAIR(" X", max_xy_jerk );
SERIAL_ECHOPAIR(" Z" ,max_z_jerk); SERIAL_ECHOPAIR(" Z", max_z_jerk);
SERIAL_ECHOPAIR(" E" ,max_e_jerk); SERIAL_ECHOPAIR(" E", max_e_jerk);
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Home offset (mm):"); SERIAL_ECHOLNPGM("Home offset (mm):");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M206 X",add_homing[X_AXIS] ); SERIAL_ECHOPAIR(" M206 X", home_offset[X_AXIS] );
SERIAL_ECHOPAIR(" Y" ,add_homing[Y_AXIS] ); SERIAL_ECHOPAIR(" Y", home_offset[Y_AXIS] );
SERIAL_ECHOPAIR(" Z" ,add_homing[Z_AXIS] ); SERIAL_ECHOPAIR(" Z", home_offset[Z_AXIS] );
SERIAL_EOL; SERIAL_EOL;
#if EXTRUDERS > 1 && !defined SINGLENOZZLE #if HOTENDS > 1
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Hotend offset (mm):"); SERIAL_ECHOLNPGM("Hotend offset (mm):");
for (int e = 0; e < EXTRUDERS; e++) { for (int e = 0; e < HOTENDS; e++) {
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M218 T", (long unsigned int)e); SERIAL_ECHOPAIR(" M218 T", (long unsigned int)e);
SERIAL_ECHOPAIR(" X", hotend_offset[X_AXIS][e]); SERIAL_ECHOPAIR(" X", hotend_offset[X_AXIS][e]);
SERIAL_ECHOPAIR(" Y" ,hotend_offset[Y_AXIS][e]); SERIAL_ECHOPAIR(" Y" ,hotend_offset[Y_AXIS][e]);
SERIAL_EOL; SERIAL_EOL;
} }
#endif //EXTRUDERS > 1 && !defined SINGLENOZZLE #endif //HOTENDS > 1
#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;
SERIAL_ECHOPAIR(" M666 X",endstop_adj[0]); SERIAL_ECHOPAIR(" M666 X", endstop_adj[0]);
SERIAL_ECHOPAIR(" Y" ,endstop_adj[1]); SERIAL_ECHOPAIR(" Y", endstop_adj[1]);
SERIAL_ECHOPAIR(" Z" ,endstop_adj[2]); SERIAL_ECHOPAIR(" Z", endstop_adj[2]);
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Delta Geometry adjustment:"); SERIAL_ECHOLNPGM("Delta Geometry adjustment:");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M666 A",tower_adj[0]); SERIAL_ECHOPAIR(" M666 A", tower_adj[0]);
SERIAL_ECHOPAIR(" B" ,tower_adj[1]); SERIAL_ECHOPAIR(" B", tower_adj[1]);
SERIAL_ECHOPAIR(" C" ,tower_adj[2]); SERIAL_ECHOPAIR(" C", tower_adj[2]);
SERIAL_ECHOPAIR(" E" ,tower_adj[3]); SERIAL_ECHOPAIR(" E", tower_adj[3]);
SERIAL_ECHOPAIR(" F" ,tower_adj[4]); SERIAL_ECHOPAIR(" F", tower_adj[4]);
SERIAL_ECHOPAIR(" G" ,tower_adj[5]); SERIAL_ECHOPAIR(" G", tower_adj[5]);
SERIAL_ECHOPAIR(" R" ,delta_radius); SERIAL_ECHOPAIR(" R", delta_radius);
SERIAL_ECHOPAIR(" D" ,delta_diagonal_rod); SERIAL_ECHOPAIR(" D", delta_diagonal_rod);
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_EOL; SERIAL_EOL;
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);
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHOPAIR("Tower2 X:",delta_tower2_x); SERIAL_ECHOPAIR("Tower2 X:", delta_tower2_x);
SERIAL_ECHOPAIR(" Y:",delta_tower2_y); SERIAL_ECHOPAIR(" Y:", delta_tower2_y);
SERIAL_EOL; SERIAL_EOL;
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_EOL; SERIAL_EOL;
#endif // DELTA #endif // DELTA
...@@ -555,24 +551,20 @@ void Config_PrintSettings() ...@@ -555,24 +551,20 @@ void Config_PrintSettings()
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_EOL; SERIAL_EOL;
#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 for (int e = 0; e < HOTENDS; e++)
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif
{ {
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M301 E", (long unsigned int)e); SERIAL_ECHOPAIR(" M301 E", (long unsigned int)e);
SERIAL_ECHOPAIR(" P", Kp[e]); SERIAL_ECHOPAIR(" P", Kp[e]);
SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki[e])); SERIAL_ECHOPAIR(" I", unscalePID_i(Ki[e]));
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[e])); SERIAL_ECHOPAIR(" D", unscalePID_d(Kd[e]));
SERIAL_EOL; SERIAL_EOL;
} }
#endif // PIDTEMP #endif // PIDTEMP
...@@ -581,15 +573,15 @@ void Config_PrintSettings() ...@@ -581,15 +573,15 @@ void Config_PrintSettings()
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;
SERIAL_ECHOPAIR(" M207 S",retract_length); SERIAL_ECHOPAIR(" M207 S", retract_length);
SERIAL_ECHOPAIR(" F" ,retract_feedrate*60); SERIAL_ECHOPAIR(" F", retract_feedrate*60);
SERIAL_ECHOPAIR(" Z" ,retract_zlift); SERIAL_ECHOPAIR(" Z", retract_zlift);
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)"); SERIAL_ECHOLNPGM("Recover: S=Extra length (mm) F:Speed (mm/m)");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M208 S",retract_recover_length); SERIAL_ECHOPAIR(" M208 S", retract_recover_length);
SERIAL_ECHOPAIR(" F" ,retract_recover_feedrate*60); SERIAL_ECHOPAIR(" F", retract_recover_feedrate*60);
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Auto-Retract: S=0 to disable, 1 to interpret extrude-only moves as retracts or recoveries"); 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 ...@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the log
#ifdef AUTO_BED_LEVELING_GRID #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 #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension // 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 ...@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#ifdef AUTO_BED_LEVELING_GRID #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 #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension // 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 ...@@ -150,11 +150,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the log
#ifdef AUTO_BED_LEVELING_GRID #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 #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension // Set the number of grid points per dimension
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#if defined(EXTRUDER_RUNOUT_PREVENT) && defined(IDLE_OOZING_PREVENT) #if defined(EXTRUDER_RUNOUT_PREVENT) && defined(IDLE_OOZING_PREVENT)
#error EXTRUDER_RUNOUT_PREVENT and IDLE_OOZING_PREVENT are incopatible. Please comment one of them. #error EXTRUDER_RUNOUT_PREVENT and IDLE_OOZING_PREVENT are incopatible. Please comment one of them.
#endif #endif
//These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements. //These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
//The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET" //The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
#define TEMP_SENSOR_AD595_OFFSET 0.0 #define TEMP_SENSOR_AD595_OFFSET 0.0
...@@ -486,6 +487,12 @@ const unsigned int dropsegments=5; //everything with less than this number of st ...@@ -486,6 +487,12 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#endif #endif
#endif #endif
#ifdef FILAMENTCHANGEENABLE
#ifdef EXTRUDER_RUNOUT_PREVENT
#error EXTRUDER_RUNOUT_PREVENT currently incompatible with FILAMENTCHANGE
#endif
#endif
/******************************************************************************\ /******************************************************************************\
* enable this section if you have TMC26X motor drivers. * enable this section if you have TMC26X motor drivers.
......
...@@ -252,19 +252,17 @@ extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in m ...@@ -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 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 current_position[NUM_AXIS];
extern float destination[NUM_AXIS]; extern float destination[NUM_AXIS];
extern float add_homing[3]; extern float home_offset[3];
// Extruder offset // Hotend offset
#if EXTRUDERS > 1 #if HOTENDS > 1
#ifndef SINGLENOZZLE
#ifndef DUAL_X_CARRIAGE #ifndef DUAL_X_CARRIAGE
#define NUM_HOTEND_OFFSETS 2 // only in XY plane #define NUM_HOTEND_OFFSETS 2 // only in XY plane
#else #else
#define NUM_HOTEND_OFFSETS 3 // supports offsets in XYZ plane #define NUM_HOTEND_OFFSETS 3 // supports offsets in XYZ plane
#endif #endif
extern float hotend_offset[NUM_HOTEND_OFFSETS][EXTRUDERS]; extern float hotend_offset[NUM_HOTEND_OFFSETS][HOTENDS];
#endif // end SINGLENOZZLE #endif // HOTENDS > 1
#endif // end EXTRUDERS
#ifdef NPR2 #ifdef NPR2
extern int old_color; // old color for system NPR2 extern int old_color; // old color for system NPR2
...@@ -300,7 +298,7 @@ extern int EtoPPressure; ...@@ -300,7 +298,7 @@ extern int EtoPPressure;
extern unsigned char fanSpeedSoftPwm; extern unsigned char fanSpeedSoftPwm;
#endif #endif
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0)
extern float filament_width_nominal; //holds the theoretical filament diameter ie., 3.00 or 1.75 extern float filament_width_nominal; //holds the theoretical filament diameter ie., 3.00 or 1.75
extern bool filament_sensor; //indicates that filament sensor readings should control extrusion extern bool filament_sensor; //indicates that filament sensor readings should control extrusion
extern float filament_width_meas; //holds the filament diameter as accurately measured extern float filament_width_meas; //holds the filament diameter as accurately measured
...@@ -314,6 +312,7 @@ extern unsigned char fanSpeedSoftPwm; ...@@ -314,6 +312,7 @@ extern unsigned char fanSpeedSoftPwm;
extern unsigned int power_consumption_meas; //holds the power consumption as accurately measured extern unsigned int power_consumption_meas; //holds the power consumption as accurately measured
extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured
#endif #endif
#ifdef FWRETRACT #ifdef FWRETRACT
extern bool autoretract_enabled; extern bool autoretract_enabled;
extern bool retracted[EXTRUDERS]; extern bool retracted[EXTRUDERS];
......
...@@ -245,7 +245,7 @@ float volumetric_multiplier[EXTRUDERS] = {1.0 ...@@ -245,7 +245,7 @@ float volumetric_multiplier[EXTRUDERS] = {1.0
}; };
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.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 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; int fanSpeed = 0;
bool cancel_heatup = false; bool cancel_heatup = false;
...@@ -294,29 +294,27 @@ bool axis_known_position[3] = { false, false, false }; ...@@ -294,29 +294,27 @@ bool axis_known_position[3] = { false, false, false };
float zprobe_zoffset; float zprobe_zoffset;
float lastpos[4]; float lastpos[4];
// Extruder offset // Hotend offset
#ifndef SINGLENOZZLE #if HOTENDS > 1
#if EXTRUDERS > 1
#ifndef DUAL_X_CARRIAGE #ifndef DUAL_X_CARRIAGE
#define NUM_EXTRUDER_OFFSETS 2 // only in XY plane #define NUM_HOTENDS_OFFSETS 2 // only in XY plane
#else #else
#define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane #define NUM_HOTENDS_OFFSETS 3 // supports offsets in XYZ plane
#endif #endif
float hotend_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = { float hotend_offset[NUM_HOTENDS_OFFSETS][HOTENDS] = {
#if defined(EXTRUDER_OFFSET_X) #if defined(HOTEND_OFFSET_X)
EXTRUDER_OFFSET_X HOTEND_OFFSET_X
#else #else
0 0
#endif #endif
, ,
#if defined(EXTRUDER_OFFSET_Y) #if defined(HOTEND_OFFSET_Y)
EXTRUDER_OFFSET_Y HOTEND_OFFSET_Y
#else #else
0 0
#endif #endif
}; };
#endif //EXTRUDERS > 1 #endif //HOTENDS > 1
#endif //SINGLENOZZLE
uint8_t active_extruder = 0; uint8_t active_extruder = 0;
...@@ -333,13 +331,15 @@ uint8_t debugLevel = 0; ...@@ -333,13 +331,15 @@ uint8_t debugLevel = 0;
int EtoPPressure = 0; int EtoPPressure = 0;
#endif //BARICUDA #endif //BARICUDA
#ifdef FILAMENTCHANGEENABLE #if defined(FILAMENTCHANGEENABLE) || defined(IDLE_OOZING_PREVENT)
bool filament_changing = false; bool filament_changing = false;
#endif #endif
#ifdef IDLE_OOZING_PREVENT || EXTRUDER_RUNOUT_PREVENT
#if defined(IDLE_OOZING_PREVENT) || defined(EXTRUDER_RUNOUT_PREVENT)
unsigned long axis_last_activity = 0; unsigned long axis_last_activity = 0;
bool axis_is_moving = false; bool axis_is_moving = false;
#endif #endif
#ifdef IDLE_OOZING_PREVENT #ifdef IDLE_OOZING_PREVENT
bool IDLE_OOZING_retracted[EXTRUDERS] = { false bool IDLE_OOZING_retracted[EXTRUDERS] = { false
#if EXTRUDERS > 1 #if EXTRUDERS > 1
...@@ -348,9 +348,9 @@ uint8_t debugLevel = 0; ...@@ -348,9 +348,9 @@ uint8_t debugLevel = 0;
, false , false
#if EXTRUDERS > 3 #if EXTRUDERS > 3
, false , false
#endif #endif //EXTRUDERS > 3
#endif #endif //EXTRUDERS > 2
#endif #endif //EXTRUDERS > 1
}; };
#endif #endif
...@@ -400,7 +400,7 @@ uint8_t debugLevel = 0; ...@@ -400,7 +400,7 @@ uint8_t debugLevel = 0;
static float delta[3] = { 0, 0, 0 }; static float delta[3] = { 0, 0, 0 };
#endif //SCARA #endif //SCARA
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0)
//Variables for Filament Sensor input //Variables for Filament Sensor input
float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off
...@@ -412,7 +412,7 @@ uint8_t debugLevel = 0; ...@@ -412,7 +412,7 @@ uint8_t debugLevel = 0;
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
#endif #endif
#if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) #if defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0
unsigned int power_consumption_meas = 0; unsigned int power_consumption_meas = 0;
unsigned long power_consumption_hour = 0.0; unsigned long power_consumption_hour = 0.0;
#endif #endif
...@@ -1097,13 +1097,13 @@ static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; ...@@ -1097,13 +1097,13 @@ static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
static float x_home_pos(int extruder) { static float x_home_pos(int extruder) {
if (extruder == 0) if (extruder == 0)
return base_home_pos(X_AXIS) + add_homing[X_AXIS]; return base_home_pos(X_AXIS) + home_offset[X_AXIS];
else else
// In dual carriage mode the extruder offset provides an override of the // In dual carriage mode the extruder offset provides an override of the
// second X-carriage offset when homed - otherwise X2_HOME_POS is used. // 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 // This allow soft recalibration of the second extruder offset position without firmware reflash
// (through the M218 command). // (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) { static int x_home_dir(int extruder) {
...@@ -1133,9 +1133,9 @@ bool extruder_duplication_enabled = false; // used in mode 2 ...@@ -1133,9 +1133,9 @@ bool extruder_duplication_enabled = false; // used in mode 2
} }
else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && active_extruder == 0) 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]; current_position[X_AXIS] = base_home_pos(X_AXIS) + home_offset[X_AXIS];
min_pos[X_AXIS] = base_min_pos(X_AXIS) + add_homing[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) + add_homing[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); max(hotend_offset[X_AXIS][1], X2_MAX_POS) - duplicate_extruder_x_offset);
return; return;
} }
...@@ -1160,11 +1160,11 @@ bool extruder_duplication_enabled = false; // used in mode 2 ...@@ -1160,11 +1160,11 @@ bool extruder_duplication_enabled = false; // used in mode 2
// SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); // SERIAL_ECHOPGM(" base Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]);
for (i=0; i<2; i++) { 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 X="); SERIAL_ECHO(home_offset[X_AXIS]);
// SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(add_homing[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Y="); SERIAL_ECHO(home_offset[Y_AXIS]);
// SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]); // SERIAL_ECHOPGM(" addhome Theta="); SERIAL_ECHO(delta[X_AXIS]);
// SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]); // SERIAL_ECHOPGM(" addhome Psi+Theta="); SERIAL_ECHOLN(delta[Y_AXIS]);
...@@ -1182,14 +1182,14 @@ bool extruder_duplication_enabled = false; // used in mode 2 ...@@ -1182,14 +1182,14 @@ bool extruder_duplication_enabled = false; // used in mode 2
} }
else else
{ {
current_position[axis] = base_home_pos(axis) + add_homing[axis]; current_position[axis] = base_home_pos(axis) + home_offset[axis];
min_pos[axis] = base_min_pos(axis) + add_homing[axis]; min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos(axis) + add_homing[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis];
} }
#else // NO SCARA #else // NO SCARA
current_position[axis] = base_home_pos(axis) + add_homing[axis]; current_position[axis] = base_home_pos(axis) + home_offset[axis];
min_pos[axis] = base_min_pos(axis) + add_homing[axis]; min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos(axis) + add_homing[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis];
#endif // SCARA #endif // SCARA
} }
...@@ -1350,10 +1350,15 @@ bool extruder_duplication_enabled = false; // used in mode 2 ...@@ -1350,10 +1350,15 @@ bool extruder_duplication_enabled = false; // used in mode 2
#endif //NUM_SERVOS > 0 #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 // 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 // move to right place
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); 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]); do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
...@@ -1462,9 +1467,9 @@ bool extruder_duplication_enabled = false; // used in mode 2 ...@@ -1462,9 +1467,9 @@ bool extruder_duplication_enabled = false; // used in mode 2
#ifdef DELTA #ifdef DELTA
static void axis_is_at_home(int axis) static void axis_is_at_home(int axis)
{ {
current_position[axis] = base_home_pos[axis] + add_homing[axis]; current_position[axis] = base_home_pos[axis] + home_offset[axis];
min_pos[axis] = base_min_pos(axis) + add_homing[axis]; min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos[axis] + add_homing[axis]; max_pos[axis] = base_max_pos[axis] + home_offset[axis];
} }
static void homeaxis(int axis) static void homeaxis(int axis)
...@@ -1961,7 +1966,7 @@ void refresh_cmd_timeout(void) { previous_millis_cmd = millis(); } ...@@ -1961,7 +1966,7 @@ void refresh_cmd_timeout(void) { previous_millis_cmd = millis(); }
#ifdef IDLE_OOZING_PREVENT #ifdef IDLE_OOZING_PREVENT
void IDLE_OOZING_retract(bool retracting) void IDLE_OOZING_retract(bool retracting)
{ {
if(retracting && !IDLE_OOZING_retracted[active_extruder]) { if (retracting && !IDLE_OOZING_retracted[active_extruder]) {
//SERIAL_ECHOLN("RETRACT FOR OOZING PREVENT"); //SERIAL_ECHOLN("RETRACT FOR OOZING PREVENT");
destination[X_AXIS]=current_position[X_AXIS]; destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS]; destination[Y_AXIS]=current_position[Y_AXIS];
...@@ -1975,7 +1980,7 @@ void refresh_cmd_timeout(void) { previous_millis_cmd = millis(); } ...@@ -1975,7 +1980,7 @@ void refresh_cmd_timeout(void) { previous_millis_cmd = millis(); }
prepare_move(); prepare_move();
feedrate = oldFeedrate; feedrate = oldFeedrate;
} }
else if(!retracting && IDLE_OOZING_retracted[active_extruder]){ else if(!retracting && IDLE_OOZING_retracted[active_extruder]) {
//SERIAL_ECHOLN("EXTRUDE FOR OOZING PREVENT"); //SERIAL_ECHOLN("EXTRUDE FOR OOZING PREVENT");
destination[X_AXIS]=current_position[X_AXIS]; destination[X_AXIS]=current_position[X_AXIS];
destination[Y_AXIS]=current_position[Y_AXIS]; destination[Y_AXIS]=current_position[Y_AXIS];
...@@ -2215,10 +2220,13 @@ inline void wait_bed() { ...@@ -2215,10 +2220,13 @@ inline void wait_bed() {
// G0-G1: Coordinated movement of X Y Z E axes // G0-G1: Coordinated movement of X Y Z E axes
inline void gcode_G0_G1() { inline void gcode_G0_G1() {
if (!Stopped) { if (!Stopped) {
#ifdef IDLE_OOZING_PREVENT #ifdef IDLE_OOZING_PREVENT
IDLE_OOZING_retract(false); IDLE_OOZING_retract(false);
#endif #endif
get_coordinates(); // For X Y Z E F get_coordinates(); // For X Y Z E F
#ifdef FWRETRACT #ifdef FWRETRACT
if (autoretract_enabled) { if (autoretract_enabled) {
if (!(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) { if (!(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
...@@ -2337,6 +2345,11 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2337,6 +2345,11 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#endif //DELTA #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 defined(CARTESIAN) || defined(COREXY) || defined(SCARA)
#if Z_HOME_DIR > 0 // If homing away from BED do Z first #if Z_HOME_DIR > 0 // If homing away from BED do Z first
if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) { if((home_all_axis) || (code_seen(axis_codes[Z_AXIS]))) {
...@@ -2415,7 +2428,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2415,7 +2428,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#ifdef SCARA #ifdef SCARA
current_position[X_AXIS]=code_value(); current_position[X_AXIS]=code_value();
#else #else
current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; current_position[X_AXIS]=code_value() + home_offset[X_AXIS];
#endif #endif
} }
...@@ -2423,7 +2436,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2423,7 +2436,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#ifdef SCARA #ifdef SCARA
current_position[Y_AXIS]=code_value(); current_position[Y_AXIS]=code_value();
#else #else
current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; current_position[Y_AXIS]=code_value() + home_offset[Y_AXIS];
#endif #endif
} }
...@@ -2602,7 +2615,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2602,7 +2615,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#endif //Z_HOME_DIR < 0 #endif //Z_HOME_DIR < 0
if (code_seen(axis_codes[Z_AXIS]) && code_value_long() != 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 #ifdef ENABLE_AUTO_BED_LEVELING
if (home_all_axis || code_seen(axis_codes[Z_AXIS])) if (home_all_axis || code_seen(axis_codes[Z_AXIS]))
...@@ -2723,7 +2736,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2723,7 +2736,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#ifdef AUTO_BED_LEVELING_GRID #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"); if (verbose_level > 0) SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
...@@ -2787,8 +2800,8 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2787,8 +2800,8 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
current_position[Y_AXIS] = uncorrected_position.y; current_position[Y_AXIS] = uncorrected_position.y;
current_position[Z_AXIS] = uncorrected_position.z; 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]); 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]; feedrate = homing_feedrate[Z_AXIS];
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
...@@ -2835,7 +2848,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2835,7 +2848,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. // If topo_flag is set then don't zig-zag. Just scan in one direction.
// This gets the probe points in more readable order. // 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) for (int xCount=xStart; xCount != xStop; xCount += xInc)
{ {
double xProbe = left_probe_bed_position + xGridSpacing * xCount; double xProbe = left_probe_bed_position + xGridSpacing * xCount;
...@@ -2855,7 +2868,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2855,7 +2868,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
act = ProbeStay; act = ProbeStay;
} }
else else
act = ProbeEngageRetract; act = ProbeEngageAndRetract;
measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level); measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
...@@ -2892,37 +2905,18 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2892,37 +2905,18 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
} }
} }
if (topo_flag) { if (do_topography_map) {
int xx, yy;
SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n"); SERIAL_PROTOCOLPGM(" \nBed Height Topography: \n");
#if TOPO_ORIGIN == OriginFrontLeft
SERIAL_PROTOCOLPGM("+-----------+\n"); SERIAL_PROTOCOLPGM("+-----------+\n");
SERIAL_PROTOCOLPGM("|...Back....|\n"); SERIAL_PROTOCOLPGM("|...Back....|\n");
SERIAL_PROTOCOLPGM("|Left..Right|\n"); SERIAL_PROTOCOLPGM("|Left..Right|\n");
SERIAL_PROTOCOLPGM("|...Front...|\n"); SERIAL_PROTOCOLPGM("|...Front...|\n");
SERIAL_PROTOCOLPGM("+-----------+\n"); SERIAL_PROTOCOLPGM("+-----------+\n");
for (yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--)
#else for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
for (yy = 0; yy < auto_bed_leveling_grid_points; yy++) for (int xx = auto_bed_leveling_grid_points - 1; xx >= 0; xx--) {
#endif int ind = yy * auto_bed_leveling_grid_points + xx;
{
#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; float diff = eqnBVector[ind] - mean;
if (diff >= 0.0) if (diff >= 0.0)
SERIAL_PROTOCOLPGM(" +"); // Include + for column alignment SERIAL_PROTOCOLPGM(" +"); // Include + for column alignment
...@@ -2934,7 +2928,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2934,7 +2928,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
} // yy } // yy
SERIAL_EOL; SERIAL_EOL;
} //topo_flag } //do_topography_map
set_bed_level_equation_lsq(plane_equation_coefficients); set_bed_level_equation_lsq(plane_equation_coefficients);
...@@ -2961,9 +2955,6 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2961,9 +2955,6 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#endif // !AUTO_BED_LEVELING_GRID #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) if (verbose_level > 0)
plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:"); plan_bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
...@@ -3546,9 +3537,9 @@ inline void gcode_G92() { ...@@ -3546,9 +3537,9 @@ inline void gcode_G92() {
} }
else { else {
#ifdef SCARA #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 #else
current_position[i] = code_value() + add_homing[i]; current_position[i] = code_value() + home_offset[i];
#endif #endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
} }
...@@ -3969,15 +3960,10 @@ inline void gcode_M204() { ...@@ -3969,15 +3960,10 @@ inline void gcode_M204() {
boolean sleep = false; boolean sleep = false;
int cnt = 0; int cnt = 0;
#ifndef SINGLENOZZLE int old_target_temperature[HOTENDS] = { 0 };
int old_target_temperature[EXTRUDERS] = { 0 }; for(int8_t e = 0; e < HOTENDS; e++)
for(int8_t e=0;e<EXTRUDERS;e++)
#else
int old_target_temperature[1] = { 0 };
int8_t e=0;
#endif
{ {
old_target_temperature[e]=target_temperature[e]; old_target_temperature[e] = target_temperature[e];
} }
int old_target_temperature_bed = target_temperature_bed; int old_target_temperature_bed = target_temperature_bed;
timer.set_max_delay(60000); // 1 minute timer.set_max_delay(60000); // 1 minute
...@@ -4011,11 +3997,7 @@ inline void gcode_M204() { ...@@ -4011,11 +3997,7 @@ inline void gcode_M204() {
lcd_reset_alert_level(); lcd_reset_alert_level();
if (sleep) { if (sleep) {
#ifndef SINGLENOZZLE for(int8_t e = 0; e < HOTENDS; e++)
for(int8_t e=0;e<EXTRUDERS;e++)
#else
int8_t e=0;
#endif
{ {
setTargetHotend(old_target_temperature[e], e); setTargetHotend(old_target_temperature[e], e);
CooldownNoWait = true; CooldownNoWait = true;
...@@ -4637,7 +4619,7 @@ void process_commands() ...@@ -4637,7 +4619,7 @@ void process_commands()
{ {
if(setTargetedHotend(104)) break; if(setTargetedHotend(104)) break;
if(debugDryrun()) break; if(debugDryrun()) break;
#ifdef SINGLENOZZLE #if HOTENDS == 1
if (tmp_extruder != active_extruder) break; if (tmp_extruder != active_extruder) break;
#endif #endif
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder); if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
...@@ -4740,7 +4722,7 @@ void process_commands() ...@@ -4740,7 +4722,7 @@ void process_commands()
{ {
if(setTargetedHotend(109)) break; if(setTargetedHotend(109)) break;
if(debugDryrun()) break; if(debugDryrun()) break;
#ifdef SINGLENOZZLE #if HOTENDS == 1
if (tmp_extruder != active_extruder) break; if (tmp_extruder != active_extruder) break;
#endif #endif
LCD_MESSAGEPGM(MSG_HEATING); LCD_MESSAGEPGM(MSG_HEATING);
...@@ -4823,9 +4805,9 @@ void process_commands() ...@@ -4823,9 +4805,9 @@ void process_commands()
SERIAL_PROTOCOLLN(""); SERIAL_PROTOCOLLN("");
SERIAL_PROTOCOLPGM("SCARA Cal - Theta:"); 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_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_PROTOCOLLN("");
SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:"); SERIAL_PROTOCOLPGM("SCARA step Cal - Theta:");
...@@ -5095,16 +5077,16 @@ void process_commands() ...@@ -5095,16 +5077,16 @@ void process_commands()
{ {
for(int8_t i=0; i < 3; i++) 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 #ifdef SCARA
if(code_seen('T')) // Theta if(code_seen('T')) // Theta
{ {
add_homing[X_AXIS] = code_value() ; home_offset[X_AXIS] = code_value() ;
} }
if(code_seen('P')) // Psi if(code_seen('P')) // Psi
{ {
add_homing[Y_AXIS] = code_value() ; home_offset[Y_AXIS] = code_value() ;
} }
#endif #endif
} }
...@@ -5187,8 +5169,7 @@ void process_commands() ...@@ -5187,8 +5169,7 @@ void process_commands()
break; break;
#endif // FWRETRACT #endif // FWRETRACT
#ifndef SINGLENOZZLE #if HOTENDS > 1
#if EXTRUDERS > 1
case 218: //M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y> case 218: //M218 - set hotend offset (in mm), T<extruder_number> X<offset_on_X> Y<offset_on_Y>
{ {
if(setTargetedHotend(218)) break; if(setTargetedHotend(218)) break;
...@@ -5223,7 +5204,6 @@ void process_commands() ...@@ -5223,7 +5204,6 @@ void process_commands()
} }
break; break;
#endif //EXTRUDERS > 1 #endif //EXTRUDERS > 1
#endif // SINGLENOZZLE
case 220: //M220 S<factor in percent>- set speed factor override percentage case 220: //M220 S<factor in percent>- set speed factor override percentage
{ {
...@@ -5635,7 +5615,7 @@ void process_commands() ...@@ -5635,7 +5615,7 @@ void process_commands()
break; break;
#endif // NABLE_AUTO_BED_LEVELING #endif // NABLE_AUTO_BED_LEVELING
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0)
case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
{ {
if(code_seen('D')) filament_width_nominal=code_value(); if(code_seen('D')) filament_width_nominal=code_value();
...@@ -5945,16 +5925,11 @@ void process_commands() ...@@ -5945,16 +5925,11 @@ void process_commands()
delayed_move_time = 0; delayed_move_time = 0;
} }
#else #else
// Offset extruder (only by XY) // Offset hotend (only by XY)
#ifndef SINGLENOZZLE #if HOTENDS > 1
int i; for (int i=X_AXIS; i<=Y_AXIS; i++)
for(i = 0; i < 2; i++) current_position[i] += hotend_offset[i][tmp_extruder] - hotend_offset[i][active_extruder];
{ #endif // HOTENDS > 1
current_position[i] = current_position[i] -
hotend_offset[i][active_extruder] +
hotend_offset[i][tmp_extruder];
}
#endif // SINGLENOZZLE
#if defined(MKR4) && (EXTRUDERS > 1) #if defined(MKR4) && (EXTRUDERS > 1)
#if (EXTRUDERS == 4) && (E0E2_CHOICE_PIN >1) && (E1E3_CHOICE_PIN > 1) #if (EXTRUDERS == 4) && (E0E2_CHOICE_PIN >1) && (E1E3_CHOICE_PIN > 1)
...@@ -6169,7 +6144,7 @@ void clamp_to_software_endstops(float target[3]) ...@@ -6169,7 +6144,7 @@ void clamp_to_software_endstops(float target[3])
float negative_z_offset = 0; float negative_z_offset = 0;
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset = negative_z_offset + Z_PROBE_OFFSET_FROM_EXTRUDER; 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 #endif
if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset; if (target[Z_AXIS] < min_pos[Z_AXIS]+negative_z_offset) target[Z_AXIS] = min_pos[Z_AXIS]+negative_z_offset;
...@@ -6184,9 +6159,10 @@ void clamp_to_software_endstops(float target[3]) ...@@ -6184,9 +6159,10 @@ void clamp_to_software_endstops(float target[3])
void prepare_move() void prepare_move()
{ {
#ifdef IDLE_OOZING_PREVENT || EXTRUDER_RUNOUT_PREVENT #ifdef IDLE_OOZING_PREVENT || EXTRUDER_RUNOUT_PREVENT
axis_is_moving = true; axis_is_moving = true;
#endif #endif
clamp_to_software_endstops(destination); clamp_to_software_endstops(destination);
refresh_cmd_timeout(); refresh_cmd_timeout();
...@@ -6206,7 +6182,6 @@ void prepare_move() ...@@ -6206,7 +6182,6 @@ void prepare_move()
return; return;
} }
float seconds = 6000 * cartesian_mm / feedrate / feedmultiply; float seconds = 6000 * cartesian_mm / feedrate / feedmultiply;
int steps = max(1, int(scara_segments_per_second * seconds)); int steps = max(1, int(scara_segments_per_second * seconds));
//SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm); //SERIAL_ECHOPGM("mm="); SERIAL_ECHO(cartesian_mm);
//SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds); //SERIAL_ECHOPGM(" seconds="); SERIAL_ECHO(seconds);
...@@ -6321,6 +6296,7 @@ void prepare_move() ...@@ -6321,6 +6296,7 @@ void prepare_move()
axis_is_moving = false; axis_is_moving = false;
#endif #endif
for(int8_t i=0; i < NUM_AXIS; i++) { for(int8_t i=0; i < NUM_AXIS; i++) {
current_position[i] = destination[i]; current_position[i] = destination[i];
} }
...@@ -6585,11 +6561,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s ...@@ -6585,11 +6561,13 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1 #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
controllerFan(); //Check if fan should be turned on to cool stepper drivers down controllerFan(); //Check if fan should be turned on to cool stepper drivers down
#endif #endif
#ifdef IDLE_OOZING_PREVENT #ifdef IDLE_OOZING_PREVENT
if(!debugDryrun() && !axis_is_moving && !filament_changing && (millis() - axis_last_activity) > IDLE_OOZING_SECONDS*1000 && degHotend(active_extruder) > IDLE_OOZING_MINTEMP) { if(!debugDryrun() && !axis_is_moving && !filament_changing && (millis() - axis_last_activity) > IDLE_OOZING_SECONDS*1000 && degHotend(active_extruder) > IDLE_OOZING_MINTEMP) {
IDLE_OOZING_retract(true); IDLE_OOZING_retract(true);
} }
#endif #endif
#ifdef EXTRUDER_RUNOUT_PREVENT #ifdef EXTRUDER_RUNOUT_PREVENT
if(!debugDryrun() && !axis_is_moving && !filament_changing && (millis() - axis_last_activity) > EXTRUDER_RUNOUT_SECONDS*1000 && degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP) if(!debugDryrun() && !axis_is_moving && !filament_changing && (millis() - axis_last_activity) > EXTRUDER_RUNOUT_SECONDS*1000 && degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
{ {
...@@ -6607,6 +6585,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s ...@@ -6607,6 +6585,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
WRITE(E0_ENABLE_PIN,oldstatus); WRITE(E0_ENABLE_PIN,oldstatus);
} }
#endif #endif
#if defined(DUAL_X_CARRIAGE) #if defined(DUAL_X_CARRIAGE)
// handle delayed move timeout // handle delayed move timeout
if (delayed_move_time != 0 && (millis() - delayed_move_time) > 1000 && Stopped == false) if (delayed_move_time != 0 && (millis() - delayed_move_time) > 1000 && Stopped == false)
...@@ -6617,9 +6596,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s ...@@ -6617,9 +6596,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
prepare_move(); prepare_move();
} }
#endif #endif
#ifdef TEMP_STAT_LEDS #ifdef TEMP_STAT_LEDS
handle_status_leds(); handle_status_leds();
#endif #endif
check_axes_activity(); check_axes_activity();
} }
......
...@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() { ...@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() {
startFileprint(); startFileprint();
} }
else { else {
quickStop();
file.close(); file.close();
sdprinting = false; sdprinting = false;
if (SD_FINISHED_STEPPERRELEASE) { if (SD_FINISHED_STEPPERRELEASE) {
......
...@@ -267,10 +267,7 @@ static void lcd_implementation_status_screen() { ...@@ -267,10 +267,7 @@ static void lcd_implementation_status_screen() {
// Status line // Status line
u8g.setFont(FONT_STATUSMENU); u8g.setFont(FONT_STATUSMENU);
u8g.setPrintPos(0,63); u8g.setPrintPos(0,63);
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && (POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
u8g.print(lcd_status_message); u8g.print(lcd_status_message);
} }
......
...@@ -78,12 +78,12 @@ float mintravelfeedrate; ...@@ -78,12 +78,12 @@ float mintravelfeedrate;
unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS]; unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
// this holds the required transform to compensate for bed level // this holds the required transform to compensate for bed level
matrix_3x3 plan_bed_level_matrix = { matrix_3x3 plan_bed_level_matrix = {
1.0, 0.0, 0.0, 1.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 1.0 0.0, 0.0, 1.0
}; };
#endif // #ifdef ENABLE_AUTO_BED_LEVELING #endif // #ifdef ENABLE_AUTO_BED_LEVELING
// The current position of the tool in absolute steps // The current position of the tool in absolute steps
...@@ -92,18 +92,18 @@ static float previous_speed[NUM_AXIS]; // Speed of previous path line segment ...@@ -92,18 +92,18 @@ static float previous_speed[NUM_AXIS]; // Speed of previous path line segment
static float previous_nominal_speed; // Nominal speed of previous path line segment static float previous_nominal_speed; // Nominal speed of previous path line segment
#ifdef AUTOTEMP #ifdef AUTOTEMP
float autotemp_max=250; float autotemp_max = 250;
float autotemp_min=210; float autotemp_min = 210;
float autotemp_factor=0.1; float autotemp_factor = 0.1;
bool autotemp_enabled=false; bool autotemp_enabled = false;
#endif #endif
unsigned char g_uc_extruder_last_move[4] = {0,0,0,0}; unsigned char g_uc_extruder_last_move[4] = {0,0,0,0};
//=========================================================================== //===========================================================================
//=================semi-private variables, used in inline functions ===== //=================semi-private variables, used in inline functions =========
//=========================================================================== //===========================================================================
block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions
volatile unsigned char block_buffer_head; // Index of the next block to be pushed volatile unsigned char block_buffer_head; // Index of the next block to be pushed
volatile unsigned char block_buffer_tail; // Index of the block to process now volatile unsigned char block_buffer_tail; // Index of the block to process now
...@@ -111,55 +111,36 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro ...@@ -111,55 +111,36 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro
//=============================private variables ============================ //=============================private variables ============================
//=========================================================================== //===========================================================================
#ifdef PREVENT_DANGEROUS_EXTRUDE #ifdef PREVENT_DANGEROUS_EXTRUDE
float extrude_min_temp=EXTRUDE_MINTEMP; float extrude_min_temp = EXTRUDE_MINTEMP;
#endif #endif
#ifdef XY_FREQUENCY_LIMIT #ifdef XY_FREQUENCY_LIMIT
#define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT) // Used for the frequency limit
// Used for the frequency limit #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations // Old direction bits. Used for speed calculations
static long x_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // Segment times (in us). Used for speed calculations static unsigned char old_direction_bits = 0;
static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0}; // Segment times (in us). Used for speed calculations
static long x_segment_time[3]={MAX_FREQ_TIME + 1,0,0};
static long y_segment_time[3]={MAX_FREQ_TIME + 1,0,0};
#endif #endif
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #ifdef FILAMENT_SENSOR
static char meas_sample; //temporary variable to hold filament measurement sample static char meas_sample; //temporary variable to hold filament measurement sample
#endif #endif
// Returns the index of the next block in the ring buffer // Get the next / previous index of the next block in the ring buffer
// NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication. // NOTE: Using & here (not %) because BLOCK_BUFFER_SIZE is always a power of 2
static int8_t next_block_index(int8_t block_index) { FORCE_INLINE int8_t next_block_index(int8_t block_index) { return BLOCK_MOD(block_index + 1); }
block_index++; FORCE_INLINE int8_t prev_block_index(int8_t block_index) { return BLOCK_MOD(block_index - 1); }
if (block_index == BLOCK_BUFFER_SIZE) {
block_index = 0;
}
return(block_index);
}
// Returns the index of the previous block in the ring buffer
static int8_t prev_block_index(int8_t block_index) {
if (block_index == 0) {
block_index = BLOCK_BUFFER_SIZE;
}
block_index--;
return(block_index);
}
//=========================================================================== //===========================================================================
//=============================functions ============================ //================================ Functions ================================
//=========================================================================== //===========================================================================
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
// given acceleration: // given acceleration:
FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
{ if (acceleration == 0) return 0; // acceleration was 0, set acceleration distance to 0
if (acceleration!=0) { return (target_rate * target_rate - initial_rate * initial_rate) / (acceleration * 2);
return((target_rate*target_rate-initial_rate*initial_rate)/
(2.0*acceleration));
}
else {
return 0.0; // acceleration was 0, set acceleration distance to 0
}
} }
// This function gives you the point at which you must start braking (at the rate of -acceleration) if // This function gives you the point at which you must start braking (at the rate of -acceleration) if
...@@ -167,67 +148,55 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ ...@@ -167,67 +148,55 @@ FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float targ
// a total travel of distance. This can be used to compute the intersection point between acceleration and // a total travel of distance. This can be used to compute the intersection point between acceleration and
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) {
{ if (acceleration == 0) return 0; // acceleration was 0, set intersection distance to 0
if (acceleration!=0) { return (acceleration * 2 * distance - initial_rate * initial_rate + final_rate * final_rate) / (acceleration * 4);
return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
(4.0*acceleration) );
}
else {
return 0.0; // acceleration was 0, set intersection distance to 0
}
} }
// Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors. // Calculates trapezoid parameters so that the entry- and exit-speed is compensated by the provided factors.
void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exit_factor) { void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exit_factor) {
unsigned long initial_rate = ceil(block->nominal_rate*entry_factor); // (step/min) unsigned long initial_rate = ceil(block->nominal_rate * entry_factor); // (step/min)
unsigned long final_rate = ceil(block->nominal_rate*exit_factor); // (step/min) unsigned long final_rate = ceil(block->nominal_rate * exit_factor); // (step/min)
// Limit minimal step rate (Otherwise the timer will overflow.) // Limit minimal step rate (Otherwise the timer will overflow.)
if(initial_rate <120) { if (initial_rate < 120) initial_rate = 120;
initial_rate=120; if (final_rate < 120) final_rate = 120;
}
if(final_rate < 120) {
final_rate=120;
}
long acceleration = block->acceleration_st; long acceleration = block->acceleration_st;
int32_t accelerate_steps = int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, acceleration));
ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, acceleration)); int32_t decelerate_steps = floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -acceleration));
int32_t decelerate_steps =
floor(estimate_acceleration_distance(block->nominal_rate, final_rate, -acceleration));
// Calculate the size of Plateau of Nominal Rate. // Calculate the size of Plateau of Nominal Rate.
int32_t plateau_steps = block->step_event_count-accelerate_steps-decelerate_steps; int32_t plateau_steps = block->step_event_count - accelerate_steps - decelerate_steps;
// Is the Plateau of Nominal Rate smaller than nothing? That means no cruising, and we will // Is the Plateau of Nominal Rate smaller than nothing? That means no cruising, and we will
// have to use intersection_distance() to calculate when to abort acceleration and start braking // have to use intersection_distance() to calculate when to abort acceleration and start braking
// in order to reach the final_rate exactly at the end of this block. // in order to reach the final_rate exactly at the end of this block.
if (plateau_steps < 0) { if (plateau_steps < 0) {
accelerate_steps = ceil(intersection_distance(initial_rate, final_rate, acceleration, block->step_event_count)); accelerate_steps = ceil(intersection_distance(initial_rate, final_rate, acceleration, block->step_event_count));
accelerate_steps = max(accelerate_steps,0); // Check limits due to numerical round-off accelerate_steps = max(accelerate_steps, 0); // Check limits due to numerical round-off
accelerate_steps = min((uint32_t)accelerate_steps,block->step_event_count);//(We can cast here to unsigned, because the above line ensures that we are above zero) accelerate_steps = min((uint32_t)accelerate_steps, block->step_event_count);//(We can cast here to unsigned, because the above line ensures that we are above zero)
plateau_steps = 0; plateau_steps = 0;
} }
#ifdef ADVANCE #ifdef ADVANCE
volatile long initial_advance = block->advance*entry_factor*entry_factor; volatile long initial_advance = block->advance * entry_factor * entry_factor;
volatile long final_advance = block->advance*exit_factor*exit_factor; volatile long final_advance = block->advance * exit_factor * exit_factor;
#endif // ADVANCE #endif // ADVANCE
// block->accelerate_until = accelerate_steps; // block->accelerate_until = accelerate_steps;
// block->decelerate_after = accelerate_steps+plateau_steps; // block->decelerate_after = accelerate_steps+plateau_steps;
CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section
if(block->busy == false) { // Don't update variables if block is busy. if (!block->busy) { // Don't update variables if block is busy.
block->accelerate_until = accelerate_steps; block->accelerate_until = accelerate_steps;
block->decelerate_after = accelerate_steps+plateau_steps; block->decelerate_after = accelerate_steps+plateau_steps;
block->initial_rate = initial_rate; block->initial_rate = initial_rate;
block->final_rate = final_rate; block->final_rate = final_rate;
#ifdef ADVANCE #ifdef ADVANCE
block->initial_advance = initial_advance; block->initial_advance = initial_advance;
block->final_advance = final_advance; block->final_advance = final_advance;
#endif //ADVANCE #endif //ADVANCE
} }
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
} }
...@@ -235,23 +204,12 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi ...@@ -235,23 +204,12 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the
// acceleration within the allotted distance. // acceleration within the allotted distance.
FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) { FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
return sqrt(target_velocity*target_velocity-2*acceleration*distance); return sqrt(target_velocity * target_velocity - 2 * acceleration * distance);
} }
// "Junction jerk" in this context is the immediate change in speed at the junction of two blocks.
// This method will calculate the junction jerk as the euclidean distance between the nominal
// velocities of the respective blocks.
//inline float junction_jerk(block_t *before, block_t *after) {
// return sqrt(
// pow((before->speed_x-after->speed_x), 2)+pow((before->speed_y-after->speed_y), 2));
//}
// The kernel called by planner_recalculate() when scanning the plan from last to first entry. // The kernel called by planner_recalculate() when scanning the plan from last to first entry.
void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) { void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *next) {
if(!current) { if (!current) return;
return;
}
if (next) { if (next) {
// If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising. // If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising.
...@@ -261,9 +219,9 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n ...@@ -261,9 +219,9 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
// If nominal length true, max junction speed is guaranteed to be reached. Only compute // If nominal length true, max junction speed is guaranteed to be reached. Only compute
// for max allowable speed if block is decelerating and nominal length is false. // for max allowable speed if block is decelerating and nominal length is false.
if ((!current->nominal_length_flag) && (current->max_entry_speed > next->entry_speed)) { if (!current->nominal_length_flag && current->max_entry_speed > next->entry_speed) {
current->entry_speed = min( current->max_entry_speed, current->entry_speed = min(current->max_entry_speed,
max_allowable_speed(-current->acceleration,next->entry_speed,current->millimeters)); max_allowable_speed(-current->acceleration, next->entry_speed, current->millimeters));
} }
else { else {
current->entry_speed = current->max_entry_speed; current->entry_speed = current->max_entry_speed;
...@@ -284,11 +242,10 @@ void planner_reverse_pass() { ...@@ -284,11 +242,10 @@ void planner_reverse_pass() {
unsigned char tail = block_buffer_tail; unsigned char tail = block_buffer_tail;
CRITICAL_SECTION_END CRITICAL_SECTION_END
if(((block_buffer_head-tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) { if (BLOCK_MOD(block_buffer_head - tail + BLOCK_BUFFER_SIZE) > 3) { // moves queued
block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1); block_index = BLOCK_MOD(block_buffer_head - 3);
block_t *block[3] = { block_t *block[3] = { NULL, NULL, NULL };
NULL, NULL, NULL }; while (block_index != tail) {
while(block_index != tail) {
block_index = prev_block_index(block_index); block_index = prev_block_index(block_index);
block[2]= block[1]; block[2]= block[1];
block[1]= block[0]; block[1]= block[0];
...@@ -300,9 +257,7 @@ void planner_reverse_pass() { ...@@ -300,9 +257,7 @@ void planner_reverse_pass() {
// The kernel called by planner_recalculate() when scanning the plan from first to last entry. // The kernel called by planner_recalculate() when scanning the plan from first to last entry.
void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) { void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *next) {
if(!previous) { if (!previous) return;
return;
}
// If the previous block is an acceleration block, but it is not long enough to complete the // If the previous block is an acceleration block, but it is not long enough to complete the
// full speed change within the block, we need to adjust the entry speed accordingly. Entry // full speed change within the block, we need to adjust the entry speed accordingly. Entry
...@@ -310,8 +265,8 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n ...@@ -310,8 +265,8 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
// If nominal length is true, max junction speed is guaranteed to be reached. No need to recheck. // If nominal length is true, max junction speed is guaranteed to be reached. No need to recheck.
if (!previous->nominal_length_flag) { if (!previous->nominal_length_flag) {
if (previous->entry_speed < current->entry_speed) { if (previous->entry_speed < current->entry_speed) {
double entry_speed = min( current->entry_speed, double entry_speed = min(current->entry_speed,
max_allowable_speed(-previous->acceleration,previous->entry_speed,previous->millimeters) ); max_allowable_speed(-previous->acceleration, previous->entry_speed, previous->millimeters));
// Check for junction speed change // Check for junction speed change
if (current->entry_speed != entry_speed) { if (current->entry_speed != entry_speed) {
...@@ -326,14 +281,13 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n ...@@ -326,14 +281,13 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
// implements the forward pass. // implements the forward pass.
void planner_forward_pass() { void planner_forward_pass() {
uint8_t block_index = block_buffer_tail; uint8_t block_index = block_buffer_tail;
block_t *block[3] = { block_t *block[3] = { NULL, NULL, NULL };
NULL, NULL, NULL };
while(block_index != block_buffer_head) { while (block_index != block_buffer_head) {
block[0] = block[1]; block[0] = block[1];
block[1] = block[2]; block[1] = block[2];
block[2] = &block_buffer[block_index]; block[2] = &block_buffer[block_index];
planner_forward_pass_kernel(block[0],block[1],block[2]); planner_forward_pass_kernel(block[0], block[1], block[2]);
block_index = next_block_index(block_index); block_index = next_block_index(block_index);
} }
planner_forward_pass_kernel(block[1], block[2], NULL); planner_forward_pass_kernel(block[1], block[2], NULL);
...@@ -347,24 +301,24 @@ void planner_recalculate_trapezoids() { ...@@ -347,24 +301,24 @@ void planner_recalculate_trapezoids() {
block_t *current; block_t *current;
block_t *next = NULL; block_t *next = NULL;
while(block_index != block_buffer_head) { while (block_index != block_buffer_head) {
current = next; current = next;
next = &block_buffer[block_index]; next = &block_buffer[block_index];
if (current) { if (current) {
// Recalculate if current block entry or exit junction speed has changed. // Recalculate if current block entry or exit junction speed has changed.
if (current->recalculate_flag || next->recalculate_flag) { if (current->recalculate_flag || next->recalculate_flag) {
// NOTE: Entry and exit factors always > 0 by all previous logic operations. // NOTE: Entry and exit factors always > 0 by all previous logic operations.
calculate_trapezoid_for_block(current, current->entry_speed/current->nominal_speed, float nom = current->nominal_speed;
next->entry_speed/current->nominal_speed); calculate_trapezoid_for_block(current, current->entry_speed / nom, next->entry_speed / nom);
current->recalculate_flag = false; // Reset current only to ensure next trapezoid is computed current->recalculate_flag = false; // Reset current only to ensure next trapezoid is computed
} }
} }
block_index = next_block_index( block_index ); block_index = next_block_index( block_index );
} }
// Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated. // Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
if(next != NULL) { if (next) {
calculate_trapezoid_for_block(next, next->entry_speed/next->nominal_speed, float nom = next->nominal_speed;
MINIMUM_PLANNER_SPEED/next->nominal_speed); calculate_trapezoid_for_block(next, next->entry_speed / nom, MINIMUM_PLANNER_SPEED / nom);
next->recalculate_flag = false; next->recalculate_flag = false;
} }
} }
...@@ -393,111 +347,81 @@ void planner_recalculate() { ...@@ -393,111 +347,81 @@ void planner_recalculate() {
} }
void plan_init() { void plan_init() {
block_buffer_head = 0; block_buffer_head = block_buffer_tail = 0;
block_buffer_tail = 0;
memset(position, 0, sizeof(position)); // clear position memset(position, 0, sizeof(position)); // clear position
previous_speed[0] = 0.0; for (int i=0; i<NUM_AXIS; i++) previous_speed[i] = 0.0;
previous_speed[1] = 0.0;
previous_speed[2] = 0.0;
previous_speed[3] = 0.0;
previous_nominal_speed = 0.0; previous_nominal_speed = 0.0;
} }
#ifdef AUTOTEMP #ifdef AUTOTEMP
void getHighESpeed() void getHighESpeed() {
{ static float oldt = 0;
static float oldt=0;
if(!autotemp_enabled){
return;
}
if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
return; //do nothing
}
float high=0.0; if (!autotemp_enabled) return;
if (degTargetHotend0() + 2 < autotemp_min) return; // probably temperature set to zero.
float high = 0.0;
uint8_t block_index = block_buffer_tail; uint8_t block_index = block_buffer_tail;
while(block_index != block_buffer_head) { while (block_index != block_buffer_head) {
if((block_buffer[block_index].steps_x != 0) || block_t *block = &block_buffer[block_index];
(block_buffer[block_index].steps_y != 0) || if (block->steps[X_AXIS] || block->steps[Y_AXIS] || block->steps[Z_AXIS]) {
(block_buffer[block_index].steps_z != 0)) { float se = (float)block->steps[E_AXIS] / block->step_event_count * block->nominal_speed; // mm/sec;
float se=(float(block_buffer[block_index].steps_e)/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed; if (se > high) high = se;
//se; mm/sec;
if(se>high)
{
high=se;
} }
} block_index = next_block_index(block_index);
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
} }
float g=autotemp_min+high*autotemp_factor; float t = autotemp_min + high * autotemp_factor;
float t=g; if (t < autotemp_min) t = autotemp_min;
if(t<autotemp_min) if (t > autotemp_max) t = autotemp_max;
t=autotemp_min; if (oldt > t) t = AUTOTEMP_OLDWEIGHT * oldt + (1 - AUTOTEMP_OLDWEIGHT) * t;
if(t>autotemp_max) oldt = t;
t=autotemp_max;
if(oldt>t)
{
t=AUTOTEMP_OLDWEIGHT*oldt+(1-AUTOTEMP_OLDWEIGHT)*t;
}
oldt=t;
setTargetHotend0(t); setTargetHotend0(t);
} }
#endif #endif
void check_axes_activity() void check_axes_activity() {
{ unsigned char axis_active[NUM_AXIS],
unsigned char x_active = 0; tail_fan_speed = fanSpeed;
unsigned char y_active = 0;
unsigned char z_active = 0;
unsigned char e_active = 0;
unsigned char tail_fan_speed = fanSpeed;
#ifdef BARICUDA #ifdef BARICUDA
unsigned char tail_valve_pressure = ValvePressure; unsigned char tail_valve_pressure = ValvePressure,
unsigned char tail_e_to_p_pressure = EtoPPressure; tail_e_to_p_pressure = EtoPPressure;
#endif #endif
#ifdef LASERBEAM #ifdef LASERBEAM
unsigned char tail_laser_ttl_modulation = laser_ttl_modulation; unsigned char tail_laser_ttl_modulation = laser_ttl_modulation;
#endif #endif
block_t *block; block_t *block;
if(block_buffer_tail != block_buffer_head) if (blocks_queued()) {
{
uint8_t block_index = block_buffer_tail; uint8_t block_index = block_buffer_tail;
tail_fan_speed = block_buffer[block_index].fan_speed; tail_fan_speed = block_buffer[block_index].fan_speed;
#ifdef BARICUDA #ifdef BARICUDA
tail_valve_pressure = block_buffer[block_index].valve_pressure; block = &block_buffer[block_index];
tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure; tail_valve_pressure = block->valve_pressure;
tail_e_to_p_pressure = block->e_to_p_pressure;
#endif #endif
#ifdef LASERBEAM #ifdef LASERBEAM
tail_laser_ttl_modulation = block_buffer[block_index].laser_ttlmodulation; tail_laser_ttl_modulation = block_buffer[block_index].laser_ttlmodulation;
#endif #endif
while(block_index != block_buffer_head) while (block_index != block_buffer_head) {
{
block = &block_buffer[block_index]; block = &block_buffer[block_index];
if(block->steps_x != 0) x_active++; for (int i=0; i<NUM_AXIS; i++) if (block->steps[i]) axis_active[i]++;
if(block->steps_y != 0) y_active++; block_index = next_block_index(block_index);
if(block->steps_z != 0) z_active++;
if(block->steps_e != 0) e_active++;
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
} }
} }
if((DISABLE_X) && (x_active == 0)) disable_x(); if (DISABLE_X && !axis_active[X_AXIS]) disable_x();
if((DISABLE_Y) && (y_active == 0)) disable_y(); if (DISABLE_Y && !axis_active[Y_AXIS]) disable_y();
if((DISABLE_Z) && (z_active == 0)) disable_z(); if (DISABLE_Z && !axis_active[Z_AXIS]) disable_z();
if((DISABLE_E) && (e_active == 0)) if (DISABLE_E && !axis_active[E_AXIS]) {
{
disable_e0(); disable_e0();
disable_e1(); disable_e1();
disable_e2(); disable_e2();
disable_e3(); disable_e3();
} }
#if defined(FAN_PIN) && FAN_PIN > -1
#if defined(FAN_PIN) && FAN_PIN > -1 // HAS_FAN
#ifdef FAN_KICKSTART_TIME #ifdef FAN_KICKSTART_TIME
static unsigned long fan_kick_end; static unsigned long fan_kick_end;
if (tail_fan_speed) { if (tail_fan_speed) {
...@@ -515,39 +439,38 @@ void check_axes_activity() ...@@ -515,39 +439,38 @@ void check_axes_activity()
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
fanSpeedSoftPwm = tail_fan_speed; fanSpeedSoftPwm = tail_fan_speed;
#else #else
analogWrite(FAN_PIN,tail_fan_speed); analogWrite(FAN_PIN, tail_fan_speed);
#endif//!FAN_SOFT_PWM #endif //!FAN_SOFT_PWM
#endif//FAN_PIN > -1 #endif //FAN_PIN > -1
#ifdef AUTOTEMP
#ifdef AUTOTEMP
getHighESpeed(); getHighESpeed();
#endif #endif
#ifdef BARICUDA #ifdef BARICUDA
#if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 // HAS_HEATER_1
analogWrite(HEATER_1_PIN,tail_valve_pressure); analogWrite(HEATER_1_PIN,tail_valve_pressure);
#endif #endif
#if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 // HAS_HEATER_2
#if defined(HEATER_2_PIN) && HEATER_2_PIN > -1
analogWrite(HEATER_2_PIN,tail_e_to_p_pressure); analogWrite(HEATER_2_PIN,tail_e_to_p_pressure);
#endif #endif
#endif #endif
// add Laser TTL Modulation(PWM) Control // add Laser TTL Modulation(PWM) Control
#ifdef LASERBEAM #ifdef LASERBEAM
analogWrite(LASER_TTL_PIN, tail_laser_ttl_modulation); analogWrite(LASER_TTL_PIN, tail_laser_ttl_modulation);
#endif #endif
} }
float junction_deviation = 0.1; float junction_deviation = 0.1;
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in // Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration // mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters. // calculation the caller must also provide the physical length of the line in millimeters.
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver) void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
#else #else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver) void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
#endif //ENABLE_AUTO_BED_LEVELING #endif //ENABLE_AUTO_BED_LEVELING
{ {
// Calculate the buffer head after we push this byte // Calculate the buffer head after we push this byte
...@@ -555,68 +478,64 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa ...@@ -555,68 +478,64 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// If the buffer is full: good! That means we are well ahead of the robot. // If the buffer is full: good! That means we are well ahead of the robot.
// Rest here until there is room in the buffer. // Rest here until there is room in the buffer.
while(block_buffer_tail == next_buffer_head) while(block_buffer_tail == next_buffer_head) {
{
manage_heater(); manage_heater();
manage_inactivity(); manage_inactivity();
lcd_update(); lcd_update();
} }
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
apply_rotation_xyz(plan_bed_level_matrix, x, y, z); apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif // ENABLE_AUTO_BED_LEVELING #endif // ENABLE_AUTO_BED_LEVELING
// The target position of the tool in absolute steps // The target position of the tool in absolute steps
// Calculate target position in absolute steps // Calculate target position in absolute steps
//this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow //this should be done after the wait, because otherwise a M92 code within the gcode disrupts this calculation somehow
long target[4]; long target[NUM_AXIS];
target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]);
target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); target[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]);
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); target[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]);
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS + active_extruder]); target[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + active_extruder]);
#ifdef PREVENT_DANGEROUS_EXTRUDE float dx = target[X_AXIS] - position[X_AXIS],
#ifdef NPR2 dy = target[Y_AXIS] - position[Y_AXIS],
if(target[E_AXIS]!=position[E_AXIS]) dz = target[Z_AXIS] - position[Z_AXIS],
{ de = target[E_AXIS] - position[E_AXIS];
if (active_extruder!=1)
{ #ifdef PREVENT_DANGEROUS_EXTRUDE
if(degHotend(active_extruder)<extrude_min_temp && !debugDryrun()) if (de) {
{ #ifdef NPR2
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part if (active_extruder!=1) {
if(degHotend(active_extruder) < extrude_min_temp && !debugDryrun()) {
position[E_AXIS] = target[E_AXIS]; //behave as if the move really took place, but ignore E part
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
} }
} }
#else // NO NPR2 #else // NO NPR2
if(target[E_AXIS]!=position[E_AXIS]) if(degHotend(active_extruder) < extrude_min_temp && !debugDryrun()) {
{ position[E_AXIS] = target[E_AXIS]; //behave as if the move really took place, but ignore E part
if(degHotend(active_extruder)<extrude_min_temp && !debugDryrun())
{
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP); SERIAL_ECHOLNPGM(MSG_ERR_COLD_EXTRUDE_STOP);
} }
#endif // NPR2 #endif // NPR2
#ifdef PREVENT_LENGTHY_EXTRUDE #ifdef PREVENT_LENGTHY_EXTRUDE
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[active_extruder+3]*EXTRUDE_MAXLENGTH) if(labs(de) > axis_steps_per_unit[E_AXIS + active_extruder] * EXTRUDE_MAXLENGTH) {
{ #ifdef EASY_LOAD
#ifdef EASY_LOAD
if (!allow_lengthy_extrude_once) { if (!allow_lengthy_extrude_once) {
#endif #endif
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part position[E_AXIS] = target[E_AXIS]; //behave as if the move really took place, but ignore E part
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP); SERIAL_ECHOLNPGM(MSG_ERR_LONG_EXTRUDE_STOP);
#ifdef EASY_LOAD #ifdef EASY_LOAD
} }
allow_lengthy_extrude_once = false; allow_lengthy_extrude_once = false;
#endif #endif
} }
#endif // PREVENT_LENGTHY_EXTRUDE #endif // PREVENT_LENGTHY_EXTRUDE
} }
#endif // PREVENT_DANGEROUS_EXTRUDE
#endif // PREVENT_DANGEROUS_EXTRUDE
// Prepare to set up new block // Prepare to set up new block
block_t *block = &block_buffer[block_buffer_head]; block_t *block = &block_buffer[block_buffer_head];
...@@ -625,28 +544,26 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa ...@@ -625,28 +544,26 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
block->busy = false; block->busy = false;
// Number of steps for each axis // Number of steps for each axis
#ifndef COREXY #ifdef COREXY
// default non-h-bot planning // corexy planning
block->steps_x = labs(target[X_AXIS]-position[X_AXIS]); // these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
block->steps_y = labs(target[Y_AXIS]-position[Y_AXIS]); block->steps[A_AXIS] = labs(dx + dy);
#else block->steps[B_AXIS] = labs(dx - dy);
// corexy planning #else
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html // default non-h-bot planning
block->steps_x = labs((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS])); block->steps[X_AXIS] = labs(dx);
block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS])); block->steps[Y_AXIS] = labs(dy);
#endif #endif
block->steps_z = labs(target[Z_AXIS]-position[Z_AXIS]);
block->steps_e = labs(target[E_AXIS]-position[E_AXIS]); block->steps[Z_AXIS] = labs(dz);
block->steps_e *= volumetric_multiplier[active_extruder]; block->steps[E_AXIS] = labs(de);
block->steps_e *= extruder_multiplier[active_extruder]; block->steps[E_AXIS] *= volumetric_multiplier[active_extruder];
block->steps_e /= 100; block->steps[E_AXIS] *= extruder_multiplier[active_extruder];
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e))); block->steps[E_AXIS] /= 100;
block->step_event_count = max(block->steps[X_AXIS], max(block->steps[Y_AXIS], max(block->steps[Z_AXIS], block->steps[E_AXIS])));
// Bail if this is a zero-length block // Bail if this is a zero-length block
if (block->step_event_count <= dropsegments) if (block->step_event_count <= dropsegments) return;
{
return;
}
block->fan_speed = fanSpeed; block->fan_speed = fanSpeed;
#ifdef BARICUDA #ifdef BARICUDA
...@@ -660,105 +577,92 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi ...@@ -660,105 +577,92 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
#endif #endif
// Compute direction bits for this block // Compute direction bits for this block
block->direction_bits = 0; uint8_t db = 0;
#ifndef COREXY #ifdef COREXY
if (target[X_AXIS] < position[X_AXIS]) if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
{ if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
block->direction_bits |= BIT(X_AXIS); if (dx + dy < 0) db |= BIT(A_AXIS); // Motor A direction
} if (dx - dy < 0) db |= BIT(B_AXIS); // Motor B direction
if (target[Y_AXIS] < position[Y_AXIS]) #else
{ if (dx < 0) db |= BIT(X_AXIS);
block->direction_bits |= BIT(Y_AXIS); if (dy < 0) db |= BIT(Y_AXIS);
} #endif
#else //COREXY if (dz < 0) db |= BIT(Z_AXIS);
if (target[X_AXIS] < position[X_AXIS]) if (de < 0) db |= BIT(E_AXIS);
{ block->direction_bits = db;
block->direction_bits |= BIT(X_HEAD);
}
if (target[Y_AXIS] < position[Y_AXIS])
{
block->direction_bits |= BIT(Y_HEAD);
}
if ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]) < 0)
{
block->direction_bits |= BIT(X_AXIS);
}
if ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]) < 0)
{
block->direction_bits |= BIT(Y_AXIS);
}
#endif //COREXY
if (target[Z_AXIS] < position[Z_AXIS])
{
block->direction_bits |= BIT(Z_AXIS);
}
if (target[E_AXIS] < position[E_AXIS])
{
block->direction_bits |= BIT(E_AXIS);
}
block->active_driver = driver; block->active_driver = driver;
//enable active axes //enable active axes
#ifdef COREXY #ifdef COREXY
if((block->steps_x != 0) || (block->steps_y != 0)) { if (block->steps[A_AXIS] || block->steps[B_AXIS]) {
enable_x(); enable_x();
enable_y(); enable_y();
} }
#else //NO COREXY #else
if(block->steps_x != 0) enable_x(); if (block->steps[X_AXIS]) enable_x();
if(block->steps_y != 0) enable_y(); if (block->steps[Y_AXIS]) enable_y();
#endif //NOCOREXY #endif
#ifndef Z_LATE_ENABLE #ifndef Z_LATE_ENABLE
if(block->steps_z != 0) enable_z(); if (block->steps[Z_AXIS]) enable_z();
#endif #endif
// Enable extruder(s) // Enable extruder(s)
if(block->steps_e != 0) if (block->steps[E_AXIS]) {
{
#if !defined(MKR4) && !defined(NPR2) #if !defined(MKR4) && !defined(NPR2)
if (DISABLE_INACTIVE_EXTRUDER) //enable only selected extruder if (DISABLE_INACTIVE_EXTRUDER) { //enable only selected extruder
{
if(g_uc_extruder_last_move[0] > 0) g_uc_extruder_last_move[0]--; for (int i=0; i<EXTRUDERS; i++)
if(g_uc_extruder_last_move[1] > 0) g_uc_extruder_last_move[1]--; if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--;
if(g_uc_extruder_last_move[2] > 0) g_uc_extruder_last_move[2]--;
if(g_uc_extruder_last_move[3] > 0) g_uc_extruder_last_move[3]--;
switch(extruder) switch(extruder) {
{
case 0: case 0:
enable_e0(); enable_e0();
g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE*2; g_uc_extruder_last_move[0] = BLOCK_BUFFER_SIZE * 2;
#if EXTRUDERS > 1
if(g_uc_extruder_last_move[1] == 0) disable_e1(); if (g_uc_extruder_last_move[1] == 0) disable_e1();
if(g_uc_extruder_last_move[2] == 0) disable_e2(); #if EXTRUDERS > 2
if(g_uc_extruder_last_move[3] == 0) disable_e3(); if (g_uc_extruder_last_move[2] == 0) disable_e2();
#if EXTRUDERS > 3
if (g_uc_extruder_last_move[3] == 0) disable_e3();
#endif
#endif
#endif
break; break;
#if EXTRUDERS > 1
case 1: case 1:
enable_e1(); enable_e1();
g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2; g_uc_extruder_last_move[1] = BLOCK_BUFFER_SIZE*2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if(g_uc_extruder_last_move[0] == 0) disable_e0(); #if EXTRUDERS > 2
if(g_uc_extruder_last_move[2] == 0) disable_e2(); if (g_uc_extruder_last_move[2] == 0) disable_e2();
if(g_uc_extruder_last_move[3] == 0) disable_e3(); #if EXTRUDERS > 3
if (g_uc_extruder_last_move[3] == 0) disable_e3();
#endif
#endif
break; break;
#if EXTRUDERS > 2
case 2: case 2:
enable_e2(); enable_e2();
g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2; g_uc_extruder_last_move[2] = BLOCK_BUFFER_SIZE*2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if(g_uc_extruder_last_move[0] == 0) disable_e0(); if (g_uc_extruder_last_move[1] == 0) disable_e1();
if(g_uc_extruder_last_move[1] == 0) disable_e1(); #if EXTRUDERS > 3
if(g_uc_extruder_last_move[3] == 0) disable_e3(); if (g_uc_extruder_last_move[3] == 0) disable_e3();
#endif
break; break;
#if EXTRUDERS > 3
case 3: case 3:
enable_e3(); enable_e3();
g_uc_extruder_last_move[3] = BLOCK_BUFFER_SIZE*2; g_uc_extruder_last_move[3] = BLOCK_BUFFER_SIZE*2;
if (g_uc_extruder_last_move[0] == 0) disable_e0();
if(g_uc_extruder_last_move[0] == 0) disable_e0(); if (g_uc_extruder_last_move[1] == 0) disable_e1();
if(g_uc_extruder_last_move[1] == 0) disable_e1(); if (g_uc_extruder_last_move[2] == 0) disable_e2();
if(g_uc_extruder_last_move[2] == 0) disable_e2();
break; break;
#endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1
} }
} }
else //enable all else //enable all
...@@ -785,133 +689,110 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi ...@@ -785,133 +689,110 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
break; break;
} }
#endif //!MKR4 && !NPR2 #endif //!MKR4 && !NPR2
if (feed_rate < minimumfeedrate) feed_rate = minimumfeedrate;
} }
else if (feed_rate < mintravelfeedrate) feed_rate = mintravelfeedrate;
if (block->steps_e == 0)
{
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
}
else
{
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
}
/* This part of the code calculates the total length of the movement. /**
For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS. * This part of the code calculates the total length of the movement.
But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS * For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS.
and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y. * But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS
So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head. * and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y.
Having the real displacement of the head, we can calculate the total movement length and apply the desired speed. * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head.
*/ * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed.
#ifndef COREXY */
float delta_mm[4]; #ifdef COREXY
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
#else
float delta_mm[6]; float delta_mm[6];
delta_mm[X_HEAD] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS]; delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_HEAD] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]; delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
delta_mm[X_AXIS] = ((target[X_AXIS]-position[X_AXIS]) + (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[X_AXIS]; delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
delta_mm[Y_AXIS] = ((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-position[Y_AXIS]))/axis_steps_per_unit[Y_AXIS]; delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
#else
float delta_mm[4];
delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
#endif #endif
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]; delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
delta_mm[E_AXIS] = ((target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[active_extruder+3])*volumetric_multiplier[active_extruder]*extruder_multiplier[active_extruder]/100.0; delta_mm[E_AXIS] = (de / axis_steps_per_unit[E_AXIS + active_extruder]) * volumetric_multiplier[active_extruder] * extruder_multiplier[active_extruder] / 100.0;
if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments )
{ if (block->steps[X_AXIS] <= dropsegments && block->steps[Y_AXIS] <= dropsegments && block->steps[Z_AXIS] <= dropsegments) {
block->millimeters = fabs(delta_mm[E_AXIS]); block->millimeters = fabs(delta_mm[E_AXIS]);
} }
else else {
{ block->millimeters = sqrt(
#ifndef COREXY #ifdef COREXY
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS])); square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD])
#else #else
block->millimeters = sqrt(square(delta_mm[X_HEAD]) + square(delta_mm[Y_HEAD]) + square(delta_mm[Z_AXIS])); square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS])
#endif #endif
+ square(delta_mm[Z_AXIS])
);
} }
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides float inverse_millimeters = 1.0 / block->millimeters; // Inverse millimeters to remove multiple divides
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks. // Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
float inverse_second = feed_rate * inverse_millimeters; float inverse_second = feed_rate * inverse_millimeters;
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1); int moves_queued = movesplanned();
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
#ifdef OLD_SLOWDOWN #ifdef OLD_SLOWDOWN
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1)
feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5); feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
#endif #endif
#ifdef SLOWDOWN #ifdef SLOWDOWN
// segment time im micro seconds // segment time im micro seconds
unsigned long segment_time = lround(1000000.0/inverse_second); unsigned long segment_time = lround(1000000.0 / inverse_second);
if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
{ if (segment_time < minsegmenttime) {
if (segment_time < minsegmenttime) // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
{ // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more. inverse_second = 1000000.0 / (segment_time + lround(2 * (minsegmenttime - segment_time) / moves_queued));
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
#ifdef XY_FREQUENCY_LIMIT #ifdef XY_FREQUENCY_LIMIT
segment_time = lround(1000000.0/inverse_second); segment_time = lround(1000000.0 / inverse_second);
#endif #endif
} }
} }
#endif // SLOWDOWN #endif // SLOWDOWN
// END OF SLOW DOWN SECTION // END OF SLOW DOWN SECTION
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0 block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0 block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #ifdef FILAMENT_SENSOR
//FMM update ring buffer used for delay with filament measurements //FMM update ring buffer used for delay with filament measurements
if (extruder == FILAMENT_SENSOR_EXTRUDER_NUM && delay_index2 > -1) { //only for extruder with filament sensor and if ring buffer is initialized
if((extruder==FILAMENT_SENSOR_EXTRUDER_NUM) && (delay_index2 > -1)) //only for extruder with filament sensor and if ring buffer is initialized const int MMD = MAX_MEASUREMENT_DELAY + 1, MMD10 = MMD * 10;
{
delay_dist = delay_dist + delta_mm[E_AXIS]; //increment counter with next move in e axis
while (delay_dist >= (10*(MAX_MEASUREMENT_DELAY+1))) //check if counter is over max buffer size in mm
delay_dist = delay_dist - 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer
while (delay_dist<0)
delay_dist = delay_dist + 10*(MAX_MEASUREMENT_DELAY+1); //loop around the buffer
delay_index1=delay_dist/10.0; //calculate index delay_dist += delta_mm[E_AXIS]; //increment counter with next move in e axis
while (delay_dist >= MMD10) delay_dist -= MMD10; // loop around the buffer
while (delay_dist < 0) delay_dist += MMD10;
//ensure the number is within range of the array after converting from floating point delay_index1 = delay_dist / 10.0; // calculate index
if(delay_index1<0) delay_index1 = constrain(delay_index1, 0, MAX_MEASUREMENT_DELAY); // (already constrained above)
delay_index1=0;
else if (delay_index1>MAX_MEASUREMENT_DELAY)
delay_index1=MAX_MEASUREMENT_DELAY;
if(delay_index1 != delay_index2) //moved index if (delay_index1 != delay_index2) { // moved index
{ meas_sample = widthFil_to_size_ratio() - 100; // Subtract 100 to reduce magnitude - to store in a signed char
meas_sample=widthFil_to_size_ratio()-100; //subtract off 100 to reduce magnitude - to store in a signed char while (delay_index1 != delay_index2) {
// Increment and loop around buffer
if (++delay_index2 >= MMD) delay_index2 -= MMD;
delay_index2 = constrain(delay_index2, 0, MAX_MEASUREMENT_DELAY);
measurement_delay[delay_index2] = meas_sample;
} }
while( delay_index1 != delay_index2)
{
delay_index2 = delay_index2 + 1;
if(delay_index2>MAX_MEASUREMENT_DELAY)
delay_index2=delay_index2-(MAX_MEASUREMENT_DELAY+1); //loop around buffer when incrementing
if(delay_index2<0)
delay_index2=0;
else if (delay_index2>MAX_MEASUREMENT_DELAY)
delay_index2=MAX_MEASUREMENT_DELAY;
measurement_delay[delay_index2]=meas_sample;
} }
} }
#endif #endif
// Calculate and limit speed in mm/sec for each axis // Calculate and limit speed in mm/sec for each axis
float current_speed[4]; float current_speed[4];
float speed_factor = 1.0; //factor <=1 do decrease speed float speed_factor = 1.0; //factor <=1 do decrease speed
for(int i=0; i < 3; i++) for(int i=0; i < 3; i++) {
{
current_speed[i] = delta_mm[i] * inverse_second; current_speed[i] = delta_mm[i] * inverse_second;
if(fabs(current_speed[i]) > max_feedrate[i]) float cs = fabs(current_speed[i]), mf = max_feedrate[i];
speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i])); if (cs > mf) speed_factor = min(speed_factor, mf / cs);
} }
current_speed[E_AXIS] = delta_mm[E_AXIS] * inverse_second; current_speed[E_AXIS] = delta_mm[E_AXIS] * inverse_second;
...@@ -927,45 +808,41 @@ Having the real displacement of the head, we can calculate the total movement le ...@@ -927,45 +808,41 @@ Having the real displacement of the head, we can calculate the total movement le
} }
// Max segement time in us. // Max segement time in us.
#ifdef XY_FREQUENCY_LIMIT #ifdef XY_FREQUENCY_LIMIT
#define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT) #define MAX_FREQ_TIME (1000000.0/XY_FREQUENCY_LIMIT)
// Check and limit the xy direction change frequency // Check and limit the xy direction change frequency
unsigned char direction_change = block->direction_bits ^ old_direction_bits; unsigned char direction_change = block->direction_bits ^ old_direction_bits;
old_direction_bits = block->direction_bits; old_direction_bits = block->direction_bits;
segment_time = lround((float)segment_time / speed_factor); segment_time = lround((float)segment_time / speed_factor);
if((direction_change & BIT(X_AXIS)) == 0) if((direction_change & BIT(X_AXIS)) == 0) {
{
x_segment_time[0] += segment_time; x_segment_time[0] += segment_time;
} }
else else {
{
x_segment_time[2] = x_segment_time[1]; x_segment_time[2] = x_segment_time[1];
x_segment_time[1] = x_segment_time[0]; x_segment_time[1] = x_segment_time[0];
x_segment_time[0] = segment_time; x_segment_time[0] = segment_time;
} }
if((direction_change & BIT(Y_AXIS)) == 0)
{ if((direction_change & BIT(Y_AXIS)) == 0) {
y_segment_time[0] += segment_time; y_segment_time[0] += segment_time;
} }
else else {
{
y_segment_time[2] = y_segment_time[1]; y_segment_time[2] = y_segment_time[1];
y_segment_time[1] = y_segment_time[0]; y_segment_time[1] = y_segment_time[0];
y_segment_time[0] = segment_time; y_segment_time[0] = segment_time;
} }
long max_x_segment_time = max(x_segment_time[0], max(x_segment_time[1], x_segment_time[2])); long max_x_segment_time = max(x_segment_time[0], max(x_segment_time[1], x_segment_time[2]));
long max_y_segment_time = max(y_segment_time[0], max(y_segment_time[1], y_segment_time[2])); long max_y_segment_time = max(y_segment_time[0], max(y_segment_time[1], y_segment_time[2]));
long min_xy_segment_time =min(max_x_segment_time, max_y_segment_time); long min_xy_segment_time =min(max_x_segment_time, max_y_segment_time);
if(min_xy_segment_time < MAX_FREQ_TIME) if(min_xy_segment_time < MAX_FREQ_TIME)
speed_factor = min(speed_factor, speed_factor * (float)min_xy_segment_time / (float)MAX_FREQ_TIME); speed_factor = min(speed_factor, speed_factor * (float)min_xy_segment_time / (float)MAX_FREQ_TIME);
#endif // XY_FREQUENCY_LIMIT #endif // XY_FREQUENCY_LIMIT
// Correct the speed // Correct the speed
if( speed_factor < 1.0) if( speed_factor < 1.0) {
{ for(unsigned char i=0; i < 4; i++) {
for(unsigned char i=0; i < 4; i++)
{
current_speed[i] *= speed_factor; current_speed[i] *= speed_factor;
} }
block->nominal_speed *= speed_factor; block->nominal_speed *= speed_factor;
...@@ -974,32 +851,29 @@ Having the real displacement of the head, we can calculate the total movement le ...@@ -974,32 +851,29 @@ Having the real displacement of the head, we can calculate the total movement le
// Compute and limit the acceleration rate for the trapezoid generator. // Compute and limit the acceleration rate for the trapezoid generator.
float steps_per_mm = block->step_event_count/block->millimeters; float steps_per_mm = block->step_event_count/block->millimeters;
if(block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0) if(block->steps[X_AXIS] == 0 && block->steps[Y_AXIS] == 0 && block->steps[Z_AXIS] == 0) {
{
block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
} }
else if(block->steps_e == 0) else if(block->steps[E_AXIS] == 0) {
{
block->acceleration_st = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 block->acceleration_st = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
} }
else else {
{
block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
} }
// Limit acceleration per axis // Limit acceleration per axis
if(((float)block->acceleration_st * (float)block->steps_x / (float)block->step_event_count) > axis_steps_per_sqr_second[X_AXIS]) if(((float)block->acceleration_st * (float)block->steps[X_AXIS] / (float)block->step_event_count) > axis_steps_per_sqr_second[X_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS]; block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
if(((float)block->acceleration_st * (float)block->steps_y / (float)block->step_event_count) > axis_steps_per_sqr_second[Y_AXIS]) if(((float)block->acceleration_st * (float)block->steps[Y_AXIS] / (float)block->step_event_count) > axis_steps_per_sqr_second[Y_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS]; block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
if(((float)block->acceleration_st * (float)block->steps_e / (float)block->step_event_count) > axis_steps_per_sqr_second[E_AXIS]) if(((float)block->acceleration_st * (float)block->steps[E_AXIS] / (float)block->step_event_count) > axis_steps_per_sqr_second[E_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS]; block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
if(((float)block->acceleration_st * (float)block->steps_z / (float)block->step_event_count ) > axis_steps_per_sqr_second[Z_AXIS]) if(((float)block->acceleration_st * (float)block->steps[Z_AXIS] / (float)block->step_event_count ) > axis_steps_per_sqr_second[Z_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS]; block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
block->acceleration = block->acceleration_st / steps_per_mm; block->acceleration = block->acceleration_st / steps_per_mm;
block->acceleration_rate = (long)((float)block->acceleration_st * (16777216.0 / (F_CPU / 8.0))); block->acceleration_rate = (long)((float)block->acceleration_st * (16777216.0 / (F_CPU / 8.0)));
#if 0 // Use old jerk for now #if 0 // Use old jerk for now
// Compute path unit vector // Compute path unit vector
double unit_vec[3]; double unit_vec[3];
...@@ -1038,7 +912,7 @@ Having the real displacement of the head, we can calculate the total movement le ...@@ -1038,7 +912,7 @@ Having the real displacement of the head, we can calculate the total movement le
} }
} }
} }
#endif #endif
// Start with a safe speed // Start with a safe speed
float vmax_junction = max_xy_jerk/2; float vmax_junction = max_xy_jerk/2;
float vmax_junction_factor = 1.0; float vmax_junction_factor = 1.0;
...@@ -1091,10 +965,9 @@ Having the real displacement of the head, we can calculate the total movement le ...@@ -1091,10 +965,9 @@ Having the real displacement of the head, we can calculate the total movement le
memcpy(previous_speed, current_speed, sizeof(previous_speed)); // previous_speed[] = current_speed[] memcpy(previous_speed, current_speed, sizeof(previous_speed)); // previous_speed[] = current_speed[]
previous_nominal_speed = block->nominal_speed; previous_nominal_speed = block->nominal_speed;
#ifdef ADVANCE
#ifdef ADVANCE
// Calculate advance rate // Calculate advance rate
if((block->steps_e == 0) || (block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0)) { if((block->steps[E_AXIS] == 0) || (block->steps[X_AXIS] == 0 && block->steps[Y_AXIS] == 0 && block->steps[Z_AXIS] == 0)) {
block->advance_rate = 0; block->advance_rate = 0;
block->advance = 0; block->advance = 0;
} }
...@@ -1117,7 +990,7 @@ Having the real displacement of the head, we can calculate the total movement le ...@@ -1117,7 +990,7 @@ Having the real displacement of the head, we can calculate the total movement le
SERIAL_ECHOPGM("advance rate :"); SERIAL_ECHOPGM("advance rate :");
SERIAL_ECHOLN(block->advance_rate/256.0); SERIAL_ECHOLN(block->advance_rate/256.0);
*/ */
#endif // ADVANCE #endif // ADVANCE
calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed, calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
safe_speed/block->nominal_speed); safe_speed/block->nominal_speed);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
// the source g-code and may never actually be reached if acceleration management is active. // the source g-code and may never actually be reached if acceleration management is active.
typedef struct { typedef struct {
// Fields used by the bresenham algorithm for tracing the line // Fields used by the bresenham algorithm for tracing the line
long steps_x, steps_y, steps_z, steps_e; // Step count along each axis long steps[NUM_AXIS]; // Step count along each axis
unsigned long step_event_count; // The number of step events required to complete this block unsigned long step_event_count; // The number of step events required to complete this block
long accelerate_until; // The index of the step event on which to stop acceleration long accelerate_until; // The index of the step event on which to stop acceleration
long decelerate_after; // The index of the step event on which to start decelerating long decelerate_after; // The index of the step event on which to start decelerating
...@@ -74,6 +74,8 @@ typedef struct { ...@@ -74,6 +74,8 @@ typedef struct {
volatile char busy; volatile char busy;
} block_t; } block_t;
#define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
// this holds the required transform to compensate for bed level // this holds the required transform to compensate for bed level
extern matrix_3x3 plan_bed_level_matrix; extern matrix_3x3 plan_bed_level_matrix;
......
...@@ -107,11 +107,8 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; ...@@ -107,11 +107,8 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
X_DIR_WRITE(v); \ X_DIR_WRITE(v); \
X2_DIR_WRITE(v); \ X2_DIR_WRITE(v); \
} \ } \
else{ \ else { \
if (current_block->active_driver) \ if (current_block->active_driver) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \
X2_DIR_WRITE(v); \
else \
X_DIR_WRITE(v); \
} }
#define X_APPLY_STEP(v,ALWAYS) \ #define X_APPLY_STEP(v,ALWAYS) \
if (extruder_duplication_enabled || ALWAYS) { \ if (extruder_duplication_enabled || ALWAYS) { \
...@@ -119,10 +116,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; ...@@ -119,10 +116,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
X2_STEP_WRITE(v); \ X2_STEP_WRITE(v); \
} \ } \
else { \ else { \
if (current_block->active_driver != 0) \ if (current_block->active_driver != 0) X2_STEP_WRITE(v); else X_STEP_WRITE(v); \
X2_STEP_WRITE(v); \
else \
X_STEP_WRITE(v); \
} }
#else #else
#define X_APPLY_DIR(v,Q) X_DIR_WRITE(v) #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 }; ...@@ -130,16 +124,16 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
#endif #endif
#ifdef Y_DUAL_STEPPER_DRIVERS #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_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_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }
#else #else
#define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v) #define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v)
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v) #define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
#endif #endif
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
#define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v), Z2_DIR_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) #define Z_APPLY_STEP(v,Q) { Z_STEP_WRITE(v); Z2_STEP_WRITE(v); }
#else #else
#define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v) #define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v)
#define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v) #define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v)
...@@ -423,7 +417,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -423,7 +417,7 @@ ISR(TIMER1_COMPA_vect) {
step_events_completed = 0; step_events_completed = 0;
#ifdef Z_LATE_ENABLE #ifdef Z_LATE_ENABLE
if (current_block->steps_z > 0) { if (current_block->steps[Z_AXIS] > 0) {
enable_z(); enable_z();
OCR1A = 2000; //1ms wait OCR1A = 2000; //1ms wait
return; return;
...@@ -464,7 +458,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -464,7 +458,7 @@ ISR(TIMER1_COMPA_vect) {
#define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \ #define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \
bool axis ##_## minmax ##_endstop = (READ(AXIS ##_## MINMAX ##_PIN) != AXIS ##_## MINMAX ##_ENDSTOP_INVERTING); \ bool axis ##_## minmax ##_endstop = (READ(AXIS ##_## MINMAX ##_PIN) != AXIS ##_## MINMAX ##_ENDSTOP_INVERTING); \
if (axis ##_## minmax ##_endstop && old_## axis ##_## minmax ##_endstop && (current_block->steps_## axis > 0)) { \ if (axis ##_## minmax ##_endstop && old_## axis ##_## minmax ##_endstop && (current_block->steps[AXIS ##_AXIS] > 0)) { \
endstops_trigsteps[AXIS ##_AXIS] = count_position[AXIS ##_AXIS]; \ endstops_trigsteps[AXIS ##_AXIS] = count_position[AXIS ##_AXIS]; \
endstop_## axis ##_hit = true; \ endstop_## axis ##_hit = true; \
step_events_completed = current_block->step_event_count; \ step_events_completed = current_block->step_event_count; \
...@@ -473,13 +467,13 @@ ISR(TIMER1_COMPA_vect) { ...@@ -473,13 +467,13 @@ ISR(TIMER1_COMPA_vect) {
// Check X and Y endstops // Check X and Y endstops
if (check_endstops) { if (check_endstops) {
#ifndef COREXY #ifdef COREXY
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular cartesians bot)
#else
// Head direction in -X axis for CoreXY bots. // Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis // If DeltaX == -DeltaY, the movement is only in Y axis
if (current_block->steps_x != current_block->steps_y || (TEST(out_bits, X_AXIS) == TEST(out_bits, Y_AXIS))) if (current_block->steps[A_AXIS] != current_block->steps[B_AXIS] || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS)))
if (TEST(out_bits, X_HEAD)) if (TEST(out_bits, X_HEAD))
#else
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular cartesians bot)
#endif #endif
{ // -direction { // -direction
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
...@@ -503,14 +497,13 @@ ISR(TIMER1_COMPA_vect) { ...@@ -503,14 +497,13 @@ ISR(TIMER1_COMPA_vect) {
#endif #endif
} }
} }
#ifdef COREXY
#ifndef COREXY
if (TEST(out_bits, Y_AXIS)) // -direction
#else
// Head direction in -Y axis for CoreXY bots. // Head direction in -Y axis for CoreXY bots.
// If DeltaX == DeltaY, the movement is only in X axis // If DeltaX == DeltaY, the movement is only in X axis
if (current_block->steps_x != current_block->steps_y || (TEST(out_bits, X_AXIS) != TEST(out_bits, Y_AXIS))) if (current_block->steps[A_AXIS] != current_block->steps[B_AXIS] || (TEST(out_bits, A_AXIS) != TEST(out_bits, B_AXIS)))
if (TEST(out_bits, Y_HEAD)) if (TEST(out_bits, Y_HEAD))
#else
if (TEST(out_bits, Y_AXIS)) // -direction
#endif #endif
{ // -direction { // -direction
#if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0 #if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0
...@@ -559,7 +552,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -559,7 +552,7 @@ ISR(TIMER1_COMPA_vect) {
if (check_endstops) { if (check_endstops) {
#if defined(E_MIN_PIN) && E_MIN_PIN > -1 #if defined(E_MIN_PIN) && E_MIN_PIN > -1
bool e_min_endstop=(READ(E_MIN_PIN) != E_MIN_ENDSTOP_INVERTING); bool e_min_endstop=(READ(E_MIN_PIN) != E_MIN_ENDSTOP_INVERTING);
if (e_min_endstop && old_e_min_endstop && (current_block->steps_e > 0)) { if (e_min_endstop && old_e_min_endstop && (current_block->steps[E_AXIS] > 0)) {
endstops_trigsteps[E_AXIS] = count_position[E_AXIS]; endstops_trigsteps[E_AXIS] = count_position[E_AXIS];
endstop_e_hit=true; endstop_e_hit=true;
step_events_completed = current_block->step_event_count; step_events_completed = current_block->step_event_count;
...@@ -582,7 +575,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -582,7 +575,7 @@ ISR(TIMER1_COMPA_vect) {
#endif #endif
#ifdef ADVANCE #ifdef ADVANCE
counter_e += current_block->steps_e; counter_e += current_block->steps[E_AXIS];
if (counter_e > 0) { if (counter_e > 0) {
counter_e -= current_block->step_event_count; counter_e -= current_block->step_event_count;
e_steps[current_block->active_driver] += TEST(out_bits, E_AXIS) ? -1 : 1; e_steps[current_block->active_driver] += TEST(out_bits, E_AXIS) ? -1 : 1;
...@@ -596,15 +589,14 @@ ISR(TIMER1_COMPA_vect) { ...@@ -596,15 +589,14 @@ ISR(TIMER1_COMPA_vect) {
* instead of doing each in turn. The extra tests add enough * instead of doing each in turn. The extra tests add enough
* lag to allow it work with without needing NOPs * lag to allow it work with without needing NOPs
*/ */
counter_x += current_block->steps_x; #define STEP_ADD(axis, AXIS) \
if (counter_x > 0) X_STEP_WRITE(HIGH); counter_## axis += current_block->steps[AXIS ##_AXIS]; \
counter_y += current_block->steps_y; if (counter_## axis > 0) { AXIS ##_STEP_WRITE(HIGH); }
if (counter_y > 0) Y_STEP_WRITE(HIGH); STEP_ADD(x,X);
counter_z += current_block->steps_z; STEP_ADD(y,Y);
if (counter_z > 0) Z_STEP_WRITE(HIGH); STEP_ADD(z,Z);
#ifndef ADVANCE #ifndef ADVANCE
counter_e += current_block->steps_e; STEP_ADD(e,E);
if (counter_e > 0) E_STEP_WRITE(HIGH);
#endif #endif
#define STEP_IF_COUNTER(axis, AXIS) \ #define STEP_IF_COUNTER(axis, AXIS) \
...@@ -624,7 +616,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -624,7 +616,7 @@ ISR(TIMER1_COMPA_vect) {
#else // !CONFIG_STEPPERS_TOSHIBA #else // !CONFIG_STEPPERS_TOSHIBA
#define APPLY_MOVEMENT(axis, AXIS) \ #define APPLY_MOVEMENT(axis, AXIS) \
counter_## axis += current_block->steps_## axis; \ counter_## axis += current_block->steps[AXIS ##_AXIS]; \
if (counter_## axis > 0) { \ if (counter_## axis > 0) { \
AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN,0); \ AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN,0); \
counter_## axis -= current_block->step_event_count; \ counter_## axis -= current_block->step_event_count; \
......
...@@ -41,21 +41,17 @@ ...@@ -41,21 +41,17 @@
//================================== macros ================================= //================================== macros =================================
//=========================================================================== //===========================================================================
#ifndef SINGLENOZZLE #if HOTENDS > 4
#if EXTRUDERS > 4 #error Unsupported number of hotends
#error Unsupported number of extruders #elif HOTENDS > 3
#elif EXTRUDERS > 3 #define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2, v3, v4 }
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3, v4 } #elif HOTENDS > 2
#elif EXTRUDERS > 2 #define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2, v3 }
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3 } #elif HOTENDS > 1
#elif EXTRUDERS > 1 #define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1, v2 }
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2 }
#else
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1 }
#endif
#else #else
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1 } #define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1 }
#endif //SINGLENOZZLE #endif
#define HAS_TEMP_0 (defined(TEMP_0_PIN) && TEMP_0_PIN >= 0) #define HAS_TEMP_0 (defined(TEMP_0_PIN) && TEMP_0_PIN >= 0)
#define HAS_TEMP_1 (defined(TEMP_1_PIN) && TEMP_1_PIN >= 0) #define HAS_TEMP_1 (defined(TEMP_1_PIN) && TEMP_1_PIN >= 0)
...@@ -84,17 +80,12 @@ ...@@ -84,17 +80,12 @@
#ifdef PID_dT #ifdef PID_dT
#undef PID_dT #undef PID_dT
#endif #endif
#define PID_dT ((OVERSAMPLENR * 12.0)/(F_CPU / 64.0 / 256.0)) #define PID_dT ((OVERSAMPLENR * 14.0)/(F_CPU / 64.0 / 256.0))
int target_temperature[HOTENDS] = { 0 };
int current_temperature_raw[HOTENDS] = { 0 };
float current_temperature[HOTENDS] = { 0.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_bed = 0; int target_temperature_bed = 0;
int current_temperature_bed_raw = 0; int current_temperature_bed_raw = 0;
float current_temperature_bed = 0.0; float current_temperature_bed = 0.0;
...@@ -103,11 +94,7 @@ float current_temperature_bed = 0.0; ...@@ -103,11 +94,7 @@ float current_temperature_bed = 0.0;
float redundant_temperature = 0.0; float redundant_temperature = 0.0;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
#ifndef SINGLENOZZLE float Kp[HOTENDS],Ki[HOTENDS],Kd[HOTENDS];
float Kp[EXTRUDERS],Ki[EXTRUDERS],Kd[EXTRUDERS];
#else
float Kp[1],Ki[1],Kd[1];
#endif
#endif //PIDTEMP #endif //PIDTEMP
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
...@@ -133,6 +120,7 @@ unsigned char soft_pwm_bed; ...@@ -133,6 +120,7 @@ unsigned char soft_pwm_bed;
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
int current_raw_powconsumption = 0; //Holds measured power consumption int current_raw_powconsumption = 0; //Holds measured power consumption
#endif #endif
//=========================================================================== //===========================================================================
//=============================private variables============================ //=============================private variables============================
//=========================================================================== //===========================================================================
...@@ -140,33 +128,16 @@ static volatile bool temp_meas_ready = false; ...@@ -140,33 +128,16 @@ static volatile bool temp_meas_ready = false;
#ifdef PIDTEMP #ifdef PIDTEMP
//static cannot be external: //static cannot be external:
#ifndef SINGLENOZZLE static float temp_iState[HOTENDS] = { 0 };
static float temp_iState[EXTRUDERS] = { 0 }; static float temp_dState[HOTENDS] = { 0 };
static float temp_dState[EXTRUDERS] = { 0 }; static float pTerm[HOTENDS];
static float pTerm[EXTRUDERS]; static float iTerm[HOTENDS];
static float iTerm[EXTRUDERS]; static float dTerm[HOTENDS];
static float dTerm[EXTRUDERS];
//int output; //int output;
static float pid_error[EXTRUDERS]; static float pid_error[HOTENDS];
static float temp_iState_min[EXTRUDERS]; static float temp_iState_min[HOTENDS];
static float temp_iState_max[EXTRUDERS]; static float temp_iState_max[HOTENDS];
// static float pid_input[EXTRUDERS]; static bool pid_reset[HOTENDS];
// 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
#endif //PIDTEMP #endif //PIDTEMP
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
//static cannot be external: //static cannot be external:
...@@ -182,11 +153,9 @@ static volatile bool temp_meas_ready = false; ...@@ -182,11 +153,9 @@ static volatile bool temp_meas_ready = false;
#else //PIDTEMPBED #else //PIDTEMPBED
static unsigned long previous_millis_bed_heater; static unsigned long previous_millis_bed_heater;
#endif //PIDTEMPBED #endif //PIDTEMPBED
#ifndef SINGLENOZZLE
static unsigned char soft_pwm[EXTRUDERS]; static unsigned char soft_pwm[HOTENDS];
#else
static unsigned char soft_pwm[1];
#endif
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
static unsigned char soft_pwm_fan; static unsigned char soft_pwm_fan;
#endif #endif
...@@ -195,19 +164,11 @@ static volatile bool temp_meas_ready = false; ...@@ -195,19 +164,11 @@ static volatile bool temp_meas_ready = false;
#endif #endif
// Init min and max temp with extreme values to prevent false errors during startup // Init min and max temp with extreme values to prevent false errors during startup
#ifndef SINGLENOZZLE 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 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[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 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[HOTENDS] = ARRAY_BY_HOTENDS( 0, 0, 0, 0 );
static int minttemp[EXTRUDERS] = ARRAY_BY_EXTRUDERS( 0, 0, 0, 0 ); static int maxttemp[HOTENDS] = ARRAY_BY_HOTENDS( 16383, 16383, 16383, 16383 );
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?!? */
//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
#ifdef BED_MAXTEMP #ifdef BED_MAXTEMP
static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP; static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP;
...@@ -217,8 +178,8 @@ static volatile bool temp_meas_ready = false; ...@@ -217,8 +178,8 @@ static volatile bool temp_meas_ready = false;
static void *heater_ttbl_map[2] = {(void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE }; 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 }; static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
#else #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 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[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN, HEATER_3_TEMPTABLE_LEN ); 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 #endif
static float analog2temp(int raw, uint8_t e); static float analog2temp(int raw, uint8_t e);
...@@ -226,13 +187,8 @@ static float analog2tempBed(int raw); ...@@ -226,13 +187,8 @@ static float analog2tempBed(int raw);
static void updateTemperaturesFromRawValues(); static void updateTemperaturesFromRawValues();
#ifdef WATCH_TEMP_PERIOD #ifdef WATCH_TEMP_PERIOD
#ifndef SINGLENOZZLE int watch_start_temp[HOTENDS] = ARRAY_BY_HOTENDS(0,0,0,0);
int watch_start_temp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0,0); unsigned long watchmillis[HOTENDS] = ARRAY_BY_HOTENDS(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
#endif //WATCH_TEMP_PERIOD #endif //WATCH_TEMP_PERIOD
#ifndef SOFT_PWM_SCALE #ifndef SOFT_PWM_SCALE
...@@ -251,7 +207,8 @@ static void updateTemperaturesFromRawValues(); ...@@ -251,7 +207,8 @@ static void updateTemperaturesFromRawValues();
//============================= functions ============================ //============================= functions ============================
//=========================================================================== //===========================================================================
void PID_autotune(float temp, int extruder, int ncycles) { void PID_autotune(float temp, int hotend, int ncycles)
{
float input = 0.0; float input = 0.0;
int cycles = 0; int cycles = 0;
bool heating = true; bool heating = true;
...@@ -268,9 +225,9 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -268,9 +225,9 @@ void PID_autotune(float temp, int extruder, int ncycles) {
unsigned long extruder_autofan_last_check = temp_millis; unsigned long extruder_autofan_last_check = temp_millis;
#endif #endif
if (extruder >= EXTRUDERS if (hotend >= HOTENDS
#if !HAS_TEMP_BED #if !HAS_TEMP_BED
|| extruder < 0 || hotend < 0
#endif #endif
) { ) {
SERIAL_ECHOLN(MSG_PID_BAD_EXTRUDER_NUM); SERIAL_ECHOLN(MSG_PID_BAD_EXTRUDER_NUM);
...@@ -281,10 +238,10 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -281,10 +238,10 @@ void PID_autotune(float temp, int extruder, int ncycles) {
disable_heater(); // switch off all heaters. disable_heater(); // switch off all heaters.
if (extruder < 0) if (hotend < 0)
soft_pwm_bed = bias = d = MAX_BED_POWER / 2; soft_pwm_bed = bias = d = MAX_BED_POWER / 2;
else else
soft_pwm[extruder] = bias = d = PID_MAX / 2; soft_pwm[hotend] = bias = d = PID_MAX / 2;
// PID Tuning loop // PID Tuning loop
for(;;) { for(;;) {
...@@ -294,7 +251,7 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -294,7 +251,7 @@ void PID_autotune(float temp, int extruder, int ncycles) {
if (temp_meas_ready == true) { // temp sample ready if (temp_meas_ready == true) { // temp sample ready
updateTemperaturesFromRawValues(); updateTemperaturesFromRawValues();
input = (extruder<0)?current_temperature_bed:current_temperature[extruder]; input = (hotend<0)?current_temperature_bed:current_temperature[hotend];
max = max(max, input); max = max(max, input);
min = min(min, input); min = min(min, input);
...@@ -309,10 +266,10 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -309,10 +266,10 @@ void PID_autotune(float temp, int extruder, int ncycles) {
if (heating == true && input > temp) { if (heating == true && input > temp) {
if (ms - t2 > 5000) { if (ms - t2 > 5000) {
heating = false; heating = false;
if (extruder < 0) if (hotend < 0)
soft_pwm_bed = (bias - d) >> 1; soft_pwm_bed = (bias - d) >> 1;
else else
soft_pwm[extruder] = (bias - d) >> 1; soft_pwm[hotend] = (bias - d) >> 1;
t1 = ms; t1 = ms;
t_high = t1 - t2; t_high = t1 - t2;
max = temp; max = temp;
...@@ -324,7 +281,7 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -324,7 +281,7 @@ void PID_autotune(float temp, int extruder, int ncycles) {
t2 = ms; t2 = ms;
t_low = t2 - t1; t_low = t2 - t1;
if (cycles > 0) { 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 += (d*(t_high - t_low))/(t_low + t_high);
bias = constrain(bias, 20, max_pow - 20); bias = constrain(bias, 20, max_pow - 20);
d = (bias > max_pow / 2) ? max_pow - 1 - bias : bias; d = (bias > max_pow / 2) ? max_pow - 1 - bias : bias;
...@@ -363,10 +320,10 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -363,10 +320,10 @@ void PID_autotune(float temp, int extruder, int ncycles) {
*/ */
} }
} }
if (extruder < 0) if (hotend < 0)
soft_pwm_bed = (bias + d) >> 1; soft_pwm_bed = (bias + d) >> 1;
else else
soft_pwm[extruder] = (bias + d) >> 1; soft_pwm[hotend] = (bias + d) >> 1;
cycles++; cycles++;
min = temp; min = temp;
} }
...@@ -379,12 +336,12 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -379,12 +336,12 @@ void PID_autotune(float temp, int extruder, int ncycles) {
// Every 2 seconds... // Every 2 seconds...
if (ms > temp_millis + 2000) { if (ms > temp_millis + 2000) {
int p; int p;
if (extruder < 0) { if (hotend < 0) {
p = soft_pwm_bed; p = soft_pwm_bed;
SERIAL_PROTOCOLPGM(MSG_OK_B); SERIAL_PROTOCOLPGM(MSG_OK_B);
} }
else { else {
p = soft_pwm[extruder]; p = soft_pwm[hotend];
SERIAL_PROTOCOLPGM(MSG_OK_T); SERIAL_PROTOCOLPGM(MSG_OK_T);
} }
...@@ -409,13 +366,9 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -409,13 +366,9 @@ void PID_autotune(float temp, int extruder, int ncycles) {
void updatePID() { void updatePID() {
#ifdef PIDTEMP #ifdef PIDTEMP
#ifndef SINGLENOZZLE for (int e = 0; e < HOTENDS; e++) {
for(int e = 0; e < EXTRUDERS; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e]; temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e];
} }
#else
temp_iState_max[0] = PID_INTEGRAL_DRIVE_MAX / Ki[0];
#endif
#endif #endif
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi; temp_iState_max_bed = PID_INTEGRAL_DRIVE_MAX / bedKi;
...@@ -427,7 +380,6 @@ int getHeaterPower(int heater) { ...@@ -427,7 +380,6 @@ int getHeaterPower(int heater) {
} }
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
#if HAS_FAN #if HAS_FAN
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN #if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
#error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN" #error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
...@@ -443,17 +395,17 @@ int getHeaterPower(int heater) { ...@@ -443,17 +395,17 @@ int getHeaterPower(int heater) {
#endif #endif
#endif #endif
void setExtruderAutoFanState(int pin, bool state) void setExtruderAutoFanState(int pin, bool state)
{ {
unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0; unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0;
// this idiom allows both digital and PWM fan outputs (see M42 handling). // this idiom allows both digital and PWM fan outputs (see M42 handling).
pinMode(pin, OUTPUT); pinMode(pin, OUTPUT);
digitalWrite(pin, newFanSpeed); digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed); analogWrite(pin, newFanSpeed);
} }
void checkExtruderAutoFans() void checkExtruderAutoFans()
{ {
uint8_t fanState = 0; uint8_t fanState = 0;
// which fan pins need to be turned on? // which fan pins need to be turned on?
...@@ -462,7 +414,6 @@ void checkExtruderAutoFans() ...@@ -462,7 +414,6 @@ void checkExtruderAutoFans()
fanState |= 1; fanState |= 1;
#endif #endif
#ifndef SINGLENOZZLE
#if HAS_AUTO_FAN_1 #if HAS_AUTO_FAN_1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{ {
...@@ -494,14 +445,12 @@ void checkExtruderAutoFans() ...@@ -494,14 +445,12 @@ void checkExtruderAutoFans()
fanState |= 8; fanState |= 8;
} }
#endif #endif
#endif // !SINLGENOZZE
// update extruder auto fan states // update extruder auto fan states
#if HAS_AUTO_FAN_0 #if HAS_AUTO_FAN_0
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
#endif #endif
#ifndef SINGLENOZZLE
#if HAS_AUTO_FAN_1 #if HAS_AUTO_FAN_1
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
...@@ -517,39 +466,38 @@ void checkExtruderAutoFans() ...@@ -517,39 +466,38 @@ void checkExtruderAutoFans()
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0); setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0);
#endif #endif
#endif //!SINGLENOZZLE }
}
#endif // any extruder auto fan pins set #endif // any extruder auto fan pins set
// //
// Error checking and Write Routines // Error checking and Write Routines
// //
#if EXTRUDERS > 0 #if HOTENDS > 0
#if !HAS_HEATER_0 #if !HAS_HEATER_0
#error HEATER_0_PIN not defined for this board #error HEATER_0_PIN not defined for this board
#endif #endif
#define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, v) #define WRITE_HEATER_0P(v) WRITE(HEATER_0_PIN, v)
#endif #endif
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1 || defined(HEATERS_PARALLEL) #if HOTENDS > 1 || defined(HEATERS_PARALLEL)
#if !HAS_HEATER_1 #if !HAS_HEATER_1
#error HEATER_1_PIN not defined for this board #error HEATER_1_PIN not defined for this board
#endif #endif
#define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, v) #define WRITE_HEATER_1(v) WRITE(HEATER_1_PIN, v)
#if EXTRUDERS > 2 #if HOTENDS > 2
#if !HAS_HEATER_2 #if !HAS_HEATER_2
#error HEATER_2_PIN not defined for this board #error HEATER_2_PIN not defined for this board
#endif #endif
#define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, v) #define WRITE_HEATER_2(v) WRITE(HEATER_2_PIN, v)
#if EXTRUDERS > 3 #if HOTENDS > 3
#if !HAS_HEATER_3 #if !HAS_HEATER_3
#error HEATER_3_PIN not defined for this board #error HEATER_3_PIN not defined for this board
#endif #endif
#define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, v) #define WRITE_HEATER_3(v) WRITE(HEATER_3_PIN, v)
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#ifdef HEATERS_PARALLEL #ifdef HEATERS_PARALLEL
#define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); } #define WRITE_HEATER_0(v) { WRITE_HEATER_0P(v); WRITE_HEATER_1(v); }
#else #else
...@@ -608,14 +556,9 @@ void manage_heater() { ...@@ -608,14 +556,9 @@ void manage_heater() {
unsigned long ms = millis(); unsigned long ms = millis();
// Loop through all extruders // Loop through all hotends
#ifndef SINGLENOZZLE for (int e = 0; e < HOTENDS; e++)
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
{ {
#if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 #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); 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 #endif
...@@ -706,7 +649,7 @@ void manage_heater() { ...@@ -706,7 +649,7 @@ void manage_heater() {
_temp_error(-1, MSG_EXTRUDER_SWITCHED_OFF, MSG_ERR_REDUNDANT_TEMP); _temp_error(-1, MSG_EXTRUDER_SWITCHED_OFF, MSG_ERR_REDUNDANT_TEMP);
} }
#endif //TEMP_SENSOR_1_AS_REDUNDANT #endif //TEMP_SENSOR_1_AS_REDUNDANT
} // Extruders Loop } // Hotends Loop
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
if (ms > extruder_autofan_last_check + 2500) { // only need to check fan state very infrequently if (ms > extruder_autofan_last_check + 2500) { // only need to check fan state very infrequently
...@@ -858,7 +801,7 @@ static float analog2temp(int raw, uint8_t e) { ...@@ -858,7 +801,7 @@ static float analog2temp(int raw, uint8_t e) {
return celsius; 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() // Derived from RepRap FiveD extruder::getTemperature()
...@@ -885,7 +828,7 @@ static float analog2tempBed(int raw) { ...@@ -885,7 +828,7 @@ static float analog2tempBed(int raw) {
return celsius; return celsius;
#elif defined BED_USES_AD595 #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 #else //NO BED_USES_THERMISTOR
return 0; return 0;
#endif //BED_USES_THERMISTOR #endif //BED_USES_THERMISTOR
...@@ -898,11 +841,7 @@ static void updateTemperaturesFromRawValues() { ...@@ -898,11 +841,7 @@ static void updateTemperaturesFromRawValues() {
current_temperature_raw[0] = read_max6675(); current_temperature_raw[0] = read_max6675();
#endif #endif
#ifndef SINGLENOZZLE for (int e = 0; e < HOTENDS; e++)
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
{ {
current_temperature[e] = analog2temp(current_temperature_raw[e], e); current_temperature[e] = analog2temp(current_temperature_raw[e], e);
} }
...@@ -936,10 +875,9 @@ static void updateTemperaturesFromRawValues() { ...@@ -936,10 +875,9 @@ static void updateTemperaturesFromRawValues() {
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
// Convert raw Filament Width to millimeters // Convert raw Filament Width to millimeters
float analog2widthFil() { float analog2widthFil() {
return current_raw_filwidth / (1023.0 * OVERSAMPLENR) * 5.0; return current_raw_filwidth / (1024 * OVERSAMPLENR) * 5.0;
//return current_raw_filwidth; //return current_raw_filwidth;
} }
...@@ -954,12 +892,10 @@ static void updateTemperaturesFromRawValues() { ...@@ -954,12 +892,10 @@ static void updateTemperaturesFromRawValues() {
#endif #endif
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
// Convert raw Power Consumption to watt // Convert raw Power Consumption to watt
float analog2power() { float analog2power() {
return (((((5.0 * current_raw_powconsumption) / (1023.0 * OVERSAMPLENR)) - POWER_ZERO) * (POWER_VOLTAGE * 100.0)) / (POWER_SENSITIVITY * POWER_EFFICIENCY)); return (((((5.0 * current_raw_powconsumption) / (1024.0 * OVERSAMPLENR)) - POWER_ZERO) * (POWER_VOLTAGE * 100.0)) / (POWER_SENSITIVITY * POWER_EFFICIENCY));
} }
#endif #endif
void tp_init() void tp_init()
...@@ -970,12 +906,8 @@ void tp_init() ...@@ -970,12 +906,8 @@ void tp_init()
MCUCR=BIT(JTD); MCUCR=BIT(JTD);
#endif #endif
// Finish init of mult extruder arrays // Finish init of mult hotends arrays
#ifndef SINGLENOZZLE for (int e = 0; e < HOTENDS; e++)
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
{ {
// populate with the first value // populate with the first value
maxttemp[e] = maxttemp[0]; maxttemp[e] = maxttemp[0];
...@@ -1095,32 +1027,30 @@ void tp_init() ...@@ -1095,32 +1027,30 @@ void tp_init()
TEMP_MAX_ROUTINE(0); TEMP_MAX_ROUTINE(0);
#endif #endif
#ifndef SINGLENOZZLE #if HOTENDS > 1
#if EXTRUDERS > 1
#ifdef HEATER_1_MINTEMP #ifdef HEATER_1_MINTEMP
TEMP_MIN_ROUTINE(1); TEMP_MIN_ROUTINE(1);
#endif #endif
#ifdef HEATER_1_MAXTEMP #ifdef HEATER_1_MAXTEMP
TEMP_MAX_ROUTINE(1); TEMP_MAX_ROUTINE(1);
#endif #endif
#if EXTRUDERS > 2 #if HOTENDS > 2
#ifdef HEATER_2_MINTEMP #ifdef HEATER_2_MINTEMP
TEMP_MIN_ROUTINE(2); TEMP_MIN_ROUTINE(2);
#endif #endif
#ifdef HEATER_2_MAXTEMP #ifdef HEATER_2_MAXTEMP
TEMP_MAX_ROUTINE(2); TEMP_MAX_ROUTINE(2);
#endif #endif
#if EXTRUDERS > 3 #if HOTENDS > 3
#ifdef HEATER_3_MINTEMP #ifdef HEATER_3_MINTEMP
TEMP_MIN_ROUTINE(3); TEMP_MIN_ROUTINE(3);
#endif #endif
#ifdef HEATER_3_MAXTEMP #ifdef HEATER_3_MAXTEMP
TEMP_MAX_ROUTINE(3); TEMP_MAX_ROUTINE(3);
#endif #endif
#endif // EXTRUDERS > 3 #endif // HOTENDS > 3
#endif // EXTRUDERS > 2 #endif // HOTENDS > 2
#endif // EXTRUDERS > 1 #endif // HOTENDS > 1
#endif //SINGLENOZZLE
#ifdef BED_MINTEMP #ifdef BED_MINTEMP
/* No bed MINTEMP error implemented?!? */ /* /* No bed MINTEMP error implemented?!? */ /*
...@@ -1147,11 +1077,7 @@ void tp_init() ...@@ -1147,11 +1077,7 @@ void tp_init()
void setWatch() { void setWatch() {
#ifdef WATCH_TEMP_PERIOD #ifdef WATCH_TEMP_PERIOD
unsigned long ms = millis(); unsigned long ms = millis();
#ifndef SINGLENOZZLE for (int e = 0; e < HOTENDS; e++)
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
{ {
if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) { if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2)) {
watch_start_temp[e] = degHotend(e); watch_start_temp[e] = degHotend(e);
...@@ -1227,11 +1153,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat ...@@ -1227,11 +1153,7 @@ void thermal_runaway_protection(int *state, unsigned long *timer, float temperat
void disable_heater() { void disable_heater() {
#ifndef SINGLENOZZLE for (int e = 0; e < HOTENDS; e++)
for (int e = 0; e < EXTRUDERS; e++)
#else
int e = 0;
#endif // !SINGLENOZZLE
setTargetHotend(0, e); setTargetHotend(0, e);
setTargetBed(0); setTargetBed(0);
#if HAS_TEMP_0 #if HAS_TEMP_0
...@@ -1240,19 +1162,19 @@ void disable_heater() { ...@@ -1240,19 +1162,19 @@ void disable_heater() {
WRITE_HEATER_0P(LOW); // If HEATERS_PARALLEL should apply, change to WRITE_HEATER_0 WRITE_HEATER_0P(LOW); // If HEATERS_PARALLEL should apply, change to WRITE_HEATER_0
#endif #endif
#if EXTRUDERS > 1 && HAS_TEMP_1 #if HOTENDS > 1 && HAS_TEMP_1
target_temperature[1] = 0; target_temperature[1] = 0;
soft_pwm[1] = 0; soft_pwm[1] = 0;
WRITE_HEATER_1(LOW); WRITE_HEATER_1(LOW);
#endif #endif
#if EXTRUDERS > 2 && HAS_TEMP_2 #if HOTENDS > 2 && HAS_TEMP_2
target_temperature[2] = 0; target_temperature[2] = 0;
soft_pwm[2] = 0; soft_pwm[2] = 0;
WRITE_HEATER_2(LOW); WRITE_HEATER_2(LOW);
#endif #endif
#if EXTRUDERS > 3 && HAS_TEMP_3 #if HOTENDS > 3 && HAS_TEMP_3
target_temperature[3] = 0; target_temperature[3] = 0;
soft_pwm[3] = 0; soft_pwm[3] = 0;
WRITE_HEATER_3(LOW); WRITE_HEATER_3(LOW);
...@@ -1345,10 +1267,7 @@ enum TempState { ...@@ -1345,10 +1267,7 @@ enum TempState {
ISR(TIMER0_COMPB_vect) { ISR(TIMER0_COMPB_vect) {
//these variables are only accessible from the ISR, but static, so they don't lose their value //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 char temp_count = 0;
static unsigned long raw_temp_0_value = 0; static unsigned long raw_temp_value[HOTENDS] = { 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_bed_value = 0; static unsigned long raw_temp_bed_value = 0;
static TempState temp_state = StartupDelay; static TempState temp_state = StartupDelay;
static unsigned char pwm_count = BIT(SOFT_PWM_SCALE); static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
...@@ -1366,17 +1285,16 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1366,17 +1285,16 @@ ISR(TIMER0_COMPB_vect) {
// Statics per heater // Statics per heater
ISR_STATICS(0); ISR_STATICS(0);
#ifndef SINGLENOZZLE #if (HOTENDS > 1) || defined(HEATERS_PARALLEL)
#if (EXTRUDERS > 1) || defined(HEATERS_PARALLEL)
ISR_STATICS(1); ISR_STATICS(1);
#if EXTRUDERS > 2 #if HOTENDS > 2
ISR_STATICS(2); ISR_STATICS(2);
#if EXTRUDERS > 3 #if HOTENDS > 3
ISR_STATICS(3); ISR_STATICS(3);
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED #if HAS_HEATER_BED
ISR_STATICS(BED); ISR_STATICS(BED);
#endif #endif
...@@ -1399,20 +1317,20 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1399,20 +1317,20 @@ ISR(TIMER0_COMPB_vect) {
WRITE_HEATER_0(1); WRITE_HEATER_0(1);
} }
else WRITE_HEATER_0P(0); // If HEATERS_PARALLEL should apply, change to WRITE_HEATER_0 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]; soft_pwm_1 = soft_pwm[1];
WRITE_HEATER_1(soft_pwm_1 > 0 ? 1 : 0); WRITE_HEATER_1(soft_pwm_1 > 0 ? 1 : 0);
#if EXTRUDERS > 2 #if HOTENDS > 2
soft_pwm_2 = soft_pwm[2]; soft_pwm_2 = soft_pwm[2];
WRITE_HEATER_2(soft_pwm_2 > 0 ? 1 : 0); WRITE_HEATER_2(soft_pwm_2 > 0 ? 1 : 0);
#if EXTRUDERS > 3 #if HOTENDS > 3
soft_pwm_3 = soft_pwm[3]; soft_pwm_3 = soft_pwm[3];
WRITE_HEATER_3(soft_pwm_3 > 0 ? 1 : 0); WRITE_HEATER_3(soft_pwm_3 > 0 ? 1 : 0);
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED #if HAS_HEATER_BED
soft_pwm_BED = soft_pwm_bed; soft_pwm_BED = soft_pwm_bed;
WRITE_HEATER_BED(soft_pwm_BED > 0 ? 1 : 0); WRITE_HEATER_BED(soft_pwm_BED > 0 ? 1 : 0);
...@@ -1424,17 +1342,17 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1424,17 +1342,17 @@ ISR(TIMER0_COMPB_vect) {
} }
if (soft_pwm_0 < pwm_count) { WRITE_HEATER_0(0); } 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 (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 (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); if (soft_pwm_3 < pwm_count) WRITE_HEATER_3(0);
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED #if HAS_HEATER_BED
if (soft_pwm_BED < pwm_count) WRITE_HEATER_BED(0); if (soft_pwm_BED < pwm_count) WRITE_HEATER_BED(0);
#endif #endif
...@@ -1486,36 +1404,34 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1486,36 +1404,34 @@ ISR(TIMER0_COMPB_vect) {
if (slow_pwm_count == 0) { if (slow_pwm_count == 0) {
SLOW_PWM_ROUTINE(0); // EXTRUDER 0 SLOW_PWM_ROUTINE(0); // HOTEND 0
#ifndef SINGLENOZZLE #if HOTENDS > 1
#if EXTRUDERS > 1 SLOW_PWM_ROUTINE(1); // HOTEND 1
SLOW_PWM_ROUTINE(1); // EXTRUDER 1 #if HOTENDS > 2
#if EXTRUDERS > 2 SLOW_PWM_ROUTINE(2); // HOTEND 2
SLOW_PWM_ROUTINE(2); // EXTRUDER 2 #if HOTENDS > 3
#if EXTRUDERS > 3 SLOW_PWM_ROUTINE(3); // HOTEND 3
SLOW_PWM_ROUTINE(3); // EXTRUDER 3
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED #if HAS_HEATER_BED
_SLOW_PWM_ROUTINE(BED, soft_pwm_bed); // BED _SLOW_PWM_ROUTINE(BED, soft_pwm_bed); // BED
#endif #endif
} // slow_pwm_count == 0 } // slow_pwm_count == 0
PWM_OFF_ROUTINE(0); // EXTRUDER 0 PWM_OFF_ROUTINE(0); // HOTEND 0
#ifndef SINGLENOZZLE #if HOTENDS > 1
#if EXTRUDERS > 1 PWM_OFF_ROUTINE(1); // HOTEND 1
PWM_OFF_ROUTINE(1); // EXTRUDER 1 #if HOTENDS > 2
#if EXTRUDERS > 2 PWM_OFF_ROUTINE(2); // HOTEND 2
PWM_OFF_ROUTINE(2); // EXTRUDER 2 #if HOTENDS > 3
#if EXTRUDERS > 3 PWM_OFF_ROUTINE(3); // HOTEND 3
PWM_OFF_ROUTINE(3); // EXTRUDER 3
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED #if HAS_HEATER_BED
PWM_OFF_ROUTINE(BED); // BED PWM_OFF_ROUTINE(BED); // BED
#endif #endif
...@@ -1536,19 +1452,18 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1536,19 +1452,18 @@ ISR(TIMER0_COMPB_vect) {
slow_pwm_count++; slow_pwm_count++;
slow_pwm_count &= 0x7f; slow_pwm_count &= 0x7f;
// EXTRUDER 0 // HOTEND 0
if (state_timer_heater_0 > 0) state_timer_heater_0--; if (state_timer_heater_0 > 0) state_timer_heater_0--;
#ifndef SINGLENOZZLE #if HOTENDS > 1 // HOTEND 1
#if EXTRUDERS > 1 // EXTRUDER 1
if (state_timer_heater_1 > 0) state_timer_heater_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 (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--; if (state_timer_heater_3 > 0) state_timer_heater_3--;
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#if HAS_HEATER_BED #if HAS_HEATER_BED
if (state_timer_heater_BED > 0) state_timer_heater_BED--; if (state_timer_heater_BED > 0) state_timer_heater_BED--;
#endif #endif
...@@ -1573,7 +1488,7 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1573,7 +1488,7 @@ ISR(TIMER0_COMPB_vect) {
break; break;
case MeasureTemp_0: case MeasureTemp_0:
#if HAS_TEMP_0 #if HAS_TEMP_0
raw_temp_0_value += ADC; raw_temp_value[0] += ADC;
#endif #endif
temp_state = PrepareTemp_BED; temp_state = PrepareTemp_BED;
break; break;
...@@ -1599,7 +1514,7 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1599,7 +1514,7 @@ ISR(TIMER0_COMPB_vect) {
break; break;
case MeasureTemp_1: case MeasureTemp_1:
#if HAS_TEMP_1 #if HAS_TEMP_1
raw_temp_1_value += ADC; raw_temp_value[1] += ADC;
#endif #endif
temp_state = PrepareTemp_2; temp_state = PrepareTemp_2;
break; break;
...@@ -1612,7 +1527,7 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1612,7 +1527,7 @@ ISR(TIMER0_COMPB_vect) {
break; break;
case MeasureTemp_2: case MeasureTemp_2:
#if HAS_TEMP_2 #if HAS_TEMP_2
raw_temp_2_value += ADC; raw_temp_value[2] += ADC;
#endif #endif
temp_state = PrepareTemp_3; temp_state = PrepareTemp_3;
break; break;
...@@ -1625,7 +1540,7 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1625,7 +1540,7 @@ ISR(TIMER0_COMPB_vect) {
break; break;
case MeasureTemp_3: case MeasureTemp_3:
#if HAS_TEMP_3 #if HAS_TEMP_3
raw_temp_3_value += ADC; raw_temp_value[3] += ADC;
#endif #endif
temp_state = Prepare_FILWIDTH; temp_state = Prepare_FILWIDTH;
break; break;
...@@ -1657,7 +1572,7 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1657,7 +1572,7 @@ ISR(TIMER0_COMPB_vect) {
#if HAS_POWER_CONSUMPTION_SENSOR #if HAS_POWER_CONSUMPTION_SENSOR
// raw_powconsumption_value += ADC; //remove to use an IIR filter approach // raw_powconsumption_value += ADC; //remove to use an IIR filter approach
raw_powconsumption_value -= (raw_powconsumption_value>>7); //multiply raw_powconsumption_value by 127/128 raw_powconsumption_value -= (raw_powconsumption_value>>7); //multiply raw_powconsumption_value by 127/128
raw_powconsumption_value += ((unsigned long)((ADC < (POWER_ZERO*1023)/5.0) ? (1023 - ADC) : (ADC))<<7); //add new ADC reading raw_powconsumption_value += ((unsigned long)((ADC < (POWER_ZERO*1024)/5.0) ? (1024 - ADC) : (ADC))<<7); //add new ADC reading
#endif #endif
temp_state = PrepareTemp_0; temp_state = PrepareTemp_0;
temp_count++; temp_count++;
...@@ -1675,21 +1590,20 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1675,21 +1590,20 @@ ISR(TIMER0_COMPB_vect) {
if (temp_count >= OVERSAMPLENR) { // 12 * 16 * 1/(16000000/64/256) = 164ms. 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. 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 #ifndef HEATER_0_USES_MAX6675
current_temperature_raw[0] = raw_temp_0_value; current_temperature_raw[0] = raw_temp_value[0];
#endif #endif
#ifndef SINGLENOZZLE #if HOTENDS > 1
#if EXTRUDERS > 1 current_temperature_raw[1] = raw_temp_value[1];
current_temperature_raw[1] = raw_temp_1_value; #if HOTENDS > 2
#if EXTRUDERS > 2 current_temperature_raw[2] = raw_temp_value[2];
current_temperature_raw[2] = raw_temp_2_value; #if HOTENDS > 3
#if EXTRUDERS > 3 current_temperature_raw[3] = raw_temp_value[3];
current_temperature_raw[3] = raw_temp_3_value;
#endif #endif
#endif #endif
#endif #endif
#endif //SINGLENOZZLE
#ifdef TEMP_SENSOR_1_AS_REDUNDANT #ifdef TEMP_SENSOR_1_AS_REDUNDANT
redundant_temperature_raw = raw_temp_1_value; redundant_temperature_raw = raw_temp_value[1];
#endif #endif
current_temperature_bed_raw = raw_temp_bed_value; current_temperature_bed_raw = raw_temp_bed_value;
} //!temp_meas_ready } //!temp_meas_ready
...@@ -1698,39 +1612,65 @@ ISR(TIMER0_COMPB_vect) { ...@@ -1698,39 +1612,65 @@ ISR(TIMER0_COMPB_vect) {
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
current_raw_filwidth = raw_filwidth_value >> 10; // Divide to get to 0-16384 range since we used 1/128 IIR filter approach current_raw_filwidth = raw_filwidth_value >> 10; // Divide to get to 0-16384 range since we used 1/128 IIR filter approach
#endif #endif
// Power Sensor - can be read any time since IIR filtering is used
#if HAS_POWER_CONSUMPTION_SENSOR
current_raw_powconsumption = raw_powconsumption_value >> 10; // Divide to get to 0-16384 range since we used 1/128 IIR filter approach
#endif
temp_meas_ready = true; temp_meas_ready = true;
temp_count = 0; temp_count = 0;
raw_temp_0_value = 0; for (int i = 0; i < HOTENDS; i++) raw_temp_value[i] = 0;
raw_temp_1_value = 0;
raw_temp_2_value = 0;
raw_temp_3_value = 0;
raw_temp_bed_value = 0; raw_temp_bed_value = 0;
#if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP #if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
#define MAXTEST <= #define GE0 <=
#define MINTEST >= #define LE0 >=
#else #else
#define MAXTEST >= #define GE0 >=
#define MINTEST <= #define LE0 <=
#endif #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);
#ifndef SINGLENOZZLE #if HOTENDS > 1
for (int i = 0; i < EXTRUDERS; i++) #if HEATER_1_RAW_LO_TEMP > HEATER_1_RAW_HI_TEMP
#define GE1 <=
#define LE1 >=
#else #else
int i = 0; #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 #endif
{ if (current_temperature_raw[3] GE3 maxttemp_raw[3]) max_temp_error(3);
if (current_temperature_raw[i] MAXTEST maxttemp_raw[i]) max_temp_error(i); if (current_temperature_raw[3] LE3 minttemp_raw[3]) min_temp_error(3);
else if (current_temperature_raw[i] MINTEST minttemp_raw[i]) min_temp_error(i); #endif // HOTENDS > 3
} #endif // HOTENDS > 2
/* No bed MINTEMP error? */ #endif // HOTENDS > 1
#if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0)
if (current_temperature_bed_raw MAXTEST bed_maxttemp_raw) { #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; target_temperature_bed = 0;
bed_max_temp_error(); bed_max_temp_error();
} }
......
...@@ -31,35 +31,26 @@ void tp_init(); //initialize the heating ...@@ -31,35 +31,26 @@ void tp_init(); //initialize the heating
void manage_heater(); //it is critical that this is called periodically. void manage_heater(); //it is critical that this is called periodically.
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0)
// For converting raw Filament Width to milimeters // For converting raw Filament Width to milimeters
float analog2widthFil(); float analog2widthFil();
// For converting raw Filament Width to an extrusion ratio // For converting raw Filament Width to an extrusion ratio
int widthFil_to_size_ratio(); int widthFil_to_size_ratio();
#endif #endif
#if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) #if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0)
// For converting raw Power Consumption to watt // For converting raw Power Consumption to watt
float analog2power(); float analog2power();
#endif #endif
// low level conversion routines // low level conversion routines
// do not use these routines and variables outside of temperature.cpp // do not use these routines and variables outside of temperature.cpp
#ifndef SINGLENOZZLE extern int target_temperature[HOTENDS];
extern int target_temperature[EXTRUDERS]; extern float current_temperature[HOTENDS];
extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES
#ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[HOTENDS];
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; extern int current_temperature_bed_raw;
#endif #endif
#endif //SINGLENOZZLE
extern int target_temperature_bed; extern int target_temperature_bed;
extern float current_temperature_bed; extern float current_temperature_bed;
...@@ -72,11 +63,7 @@ extern float current_temperature_bed; ...@@ -72,11 +63,7 @@ extern float current_temperature_bed;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
#ifndef SINGLENOZZLE extern float Kp[HOTENDS],Ki[HOTENDS],Kd[HOTENDS];
extern float Kp[EXTRUDERS],Ki[EXTRUDERS],Kd[EXTRUDERS];
#else
extern float Kp[1],Ki[1],Kd[1];
#endif
float scalePID_i(float i); float scalePID_i(float i);
float scalePID_d(float d); float scalePID_d(float d);
float unscalePID_i(float i); float unscalePID_i(float i);
...@@ -94,64 +81,33 @@ extern float current_temperature_bed; ...@@ -94,64 +81,33 @@ extern float current_temperature_bed;
//high level conversion routines, for use outside of temperature.cpp //high level conversion routines, for use outside of temperature.cpp
//inline so that there is no performance decrease. //inline so that there is no performance decrease.
//deg=degreeCelsius //deg=degreeCelsius
#if HOTENDS <= 1
FORCE_INLINE float degHotend(uint8_t extruder) { #define HOTEND_ARG 0
#ifndef SINGLENOZZLE
return current_temperature[extruder];
#else #else
return current_temperature[0]; #define HOTEND_ARG hotend
#endif #endif
}
#ifdef SHOW_TEMP_ADC_VALUES FORCE_INLINE float degHotend(uint8_t hotend) { return current_temperature[HOTEND_ARG]; }
FORCE_INLINE float rawHotendTemp(uint8_t extruder) { FORCE_INLINE float degBed() { return current_temperature_bed; }
#ifndef SINGLENOZZLE
return current_temperature_raw[extruder];
#else
return current_temperature_raw[0];
#endif
}
#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; } FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
#endif //SHOW_TEMP_ADC_VALUES #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 float degTargetBed() { return target_temperature_bed; }
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t hotend) { target_temperature[HOTEND_ARG] = celsius; }
#ifndef SINGLENOZZLE
target_temperature[extruder] = celsius;
#else
target_temperature[0] = celsius;
#endif
}
FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; } FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }
FORCE_INLINE bool isHeatingHotend(uint8_t extruder) { FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; }
#ifndef SINGLENOZZLE
return target_temperature[extruder] > current_temperature[extruder];
#else
return target_temperature[0] > current_temperature[0];
#endif
}
FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; } FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { FORCE_INLINE bool isCoolingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] < current_temperature[HOTEND_ARG]; }
#ifndef SINGLENOZZLE
return target_temperature[extruder] < current_temperature[extruder];
#else
return target_temperature[0] < current_temperature[0];
#endif
}
FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; } FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
...@@ -160,7 +116,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -160,7 +116,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0) #define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
#define isHeatingHotend0() isHeatingHotend(0) #define isHeatingHotend0() isHeatingHotend(0)
#define isCoolingHotend0() isCoolingHotend(0) #define isCoolingHotend0() isCoolingHotend(0)
#if EXTRUDERS > 1 && !defined(SINGLENOZZLE) #if HOTENDS > 1
#define degHotend1() degHotend(1) #define degHotend1() degHotend(1)
#define degTargetHotend1() degTargetHotend(1) #define degTargetHotend1() degTargetHotend(1)
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1) #define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
...@@ -169,7 +125,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -169,7 +125,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else #else
#define setTargetHotend1(_celsius) do{}while(0) #define setTargetHotend1(_celsius) do{}while(0)
#endif #endif
#if EXTRUDERS > 2 && !defined(SINGLENOZZLE) #if HOTENDS > 2
#define degHotend2() degHotend(2) #define degHotend2() degHotend(2)
#define degTargetHotend2() degTargetHotend(2) #define degTargetHotend2() degTargetHotend(2)
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2) #define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
...@@ -178,7 +134,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -178,7 +134,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else #else
#define setTargetHotend2(_celsius) do{}while(0) #define setTargetHotend2(_celsius) do{}while(0)
#endif #endif
#if EXTRUDERS > 3 && !defined(SINGLENOZZLE) #if HOTENDS > 3
#define degHotend3() degHotend(3) #define degHotend3() degHotend(3)
#define degTargetHotend3() degTargetHotend(3) #define degTargetHotend3() degTargetHotend(3)
#define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3) #define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3)
...@@ -187,8 +143,8 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -187,8 +143,8 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else #else
#define setTargetHotend3(_celsius) do{}while(0) #define setTargetHotend3(_celsius) do{}while(0)
#endif #endif
#if EXTRUDERS > 4 #if HOTENDS > 4
#error Invalid number of extruders #error Invalid number of hotends
#endif #endif
int getHeaterPower(int heater); int getHeaterPower(int heater);
...@@ -217,7 +173,7 @@ FORCE_INLINE void autotempShutdown() { ...@@ -217,7 +173,7 @@ FORCE_INLINE void autotempShutdown() {
#endif #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 setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans(); void checkExtruderAutoFans();
......
...@@ -215,8 +215,8 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l ...@@ -215,8 +215,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) #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
#endif //!ENCODER_RATE_MULTIPLIER #endif //!ENCODER_RATE_MULTIPLIER
#define END_MENU() \ #define END_MENU() \
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \ if (encoderLine >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
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 >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
} } while(0) } } while(0)
/** Used variables to keep track of the menu */ /** Used variables to keep track of the menu */
...@@ -310,15 +310,11 @@ static void lcd_status_screen() ...@@ -310,15 +310,11 @@ static void lcd_status_screen()
lcd_implementation_status_screen(); lcd_implementation_status_screen();
lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */ lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
} }
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) && (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && (POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
if (millis() > message_millis + 15000) if (millis() > message_millis + 15000) message_millis = millis();
#else #else
if (millis() > message_millis + 10000) if (millis() > message_millis + 10000) message_millis = millis();
#endif
{
message_millis = millis();
}
#endif #endif
#ifdef ULTIPANEL #ifdef ULTIPANEL
...@@ -454,7 +450,7 @@ static void lcd_main_menu() { ...@@ -454,7 +450,7 @@ static void lcd_main_menu() {
void lcd_set_home_offsets() { void lcd_set_home_offsets() {
for(int8_t i=0; i < NUM_AXIS; i++) { for(int8_t i=0; i < NUM_AXIS; i++) {
if (i != E_AXIS) { if (i != E_AXIS) {
add_homing[i] -= current_position[i]; home_offset[i] -= current_position[i];
current_position[i] = 0.0; current_position[i] = 0.0;
} }
} }
...@@ -693,89 +689,74 @@ void config_lcd_level_bed() ...@@ -693,89 +689,74 @@ void config_lcd_level_bed()
void lcd_level_bed() void lcd_level_bed()
{ {
if(ChangeScreen){ if(ChangeScreen) {
switch(pageShowInfo){ lcd.clear();
switch(pageShowInfo) {
case 0: case 0:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_INTRO)); lcd_printPGM(PSTR(MSG_LP_INTRO));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
} }
break; break;
case 1: case 1:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_1)); lcd_printPGM(PSTR(MSG_LP_1));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
} }
break; break;
case 2: case 2:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_2)); lcd_printPGM(PSTR(MSG_LP_2));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
} }
break; break;
case 3: case 3:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_3)); lcd_printPGM(PSTR(MSG_LP_3));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
} }
break; break;
case 4: case 4:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_4)); lcd_printPGM(PSTR(MSG_LP_4));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
} }
break; break;
case 5: case 5:
{ {
u8g.setPrintPos(0, 1); lcd.setCursor(0, 1);
lcd_printPGM(PSTR(MSG_LP_5)); lcd_printPGM(PSTR(MSG_LP_5));
currentMenu = lcd_level_bed; currentMenu = lcd_level_bed;
ChangeScreen=false; ChangeScreen=false;
} }
break; break;
case 6: case 6:
{ {
u8g.setPrintPos(2, 2); lcd.setCursor(2, 2);
lcd_printPGM(PSTR(MSG_LP_6)); lcd_printPGM(PSTR(MSG_LP_6));
ChangeScreen=false; ChangeScreen=false;
delay(1200); delay(1200);
encoderPosition = 0; encoderPosition = 0;
<<<<<<< HEAD
lcd.clear(); lcd.clear();
=======
>>>>>>> parent of 3223901... Fix Power Consumation
currentMenu = lcd_status_screen; currentMenu = lcd_status_screen;
lcd_status_screen(); lcd_status_screen();
pageShowInfo=0; pageShowInfo=0;
} }
break; break;
} }
} }
} }
static void lcd_prepare_menu() { static void lcd_prepare_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
...@@ -981,21 +962,21 @@ static void lcd_control_temperature_menu() { ...@@ -981,21 +962,21 @@ static void lcd_control_temperature_menu() {
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15); MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15);
#endif #endif
#if EXTRUDERS > 1 #if HOTENDS > 1
#if TEMP_SENSOR_1 != 0 #if TEMP_SENSOR_1 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15); MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15);
#endif #endif
#if EXTRUDERS > 2 #if HOTENDS > 2
#if TEMP_SENSOR_2 != 0 #if TEMP_SENSOR_2 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15); MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15);
#endif #endif
#if EXTRUDERS > 3 #if HOTENDS > 3
#if TEMP_SENSOR_3 != 0 #if TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15); MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 4", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15);
#endif #endif
#endif //EXTRUDERS > 3 #endif //HOTENDS > 3
#endif //EXTRUDERS > 2 #endif //HOTENDS > 2
#endif //EXTRUDERS > 1 #endif //HOTENDS > 1
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15); MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
#endif #endif
...@@ -1014,8 +995,7 @@ static void lcd_control_temperature_menu() { ...@@ -1014,8 +995,7 @@ static void lcd_control_temperature_menu() {
// i is typically a small value so allows values below 1 // 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_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); MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
#ifndef SINGLENOZZLE #if HOTENDS > 1
#if EXTRUDERS > 1
// set up temp variables - undo the default scaling // set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[1]); raw_Ki = unscalePID_i(Ki[1]);
raw_Kd = unscalePID_d(Kd[1]); raw_Kd = unscalePID_d(Kd[1]);
...@@ -1023,8 +1003,8 @@ static void lcd_control_temperature_menu() { ...@@ -1023,8 +1003,8 @@ static void lcd_control_temperature_menu() {
// i is typically a small value so allows values below 1 // 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_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); MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E2", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 1 #endif //HOTENDS > 1
#if EXTRUDERS > 2 #if HOTENDS > 2
// set up temp variables - undo the default scaling // set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[2]); raw_Ki = unscalePID_i(Ki[2]);
raw_Kd = unscalePID_d(Kd[2]); raw_Kd = unscalePID_d(Kd[2]);
...@@ -1032,8 +1012,8 @@ static void lcd_control_temperature_menu() { ...@@ -1032,8 +1012,8 @@ static void lcd_control_temperature_menu() {
// i is typically a small value so allows values below 1 // 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_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); MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E3", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 2 #endif //HOTENDS > 2
#if EXTRUDERS > 3 #if HOTENDS > 3
// set up temp variables - undo the default scaling // set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[3]); raw_Ki = unscalePID_i(Ki[3]);
raw_Kd = unscalePID_d(Kd[3]); raw_Kd = unscalePID_d(Kd[3]);
...@@ -1041,8 +1021,7 @@ static void lcd_control_temperature_menu() { ...@@ -1041,8 +1021,7 @@ static void lcd_control_temperature_menu() {
// i is typically a small value so allows values below 1 // 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_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); MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D " E4", &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 2 #endif //HOTENDS > 2
#endif //SINGLENOZZLE
#endif //PIDTEMP #endif //PIDTEMP
MENU_ITEM(submenu, MSG_PREHEAT_PLA_SETTINGS, lcd_control_temperature_preheat_pla_settings_menu); 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); MENU_ITEM(submenu, MSG_PREHEAT_ABS_SETTINGS, lcd_control_temperature_preheat_abs_settings_menu);
......
...@@ -380,35 +380,32 @@ static void lcd_set_custom_characters( ...@@ -380,35 +380,32 @@ static void lcd_set_custom_characters(
#endif #endif
} }
static void lcd_implementation_init( static void lcd_implementation_init (
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
bool progress_bar_set=true bool progress_bar_set = true
#endif #endif
) { ){
#if defined(LCD_I2C_TYPE_PCF8575) #if defined(LCD_I2C_TYPE_PCF8575)
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#ifdef LCD_I2C_PIN_BL #ifdef LCD_I2C_PIN_BL
lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
lcd.setBacklight(HIGH); lcd.setBacklight(HIGH);
#endif #endif
#elif defined(LCD_I2C_TYPE_MCP23017) #elif defined(LCD_I2C_TYPE_MCP23017)
lcd.setMCPType(LTI_TYPE_MCP23017); lcd.setMCPType(LTI_TYPE_MCP23017);
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
lcd.setBacklight(0); //set all the LEDs off to begin with 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.setMCPType(LTI_TYPE_MCP23008);
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#elif defined(LCD_I2C_TYPE_PCA8574)
#elif defined(LCD_I2C_TYPE_PCA8574)
lcd.init(); lcd.init();
lcd.backlight(); lcd.backlight();
#else
#else
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#endif #endif
lcd_set_custom_characters( lcd_set_custom_characters(
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
...@@ -418,19 +415,20 @@ static void lcd_implementation_init( ...@@ -418,19 +415,20 @@ static void lcd_implementation_init(
lcd.clear(); lcd.clear();
} }
static void lcd_implementation_clear()
{ static void lcd_implementation_clear() {
lcd.clear(); lcd.clear();
} }
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ /* 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) static void lcd_printPGM(const char* str) {
{
char c; char c;
while((c = pgm_read_byte(str++)) != '\0') while((c = pgm_read_byte(str++)) != '\0')
{ {
lcd.write(c); lcd.write(c);
} }
} }
/* /*
Possible status screens: Possible status screens:
16x2 |0123456789012345| 16x2 |0123456789012345|
...@@ -459,69 +457,67 @@ Possible status screens: ...@@ -459,69 +457,67 @@ Possible status screens:
|F100% SD100% T--:--| |F100% SD100% T--:--|
|Status line.........| |Status line.........|
*/ */
static void lcd_implementation_status_screen()
{ static void lcd_implementation_status_screen() {
int tHotend=int(degHotend(0) + 0.5); int tHotend=int(degHotend(0) + 0.5);
int tTarget=int(degTargetHotend(0) + 0.5); int tTarget=int(degTargetHotend(0) + 0.5);
#if LCD_WIDTH < 20 #if LCD_WIDTH < 20
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
# if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #if HOTENDS > 1 || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner //If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(8, 0); lcd.setCursor(8, 0);
# if EXTRUDERS > 1 && !defined(SINGLENOZZLE) #if HOTENDS > 1
tHotend = int(degHotend(1) + 0.5); tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5); tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(LCD_STR_THERMOMETER[0]);
# else//Heated bed #else//Heated bed
tHotend=int(degBed() + 0.5); tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5); tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]); lcd.print(LCD_STR_BEDTEMP[0]);
# endif #endif
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
# endif (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #endif //HOTENDS > 1 || TEMP_SENSOR_BED != 0
#else//LCD_WIDTH > 19 #else//LCD_WIDTH > 19
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(LCD_STR_THERMOMETER[0]);
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10) if (tTarget < 10) lcd.print(' ');
lcd.print(' ');
# if (EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #if HOTENDS > 1 || TEMP_SENSOR_BED != 0
//If we have an 2nd extruder or heated bed, show that in the top right corner //If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(10, 0); lcd.setCursor(10, 0);
# if EXTRUDERS > 1 && !defined(SINGLENOZZLE) #if HOTENDS > 1
tHotend = int(degHotend(1) + 0.5); tHotend = int(degHotend(1) + 0.5);
tTarget = int(degTargetHotend(1) + 0.5); tTarget = int(degTargetHotend(1) + 0.5);
lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(LCD_STR_THERMOMETER[0]);
# else//Heated bed #else//Heated bed
tHotend=int(degBed() + 0.5); tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5); tTarget=int(degTargetBed() + 0.5);
lcd.print(LCD_STR_BEDTEMP[0]); lcd.print(LCD_STR_BEDTEMP[0]);
# endif #endif
lcd.print(itostr3(tHotend)); lcd.print(itostr3(tHotend));
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10) if (tTarget < 10) lcd.print(' ');
lcd.print(' '); #endif//HOTENDS > 1 || TEMP_SENSOR_BED != 0
# endif//(EXTRUDERS > 1 && !defined(SINGLENOZZLE)) || TEMP_SENSOR_BED != 0 #endif//LCD_WIDTH > 19
#endif//LCD_WIDTH > 19
#if LCD_HEIGHT > 2
#if LCD_HEIGHT > 2 //Lines 2 for 4 line LCD
//Lines 2 for 4 line LCD #if LCD_WIDTH < 20
# if LCD_WIDTH < 20 #ifdef SDSUPPORT
# ifdef SDSUPPORT
lcd.setCursor(0, 2); lcd.setCursor(0, 2);
lcd_printPGM(PSTR("SD")); lcd_printPGM(PSTR("SD"));
if (IS_SD_PRINTING) if (IS_SD_PRINTING)
...@@ -529,9 +525,9 @@ static void lcd_implementation_status_screen() ...@@ -529,9 +525,9 @@ static void lcd_implementation_status_screen()
else else
lcd_printPGM(PSTR("---")); lcd_printPGM(PSTR("---"));
lcd.print('%'); lcd.print('%');
# endif//SDSUPPORT #endif//SDSUPPORT
# else//LCD_WIDTH > 19 #else //LCD_WIDTH > 19
# if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0 && !defined(SINGLENOZZLE) #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 //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); tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5); tTarget=int(degTargetBed() + 0.5);
...@@ -542,35 +538,34 @@ static void lcd_implementation_status_screen() ...@@ -542,35 +538,34 @@ static void lcd_implementation_status_screen()
lcd.print('/'); lcd.print('/');
lcd.print(itostr3left(tTarget)); lcd.print(itostr3left(tTarget));
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
if (tTarget < 10) if (tTarget < 10) lcd.print(' ');
lcd.print(' '); #else
# else
lcd.setCursor(0,1); lcd.setCursor(0,1);
# ifdef DELTA #ifdef DELTA
lcd.print('X'); lcd.print('X');
lcd.print(ftostr30(current_position[X_AXIS])); lcd.print(ftostr30(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y")); lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr30(current_position[Y_AXIS])); lcd.print(ftostr30(current_position[Y_AXIS]));
# else #else
lcd.print('X'); lcd.print('X');
lcd.print(ftostr3(current_position[X_AXIS])); lcd.print(ftostr3(current_position[X_AXIS]));
lcd_printPGM(PSTR(" Y")); lcd_printPGM(PSTR(" Y"));
lcd.print(ftostr3(current_position[Y_AXIS])); lcd.print(ftostr3(current_position[Y_AXIS]));
# endif // DELTA #endif // DELTA
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 #endif //HOTENDS > 1 || TEMP_SENSOR_BED != 0
# endif//LCD_WIDTH > 19 #endif //LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 8, 1); lcd.setCursor(LCD_WIDTH - 8, 1);
lcd.print('Z'); lcd.print('Z');
lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001)); lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
#endif//LCD_HEIGHT > 2 #endif //LCD_HEIGHT > 2
#if LCD_HEIGHT > 3 #if LCD_HEIGHT > 3
lcd.setCursor(0, 2); lcd.setCursor(0, 2);
lcd.print(LCD_STR_FEEDRATE[0]); lcd.print(LCD_STR_FEEDRATE[0]);
lcd.print(itostr3(feedmultiply)); lcd.print(itostr3(feedmultiply));
lcd.print('%'); lcd.print('%');
# if LCD_WIDTH > 19 #if LCD_WIDTH > 19
# ifdef SDSUPPORT #ifdef SDSUPPORT
lcd.setCursor(7, 2); lcd.setCursor(7, 2);
lcd_printPGM(PSTR("SD")); lcd_printPGM(PSTR("SD"));
if (IS_SD_PRINTING) if (IS_SD_PRINTING)
...@@ -578,8 +573,8 @@ static void lcd_implementation_status_screen() ...@@ -578,8 +573,8 @@ static void lcd_implementation_status_screen()
else else
lcd_printPGM(PSTR("---")); lcd_printPGM(PSTR("---"));
lcd.print('%'); lcd.print('%');
# endif//SDSUPPORT #endif //SDSUPPORT
# endif//LCD_WIDTH > 19 #endif //LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 6, 2); lcd.setCursor(LCD_WIDTH - 6, 2);
lcd.print(LCD_STR_CLOCK[0]); lcd.print(LCD_STR_CLOCK[0]);
if(starttime != 0) if(starttime != 0)
...@@ -588,16 +583,17 @@ static void lcd_implementation_status_screen() ...@@ -588,16 +583,17 @@ static void lcd_implementation_status_screen()
lcd.print(itostr2(time/60)); lcd.print(itostr2(time/60));
lcd.print(':'); lcd.print(':');
lcd.print(itostr2(time%60)); lcd.print(itostr2(time%60));
}else{ }
else
{
lcd_printPGM(PSTR("--:--")); lcd_printPGM(PSTR("--:--"));
} }
#endif #endif
// Status message line at the bottom // Status message line at the bottom
lcd.setCursor(0, LCD_HEIGHT - 1); lcd.setCursor(0, LCD_HEIGHT - 1);
#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
if (card.isFileOpen()) { if (card.isFileOpen()) {
uint16_t mil = millis(), diff = mil - progressBarTick; uint16_t mil = millis(), diff = mil - progressBarTick;
if (diff >= PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) { if (diff >= PROGRESS_BAR_MSG_TIME || !lcd_status_message[0]) {
...@@ -625,8 +621,8 @@ static void lcd_implementation_status_screen() ...@@ -625,8 +621,8 @@ static void lcd_implementation_status_screen()
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
lcd.print(lcd_status_message); lcd.print(lcd_status_message);
} }
#if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) #if defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && (POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY)
else if (millis() < message_millis + 10000) else if (millis() < message_millis + 10000)
#else #else
else else
...@@ -639,14 +635,14 @@ static void lcd_implementation_status_screen() ...@@ -639,14 +635,14 @@ static void lcd_implementation_status_screen()
lcd_printPGM(PSTR("Wh")); lcd_printPGM(PSTR("Wh"));
} }
#endif #endif
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY)
else { else {
lcd_printPGM(PSTR("D:")); lcd_printPGM(PSTR("D:"));
lcd.print(ftostr12ns(filament_width_meas)); lcd.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR("mm F:")); lcd_printPGM(PSTR("mm F:"));
lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
lcd.print('%'); lcd.print('%');
return;
} }
#else #else
lcd.print(lcd_status_message); lcd.print(lcd_status_message);
...@@ -667,6 +663,7 @@ static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const cha ...@@ -667,6 +663,7 @@ static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const cha
lcd.print(post_char); lcd.print(post_char);
lcd.print(' '); lcd.print(' ');
} }
static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) { static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) {
char c; char c;
uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen(data); uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen(data);
...@@ -681,6 +678,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t r ...@@ -681,6 +678,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t r
while (n--) lcd.print(' '); while (n--) lcd.print(' ');
lcd.print(data); 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) { 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; char c;
uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen_P(data); uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen_P(data);
...@@ -695,6 +693,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t ...@@ -695,6 +693,7 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t
while (n--) lcd.print(' '); while (n--) lcd.print(' ');
lcd_printPGM(data); 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_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_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))) #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)))
...@@ -723,6 +722,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) { ...@@ -723,6 +722,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
lcd.setCursor(LCD_WIDTH - (LCD_WIDTH < 20 ? 0 : 1) - lcd_strlen(value), 1); lcd.setCursor(LCD_WIDTH - (LCD_WIDTH < 20 ? 0 : 1) - lcd_strlen(value), 1);
lcd.print(value); 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) { static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat) {
char c; char c;
uint8_t n = LCD_WIDTH - concat; uint8_t n = LCD_WIDTH - concat;
...@@ -743,9 +743,11 @@ static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* ps ...@@ -743,9 +743,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) { 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); 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) { 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); 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_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_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, '>', ' ') #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
...@@ -787,7 +789,7 @@ static void lcd_implementation_update_indicators() ...@@ -787,7 +789,7 @@ static void lcd_implementation_update_indicators()
if (target_temperature_bed > 0) leds |= LED_A; if (target_temperature_bed > 0) leds |= LED_A;
if (target_temperature[0] > 0) leds |= LED_B; if (target_temperature[0] > 0) leds |= LED_B;
if (fanSpeed) leds |= LED_C; if (fanSpeed) leds |= LED_C;
#if EXTRUDERS > 1 && !defined(SINGLENOZZLE) #if HOTENDS > 1
if (target_temperature[1] > 0) leds |= LED_C; if (target_temperature[1] > 0) leds |= LED_C;
#endif #endif
if (leds != ledsprev) { 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