/*
settings.c - eeprom configuration handling
Part of Grbl
Copyright (c) 2009-2011 Simen Svale Skogsrud
Copyright (c) 2011 Sungeun Jeon
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see .
*/
#include
#include
#include "nuts_bolts.h"
#include "settings.h"
#include "eeprom.h"
#include "print.h"
#include
#include "protocol.h"
#include "config.h"
settings_t settings;
// Version 1 outdated settings record
typedef struct {
double steps_per_mm[3];
uint8_t microsteps;
uint8_t pulse_microseconds;
double default_feed_rate;
double default_seek_rate;
uint8_t invert_mask;
double mm_per_arc_segment;
} settings_v1_t;
// Default settings (used when resetting eeprom-settings)
#define MICROSTEPS 8
#define DEFAULT_X_STEPS_PER_MM (94.488188976378*MICROSTEPS)
#define DEFAULT_Y_STEPS_PER_MM (94.488188976378*MICROSTEPS)
#define DEFAULT_Z_STEPS_PER_MM (94.488188976378*MICROSTEPS)
#define DEFAULT_STEP_PULSE_MICROSECONDS 30
#define DEFAULT_MM_PER_ARC_SEGMENT 0.1
#define DEFAULT_RAPID_FEEDRATE 500.0 // in millimeters per minute
#define DEFAULT_FEEDRATE 500.0
#define DEFAULT_ACCELERATION (DEFAULT_FEEDRATE/10.0)
#define DEFAULT_JUNCTION_DEVIATION 0.05
#define DEFAULT_STEPPING_INVERT_MASK ((1< 0.0\r\n"));
return;
}
settings.steps_per_mm[parameter] = value; break;
case 3:
if (value < 3) {
printPgmString(PSTR("Step pulse must be >= 3 microseconds\r\n"));
return;
}
settings.pulse_microseconds = round(value); break;
case 4: settings.default_feed_rate = value; break;
case 5: settings.default_seek_rate = value; break;
case 6: settings.mm_per_arc_segment = value; break;
case 7: settings.invert_mask = trunc(value); break;
case 8: settings.acceleration = value; break;
case 9: settings.junction_deviation = fabs(value); break;
default:
printPgmString(PSTR("Unknown parameter\r\n"));
return;
}
write_settings();
printPgmString(PSTR("Stored new setting\r\n"));
}
// Initialize the config subsystem
void settings_init() {
if(read_settings()) {
printPgmString(PSTR("'$' to dump current settings\r\n"));
} else {
printPgmString(PSTR("Warning: Failed to read EEPROM settings. Using defaults.\r\n"));
settings_reset();
write_settings();
settings_dump();
}
}