Add PIDTEMPBED to EEPROM
This commit is contained in:
parent
e8700bd1e2
commit
424d5495e4
@ -3,7 +3,21 @@
|
|||||||
*
|
*
|
||||||
* Configuration and EEPROM storage
|
* Configuration and EEPROM storage
|
||||||
*
|
*
|
||||||
* V16 EEPROM Layout:
|
* IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
|
||||||
|
* in the functions below, also increment the version number. This makes sure that
|
||||||
|
* the default values are used whenever there is a change to the data, to prevent
|
||||||
|
* wrong data being written to the variables.
|
||||||
|
*
|
||||||
|
* ALSO: Variables in the Store and Retrieve sections must be in the same order.
|
||||||
|
* If a feature is disabled, some data must still be written that, when read,
|
||||||
|
* either sets a Sane Default, or results in No Change to the existing value.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define EEPROM_VERSION "V19"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* V19 EEPROM Layout:
|
||||||
*
|
*
|
||||||
* ver
|
* ver
|
||||||
* axis_steps_per_unit (x4)
|
* axis_steps_per_unit (x4)
|
||||||
@ -47,6 +61,9 @@
|
|||||||
* Kp[2], Ki[2], Kd[2], Kc[2]
|
* Kp[2], Ki[2], Kd[2], Kc[2]
|
||||||
* Kp[3], Ki[3], Kd[3], Kc[3]
|
* Kp[3], Ki[3], Kd[3], Kc[3]
|
||||||
*
|
*
|
||||||
|
* PIDTEMPBED:
|
||||||
|
* bedKp, bedKi, bedKd
|
||||||
|
*
|
||||||
* DOGLCD:
|
* DOGLCD:
|
||||||
* lcd_contrast
|
* lcd_contrast
|
||||||
*
|
*
|
||||||
@ -111,15 +128,6 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
|
|||||||
|
|
||||||
#define EEPROM_OFFSET 100
|
#define EEPROM_OFFSET 100
|
||||||
|
|
||||||
|
|
||||||
// IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
|
|
||||||
// in the functions below, also increment the version number. This makes sure that
|
|
||||||
// the default values are used whenever there is a change to the data, to prevent
|
|
||||||
// wrong data being written to the variables.
|
|
||||||
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
|
|
||||||
|
|
||||||
#define EEPROM_VERSION "V18"
|
|
||||||
|
|
||||||
#ifdef EEPROM_SETTINGS
|
#ifdef EEPROM_SETTINGS
|
||||||
|
|
||||||
void Config_StoreSettings() {
|
void Config_StoreSettings() {
|
||||||
@ -194,7 +202,6 @@ void Config_StoreSettings() {
|
|||||||
EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
|
EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
|
||||||
EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
|
EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
|
||||||
|
|
||||||
|
|
||||||
for (int e = 0; e < 4; e++) {
|
for (int e = 0; e < 4; e++) {
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
@ -209,12 +216,10 @@ void Config_StoreSettings() {
|
|||||||
EEPROM_WRITE_VAR(i, dummy);
|
EEPROM_WRITE_VAR(i, dummy);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
#else // !PIDTEMP
|
|
||||||
{
|
|
||||||
#endif // !PIDTEMP
|
#endif // !PIDTEMP
|
||||||
|
{
|
||||||
dummy = DUMMY_PID_VALUE;
|
dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
|
||||||
EEPROM_WRITE_VAR(i, dummy);
|
EEPROM_WRITE_VAR(i, dummy);
|
||||||
dummy = 0.0f;
|
dummy = 0.0f;
|
||||||
for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
|
for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
|
||||||
@ -222,6 +227,14 @@ void Config_StoreSettings() {
|
|||||||
|
|
||||||
} // Extruders Loop
|
} // Extruders Loop
|
||||||
|
|
||||||
|
#ifndef PIDTEMPBED
|
||||||
|
float bedKp = DUMMY_PID_VALUE, bedKi = DUMMY_PID_VALUE, bedKd = DUMMY_PID_VALUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EEPROM_WRITE_VAR(i, bedKp);
|
||||||
|
EEPROM_WRITE_VAR(i, bedKi);
|
||||||
|
EEPROM_WRITE_VAR(i, bedKd);
|
||||||
|
|
||||||
#ifndef DOGLCD
|
#ifndef DOGLCD
|
||||||
int lcd_contrast = 32;
|
int lcd_contrast = 32;
|
||||||
#endif
|
#endif
|
||||||
@ -364,7 +377,7 @@ void Config_RetrieveSettings() {
|
|||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
|
for (int e = 0; e < 4; e++) { // 4 = max extruders currently supported by Marlin
|
||||||
EEPROM_READ_VAR(i, dummy);
|
EEPROM_READ_VAR(i, dummy); // Kp
|
||||||
if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
|
if (e < EXTRUDERS && dummy != DUMMY_PID_VALUE) {
|
||||||
// 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
|
||||||
PID_PARAM(Kp, e) = dummy;
|
PID_PARAM(Kp, e) = dummy;
|
||||||
@ -385,6 +398,20 @@ void Config_RetrieveSettings() {
|
|||||||
for (int q=16; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd, Kc
|
for (int q=16; q--;) EEPROM_READ_VAR(i, dummy); // 4x Kp, Ki, Kd, Kc
|
||||||
#endif // !PIDTEMP
|
#endif // !PIDTEMP
|
||||||
|
|
||||||
|
#ifndef PIDTEMPBED
|
||||||
|
float bedKp, bedKi, bedKd;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EEPROM_READ_VAR(i, dummy); // bedKp
|
||||||
|
if (dummy != DUMMY_PID_VALUE) {
|
||||||
|
bedKp = dummy;
|
||||||
|
EEPROM_READ_VAR(i, bedKi);
|
||||||
|
EEPROM_READ_VAR(i, bedKd);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (int q=2; q--;) EEPROM_READ_VAR(i, dummy); // bedKi, bedKd
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef DOGLCD
|
#ifndef DOGLCD
|
||||||
int lcd_contrast;
|
int lcd_contrast;
|
||||||
#endif
|
#endif
|
||||||
@ -517,6 +544,12 @@ void Config_ResetDefault() {
|
|||||||
updatePID();
|
updatePID();
|
||||||
#endif // PIDTEMP
|
#endif // PIDTEMP
|
||||||
|
|
||||||
|
#ifdef PIDTEMPBED
|
||||||
|
bedKp = DEFAULT_bedKp;
|
||||||
|
bedKi = scalePID_i(DEFAULT_bedKi);
|
||||||
|
bedKd = scalePID_d(DEFAULT_bedKd);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FWRETRACT
|
#ifdef FWRETRACT
|
||||||
autoretract_enabled = false;
|
autoretract_enabled = false;
|
||||||
retract_length = RETRACT_LENGTH;
|
retract_length = RETRACT_LENGTH;
|
||||||
@ -660,17 +693,25 @@ void Config_PrintSettings(bool forReplay) {
|
|||||||
SERIAL_EOL;
|
SERIAL_EOL;
|
||||||
#endif // DELTA
|
#endif // DELTA
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#if defined(PIDTEMP) || defined(PIDTEMPBED)
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
if (!forReplay) {
|
if (!forReplay) {
|
||||||
SERIAL_ECHOLNPGM("PID settings:");
|
SERIAL_ECHOLNPGM("PID settings:");
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
}
|
}
|
||||||
|
#ifdef PIDTEMP
|
||||||
SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
|
SERIAL_ECHOPAIR(" M301 P", PID_PARAM(Kp, 0)); // for compatibility with hosts, only echos values for E0
|
||||||
SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
|
SERIAL_ECHOPAIR(" I", unscalePID_i(PID_PARAM(Ki, 0)));
|
||||||
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
|
SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
|
||||||
SERIAL_EOL;
|
SERIAL_EOL;
|
||||||
#endif // PIDTEMP
|
#endif
|
||||||
|
#ifdef PIDTEMPBED
|
||||||
|
SERIAL_ECHOPAIR(" M304 P", bedKp); // for compatibility with hosts, only echos values for E0
|
||||||
|
SERIAL_ECHOPAIR(" I", unscalePID_i(bedKi));
|
||||||
|
SERIAL_ECHOPAIR(" D", unscalePID_d(bedKd));
|
||||||
|
SERIAL_EOL;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FWRETRACT
|
#ifdef FWRETRACT
|
||||||
|
|
||||||
|
@ -72,11 +72,11 @@ extern float current_temperature_bed;
|
|||||||
float unscalePID_d(float d);
|
float unscalePID_d(float d);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PIDTEMPBED
|
#ifdef PIDTEMPBED
|
||||||
extern float bedKp,bedKi,bedKd;
|
extern float bedKp,bedKi,bedKd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef BABYSTEPPING
|
#ifdef BABYSTEPPING
|
||||||
extern volatile int babystepsTodo[3];
|
extern volatile int babystepsTodo[3];
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user