Add PIDTEMPBED to EEPROM
This commit is contained in:
parent
e8700bd1e2
commit
424d5495e4
@ -3,7 +3,21 @@
|
||||
*
|
||||
* 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
|
||||
* axis_steps_per_unit (x4)
|
||||
@ -47,6 +61,9 @@
|
||||
* Kp[2], Ki[2], Kd[2], Kc[2]
|
||||
* Kp[3], Ki[3], Kd[3], Kc[3]
|
||||
*
|
||||
* PIDTEMPBED:
|
||||
* bedKp, bedKi, bedKd
|
||||
*
|
||||
* DOGLCD:
|
||||
* lcd_contrast
|
||||
*
|
||||
@ -111,15 +128,6 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
|
||||
|
||||
#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
|
||||
|
||||
void Config_StoreSettings() {
|
||||
@ -194,7 +202,6 @@ void Config_StoreSettings() {
|
||||
EEPROM_WRITE_VAR(i, absPreheatHPBTemp);
|
||||
EEPROM_WRITE_VAR(i, absPreheatFanSpeed);
|
||||
|
||||
|
||||
for (int e = 0; e < 4; e++) {
|
||||
|
||||
#ifdef PIDTEMP
|
||||
@ -209,12 +216,10 @@ void Config_StoreSettings() {
|
||||
EEPROM_WRITE_VAR(i, dummy);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#else // !PIDTEMP
|
||||
{
|
||||
else
|
||||
#endif // !PIDTEMP
|
||||
|
||||
dummy = DUMMY_PID_VALUE;
|
||||
{
|
||||
dummy = DUMMY_PID_VALUE; // When read, will not change the existing value
|
||||
EEPROM_WRITE_VAR(i, dummy);
|
||||
dummy = 0.0f;
|
||||
for (int q = 3; q--;) EEPROM_WRITE_VAR(i, dummy);
|
||||
@ -222,6 +227,14 @@ void Config_StoreSettings() {
|
||||
|
||||
} // 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
|
||||
int lcd_contrast = 32;
|
||||
#endif
|
||||
@ -364,7 +377,7 @@ void Config_RetrieveSettings() {
|
||||
|
||||
#ifdef PIDTEMP
|
||||
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) {
|
||||
// do not need to scale PID values as the values in EEPROM are already scaled
|
||||
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
|
||||
#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
|
||||
int lcd_contrast;
|
||||
#endif
|
||||
@ -517,6 +544,12 @@ void Config_ResetDefault() {
|
||||
updatePID();
|
||||
#endif // PIDTEMP
|
||||
|
||||
#ifdef PIDTEMPBED
|
||||
bedKp = DEFAULT_bedKp;
|
||||
bedKi = scalePID_i(DEFAULT_bedKi);
|
||||
bedKd = scalePID_d(DEFAULT_bedKd);
|
||||
#endif
|
||||
|
||||
#ifdef FWRETRACT
|
||||
autoretract_enabled = false;
|
||||
retract_length = RETRACT_LENGTH;
|
||||
@ -660,17 +693,25 @@ void Config_PrintSettings(bool forReplay) {
|
||||
SERIAL_EOL;
|
||||
#endif // DELTA
|
||||
|
||||
#ifdef PIDTEMP
|
||||
#if defined(PIDTEMP) || defined(PIDTEMPBED)
|
||||
SERIAL_ECHO_START;
|
||||
if (!forReplay) {
|
||||
SERIAL_ECHOLNPGM("PID settings:");
|
||||
SERIAL_ECHO_START;
|
||||
}
|
||||
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(" D", unscalePID_d(PID_PARAM(Kd, 0)));
|
||||
SERIAL_EOL;
|
||||
#endif // PIDTEMP
|
||||
#ifdef PIDTEMP
|
||||
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(" D", unscalePID_d(PID_PARAM(Kd, 0)));
|
||||
SERIAL_EOL;
|
||||
#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
|
||||
|
||||
|
@ -72,11 +72,11 @@ extern float current_temperature_bed;
|
||||
float unscalePID_d(float d);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PIDTEMPBED
|
||||
extern float bedKp,bedKi,bedKd;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BABYSTEPPING
|
||||
extern volatile int babystepsTodo[3];
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user