refactored handling of settings '$' command out of gcode module and into settings module
This commit is contained in:
23
settings.c
23
settings.c
@ -25,6 +25,7 @@
|
||||
#include "eeprom.h"
|
||||
#include "wiring_serial.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include "protocol.h"
|
||||
|
||||
settings_t settings;
|
||||
|
||||
@ -81,6 +82,28 @@ void settings_dump() {
|
||||
printPgmString(PSTR("\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
|
||||
}
|
||||
|
||||
// Parameter lines are on the form '$4=374.3' or '$' to dump current settings
|
||||
uint8_t settings_execute_line(char *line) {
|
||||
uint8_t char_counter = 1;
|
||||
double parameter, value;
|
||||
if(line[0] != '$') {
|
||||
return(STATUS_UNSUPPORTED_STATEMENT);
|
||||
}
|
||||
if(line[char_counter] == 0) {
|
||||
settings_dump(); return(STATUS_OK);
|
||||
}
|
||||
read_double(line, &char_counter, ¶meter);
|
||||
if(line[char_counter++] != '=') {
|
||||
return(STATUS_UNSUPPORTED_STATEMENT);
|
||||
}
|
||||
read_double(line, &char_counter, &value);
|
||||
if(line[char_counter] != 0) {
|
||||
return(STATUS_UNSUPPORTED_STATEMENT);
|
||||
}
|
||||
settings_store_setting(parameter, value);
|
||||
return(STATUS_OK);
|
||||
}
|
||||
|
||||
void write_settings() {
|
||||
eeprom_put_char(0, SETTINGS_VERSION);
|
||||
memcpy_to_eeprom_with_checksum(1, (char*)&settings, sizeof(settings_t));
|
||||
|
Reference in New Issue
Block a user