added M503 to display eeprom storage, and renamed eeprom routings. This version is compatible with the qtmarlin eeprom-tab.

This commit is contained in:
Bernhard 2011-12-04 22:26:42 +01:00
parent 7714b98da7
commit cf50ba140f
3 changed files with 73 additions and 58 deletions

View File

@ -39,7 +39,7 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V04" #define EEPROM_VERSION "V04"
FORCE_INLINE void StoreSettings() inline void EEPROM_StoreSettings()
{ {
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
char ver[4]= "000"; char ver[4]= "000";
@ -72,59 +72,10 @@ FORCE_INLINE void StoreSettings()
#endif //EEPROM_SETTINGS #endif //EEPROM_SETTINGS
} }
FORCE_INLINE void RetrieveSettings(bool def=false)
inline void EEPROM_printSettings()
{ // if def=true, the default values will be used { // if def=true, the default values will be used
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
int i=EEPROM_OFFSET;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_readAnything(i,stored_ver); //read stored version
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
if ((!def)&&(strncmp(ver,stored_ver,3)==0))
{ // version number match
EEPROM_readAnything(i,axis_steps_per_unit);
EEPROM_readAnything(i,max_feedrate);
EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
EEPROM_readAnything(i,acceleration);
EEPROM_readAnything(i,retract_acceleration);
EEPROM_readAnything(i,minimumfeedrate);
EEPROM_readAnything(i,mintravelfeedrate);
EEPROM_readAnything(i,minsegmenttime);
EEPROM_readAnything(i,max_xy_jerk);
EEPROM_readAnything(i,max_z_jerk);
#ifndef PIDTEMP
float Kp,Ki,Kd;
#endif
EEPROM_readAnything(i,Kp);
EEPROM_readAnything(i,Ki);
EEPROM_readAnything(i,Kd);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retreived:");
}
else
#endif
{
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[]=DEFAULT_MAX_FEEDRATE;
long tmp3[]=DEFAULT_MAX_ACCELERATION;
for (short i=0;i<4;i++)
{
axis_steps_per_unit[i]=tmp1[i];
max_feedrate[i]=tmp2[i];
max_acceleration_units_per_sq_second[i]=tmp3[i];
}
acceleration=DEFAULT_ACCELERATION;
retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
minsegmenttime=DEFAULT_MINSEGMENTTIME;
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
max_xy_jerk=DEFAULT_XYJERK;
max_z_jerk=DEFAULT_ZJERK;
SERIAL_ECHO_START;
SERIAL_ECHOLN("Using Default settings:");
}
#ifdef EEPROM_CHITCHAT
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Steps per unit:"); SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START; SERIAL_ECHO_START;
@ -177,6 +128,64 @@ FORCE_INLINE void RetrieveSettings(bool def=false)
#endif #endif
} }
inline void EEPROM_RetrieveSettings(bool def=false)
{ // if def=true, the default values will be used
#ifdef EEPROM_SETTINGS
int i=EEPROM_OFFSET;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_readAnything(i,stored_ver); //read stored version
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
if ((!def)&&(strncmp(ver,stored_ver,3)==0))
{ // version number match
EEPROM_readAnything(i,axis_steps_per_unit);
EEPROM_readAnything(i,max_feedrate);
EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
EEPROM_readAnything(i,acceleration);
EEPROM_readAnything(i,retract_acceleration);
EEPROM_readAnything(i,minimumfeedrate);
EEPROM_readAnything(i,mintravelfeedrate);
EEPROM_readAnything(i,minsegmenttime);
EEPROM_readAnything(i,max_xy_jerk);
EEPROM_readAnything(i,max_z_jerk);
#ifndef PIDTEMP
float Kp,Ki,Kd;
#endif
EEPROM_readAnything(i,Kp);
EEPROM_readAnything(i,Ki);
EEPROM_readAnything(i,Kd);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retreived:");
}
else
#endif
{
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[]=DEFAULT_MAX_FEEDRATE;
long tmp3[]=DEFAULT_MAX_ACCELERATION;
for (short i=0;i<4;i++)
{
axis_steps_per_unit[i]=tmp1[i];
max_feedrate[i]=tmp2[i];
max_acceleration_units_per_sq_second[i]=tmp3[i];
}
acceleration=DEFAULT_ACCELERATION;
retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
minsegmenttime=DEFAULT_MINSEGMENTTIME;
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
max_xy_jerk=DEFAULT_XYJERK;
max_z_jerk=DEFAULT_ZJERK;
SERIAL_ECHO_START;
SERIAL_ECHOLN("Using Default settings:");
}
#ifdef EEPROM_CHITCHAT
EEPROM_printSettings();
#endif
}
#endif #endif

View File

@ -112,6 +112,7 @@
// M500 - stores paramters in EEPROM // M500 - stores paramters in EEPROM
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
// M503 - print the current settings (from memory not from eeprom)
//Stepper Movement Variables //Stepper Movement Variables
@ -236,7 +237,7 @@ void setup()
fromsd[i] = false; fromsd[i] = false;
} }
RetrieveSettings(); // loads data from EEPROM if available EEPROM_RetrieveSettings(); // loads data from EEPROM if available
for(int8_t i=0; i < NUM_AXIS; i++) for(int8_t i=0; i < NUM_AXIS; i++)
{ {
@ -1034,17 +1035,22 @@ FORCE_INLINE void process_commands()
break; break;
case 500: // Store settings in EEPROM case 500: // Store settings in EEPROM
{ {
StoreSettings(); EEPROM_StoreSettings();
} }
break; break;
case 501: // Read settings from EEPROM case 501: // Read settings from EEPROM
{ {
RetrieveSettings(); EEPROM_RetrieveSettings();
} }
break; break;
case 502: // Revert to default settings case 502: // Revert to default settings
{ {
RetrieveSettings(true); EEPROM_RetrieveSettings(true);
}
break;
case 503: // print settings currently in memory
{
EEPROM_printSettings();
} }
break; break;

View File

@ -1402,7 +1402,7 @@ void MainMenu::showControl()
//enquecommand("M84"); //enquecommand("M84");
beepshort(); beepshort();
BLOCK; BLOCK;
StoreSettings(); EEPROM_StoreSettings();
} }
}break; }break;
case ItemC_load: case ItemC_load:
@ -1416,7 +1416,7 @@ void MainMenu::showControl()
//enquecommand("M84"); //enquecommand("M84");
beepshort(); beepshort();
BLOCK; BLOCK;
RetrieveSettings(); EEPROM_RetrieveSettings();
} }
}break; }break;
case ItemC_failsafe: case ItemC_failsafe:
@ -1430,7 +1430,7 @@ void MainMenu::showControl()
//enquecommand("M84"); //enquecommand("M84");
beepshort(); beepshort();
BLOCK; BLOCK;
RetrieveSettings(true); EEPROM_RetrieveSettings(true);
} }
}break; }break;
default: default: