|
|
@ -3,26 +3,26 @@ |
|
|
|
#include "temperature.h" |
|
|
|
#include "ultralcd.h" |
|
|
|
#include "ConfigurationStore.h" |
|
|
|
|
|
|
|
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) |
|
|
|
{ |
|
|
|
do |
|
|
|
{ |
|
|
|
eeprom_write_byte((unsigned char*)pos, *value); |
|
|
|
pos++; |
|
|
|
value++; |
|
|
|
|
|
|
|
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) |
|
|
|
{ |
|
|
|
do |
|
|
|
{ |
|
|
|
eeprom_write_byte((unsigned char*)pos, *value); |
|
|
|
pos++; |
|
|
|
value++; |
|
|
|
}while(--size); |
|
|
|
} |
|
|
|
} |
|
|
|
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value)) |
|
|
|
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) |
|
|
|
{ |
|
|
|
do |
|
|
|
{ |
|
|
|
*value = eeprom_read_byte((unsigned char*)pos); |
|
|
|
pos++; |
|
|
|
value++; |
|
|
|
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) |
|
|
|
{ |
|
|
|
do |
|
|
|
{ |
|
|
|
*value = eeprom_read_byte((unsigned char*)pos); |
|
|
|
pos++; |
|
|
|
value++; |
|
|
|
}while(--size); |
|
|
|
} |
|
|
|
} |
|
|
|
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value)) |
|
|
|
//======================================================================================
|
|
|
|
|
|
|
@ -43,7 +43,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) |
|
|
|
void Config_StoreSettings() |
|
|
|
{ |
|
|
|
char ver[4]= "000"; |
|
|
|
int i=EEPROM_OFFSET; |
|
|
|
int i=EEPROM_OFFSET; |
|
|
|
EEPROM_WRITE_VAR(i,ver); // invalidate data first
|
|
|
|
EEPROM_WRITE_VAR(i,axis_steps_per_unit); |
|
|
|
EEPROM_WRITE_VAR(i,max_feedrate); |
|
|
@ -58,8 +58,8 @@ void Config_StoreSettings() |
|
|
|
EEPROM_WRITE_VAR(i,max_e_jerk); |
|
|
|
EEPROM_WRITE_VAR(i,add_homeing); |
|
|
|
#ifndef ULTIPANEL |
|
|
|
int plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP, plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP, plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED; |
|
|
|
int absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP, absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP, absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED; |
|
|
|
int plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP, plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP, plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED; |
|
|
|
int absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP, absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP, absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED; |
|
|
|
#endif |
|
|
|
EEPROM_WRITE_VAR(i,plaPreheatHotendTemp); |
|
|
|
EEPROM_WRITE_VAR(i,plaPreheatHPBTemp); |
|
|
@ -75,7 +75,7 @@ void Config_StoreSettings() |
|
|
|
EEPROM_WRITE_VAR(i,3000); |
|
|
|
EEPROM_WRITE_VAR(i,0); |
|
|
|
EEPROM_WRITE_VAR(i,0); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
char ver2[4]=EEPROM_VERSION; |
|
|
|
i=EEPROM_OFFSET; |
|
|
|
EEPROM_WRITE_VAR(i,ver2); // validate data
|
|
|
@ -105,7 +105,7 @@ void Config_PrintSettings() |
|
|
|
SERIAL_ECHOPAIR(" Z", max_feedrate[2] ); |
|
|
|
SERIAL_ECHOPAIR(" E", max_feedrate[3]); |
|
|
|
SERIAL_ECHOLN(""); |
|
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):"); |
|
|
|
SERIAL_ECHO_START; |
|
|
@ -120,7 +120,7 @@ void Config_PrintSettings() |
|
|
|
SERIAL_ECHOPAIR(" M204 S",acceleration ); |
|
|
|
SERIAL_ECHOPAIR(" T" ,retract_acceleration); |
|
|
|
SERIAL_ECHOLN(""); |
|
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s), Z=maximum Z jerk (mm/s)"); |
|
|
|
SERIAL_ECHO_START; |
|
|
@ -131,7 +131,7 @@ void Config_PrintSettings() |
|
|
|
SERIAL_ECHOPAIR(" Z" ,max_z_jerk); |
|
|
|
SERIAL_ECHOPAIR(" E" ,max_e_jerk); |
|
|
|
SERIAL_ECHOLN(""); |
|
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOLNPGM("Home offset (mm):"); |
|
|
|
SERIAL_ECHO_START; |
|
|
@ -143,11 +143,25 @@ void Config_PrintSettings() |
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOLNPGM("PID settings:"); |
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOPAIR(" M301 P",Kp); |
|
|
|
SERIAL_ECHOPAIR(" I" ,Ki/PID_dT); |
|
|
|
SERIAL_ECHOPAIR(" D" ,Kd*PID_dT); |
|
|
|
SERIAL_ECHOPAIR(" M301 P",Kp[0]); |
|
|
|
SERIAL_ECHOPAIR(" I" ,Ki[0]/PID_dT); |
|
|
|
SERIAL_ECHOPAIR(" D" ,Kd[0]*PID_dT); |
|
|
|
SERIAL_ECHOLN(""); |
|
|
|
#if EXTRUDERS > 1 |
|
|
|
SERIAL_ECHOPAIR(" M301 P",Kp[1]); |
|
|
|
SERIAL_ECHOPAIR(" I" ,Ki[1]/PID_dT); |
|
|
|
SERIAL_ECHOPAIR(" D" ,Kd[1]*PID_dT); |
|
|
|
SERIAL_ECHOPGM(" T1"); |
|
|
|
SERIAL_ECHOLN(""); |
|
|
|
#endif |
|
|
|
#if EXTRUDERS > 2 |
|
|
|
SERIAL_ECHOPAIR(" M301 P",Kp[2]); |
|
|
|
SERIAL_ECHOPAIR(" I" ,Ki[2]/PID_dT); |
|
|
|
SERIAL_ECHOPAIR(" D" ,Kd[2]*PID_dT); |
|
|
|
SERIAL_ECHOPGM(" T2"); |
|
|
|
SERIAL_ECHOLN(""); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
@ -161,7 +175,7 @@ void Config_RetrieveSettings() |
|
|
|
EEPROM_READ_VAR(i,stored_ver); //read stored version
|
|
|
|
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
|
|
|
|
if (strncmp(ver,stored_ver,3) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// version number match
|
|
|
|
EEPROM_READ_VAR(i,axis_steps_per_unit); |
|
|
|
EEPROM_READ_VAR(i,max_feedrate); |
|
|
@ -176,15 +190,15 @@ void Config_RetrieveSettings() |
|
|
|
EEPROM_READ_VAR(i,max_e_jerk); |
|
|
|
EEPROM_READ_VAR(i,add_homeing); |
|
|
|
#ifndef ULTIPANEL |
|
|
|
int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed; |
|
|
|
int absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed; |
|
|
|
int plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed; |
|
|
|
int absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed; |
|
|
|
#endif |
|
|
|
EEPROM_READ_VAR(i,plaPreheatHotendTemp); |
|
|
|
EEPROM_READ_VAR(i,plaPreheatHPBTemp); |
|
|
|
EEPROM_READ_VAR(i,plaPreheatFanSpeed); |
|
|
|
EEPROM_READ_VAR(i,absPreheatHotendTemp); |
|
|
|
EEPROM_READ_VAR(i,absPreheatHPBTemp); |
|
|
|
EEPROM_READ_VAR(i,absPreheatFanSpeed); |
|
|
|
EEPROM_READ_VAR(i,absPreheatFanSpeed); |
|
|
|
#ifndef PIDTEMP |
|
|
|
float Kp,Ki,Kd; |
|
|
|
#endif |
|
|
@ -195,17 +209,17 @@ void Config_RetrieveSettings() |
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOLNPGM("Stored settings retreived:"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Config_ResetDefault(); |
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOLN("Using Default settings:"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Config_ResetDefault(); |
|
|
|
SERIAL_ECHO_START; |
|
|
|
SERIAL_ECHOLN("Using Default settings:"); |
|
|
|
} |
|
|
|
Config_PrintSettings(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
void Config_ResetDefault() |
|
|
|
#endif |
|
|
|
|
|
|
|
void Config_ResetDefault() |
|
|
|
{ |
|
|
|
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT; |
|
|
|
float tmp2[]=DEFAULT_MAX_FEEDRATE; |
|
|
@ -234,9 +248,19 @@ void Config_ResetDefault() |
|
|
|
absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED; |
|
|
|
#endif |
|
|
|
#ifdef PIDTEMP |
|
|
|
Kp = DEFAULT_Kp; |
|
|
|
Ki = (DEFAULT_Ki*PID_dT); |
|
|
|
Kd = (DEFAULT_Kd/PID_dT); |
|
|
|
Kp[0] = DEFAULT_Kp; |
|
|
|
Ki[0] = (DEFAULT_Ki*PID_dT); |
|
|
|
Kd[0] = (DEFAULT_Kd/PID_dT); |
|
|
|
#if EXTRUDERS > 1 |
|
|
|
Kp[1] = DEFAULT_Kp_E1; |
|
|
|
Ki[1] = (DEFAULT_Ki_E1*PID_dT); |
|
|
|
Kd[1] = (DEFAULT_Kd_E1/PID_dT); |
|
|
|
#endif |
|
|
|
#if EXTRUDERS > 2 |
|
|
|
Kp[2] = DEFAULT_Kp_E2; |
|
|
|
Ki[2] = (DEFAULT_Ki_E2*PID_dT); |
|
|
|
Kd[2] = (DEFAULT_Kd_E2/PID_dT); |
|
|
|
#endif |
|
|
|
#ifdef PID_ADD_EXTRUSION_RATE |
|
|
|
Kc = DEFAULT_Kc; |
|
|
|
#endif//PID_ADD_EXTRUSION_RATE
|
|
|
|