New EEPROM restore functions.

- Tweaked the previous EEPROM restore implementation and added new
functionality.

- `$RST=$` restores the `$$` grbl settings back to firmware defaults,
which are set when compiled.

- `$RST=#` restores the `$#` parameters in EEPROM. At times it’s useful
to clear these and start over, rather than manually writing each entry.

-`$RST=*` wipe all of the data in EEPROM that Grbl uses and restores
them to defaults. This includes `$$` settings, `$#` parameters, `$N`
startup lines, and `$i` build info string.

NOTE: This doesn’t write zeros throughout the EEPROM. It only writes
where Grbl looks for data. For a complete wipe, please use the Arduino
IDE’s EEPROM clear example.

- Refactored the restore and wipe functions in settings.c to
accommodate the new commands.
This commit is contained in:
Sonny Jeon
2015-06-20 10:27:24 -06:00
parent e6db564511
commit 81505e6a81
6 changed files with 90 additions and 83 deletions

View File

@ -46,6 +46,13 @@
#define BITFLAG_RT_STATUS_SERIAL_RX bit(3)
#define BITFLAG_RT_STATUS_LIMIT_PINS bit(4)
// Define settings restore bitflags.
#define SETTINGS_RESTORE_ALL 0xFF // All bitflags
#define SETTINGS_RESTORE_DEFAULTS bit(0)
#define SETTINGS_RESTORE_PARAMETERS bit(1)
#define SETTINGS_RESTORE_STARTUP_LINES bit(2)
#define SETTINGS_RESTORE_BUILD_INFO bit(3)
// Define EEPROM memory address location values for Grbl settings and parameters
// NOTE: The Atmega328p has 1KB EEPROM. The upper half is reserved for parameters and
// the startup script. The lower half contains the global settings and space for future
@ -98,11 +105,8 @@ extern settings_t settings;
// Initialize the configuration subsystem (load settings from EEPROM)
void settings_init();
// Helper functions to clear and restore EEPROM defaults
void settings_restore_global_settings();
void settings_clear_parameters();
void settings_clear_startup_lines();
void settings_clear_build_info();
// Helper function to clear and restore EEPROM defaults
void settings_restore(uint8_t restore_flag);
// A helper method to set new settings from command line
uint8_t settings_store_global_setting(uint8_t parameter, float value);