Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
settings.h
00001 /* 00002 settings.h - eeprom configuration handling 00003 Part of Grbl 00004 00005 Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC 00006 Copyright (c) 2009-2011 Simen Svale Skogsrud 00007 00008 Grbl is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 Grbl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Grbl. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 #ifndef settings_h 00023 #define settings_h 00024 00025 #include "grbl.h" 00026 00027 00028 // Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl 00029 // when firmware is upgraded. Always stored in byte 0 of eeprom 00030 #define SETTINGS_VERSION 10 // NOTE: Check settings_reset() when moving to next version. 00031 00032 // Define bit flag masks for the boolean settings in settings.flag. 00033 #define BITFLAG_REPORT_INCHES bit(0) 00034 #define BITFLAG_LASER_MODE bit(1) 00035 #define BITFLAG_INVERT_ST_ENABLE bit(2) 00036 #define BITFLAG_HARD_LIMIT_ENABLE bit(3) 00037 #define BITFLAG_HOMING_ENABLE bit(4) 00038 #define BITFLAG_SOFT_LIMIT_ENABLE bit(5) 00039 #define BITFLAG_INVERT_LIMIT_PINS bit(6) 00040 #define BITFLAG_INVERT_PROBE_PIN bit(7) 00041 00042 // Define status reporting boolean enable bit flags in settings.status_report_mask 00043 #define BITFLAG_RT_STATUS_POSITION_TYPE bit(0) 00044 #define BITFLAG_RT_STATUS_BUFFER_STATE bit(1) 00045 00046 // Define settings restore bitflags. 00047 #define SETTINGS_RESTORE_DEFAULTS bit(0) 00048 #define SETTINGS_RESTORE_PARAMETERS bit(1) 00049 #define SETTINGS_RESTORE_STARTUP_LINES bit(2) 00050 #define SETTINGS_RESTORE_BUILD_INFO bit(3) 00051 #ifndef SETTINGS_RESTORE_ALL 00052 #define SETTINGS_RESTORE_ALL 0xFF // All bitflags 00053 #endif 00054 00055 // Define EEPROM memory address location values for Grbl settings and parameters 00056 // NOTE: The Atmega328p has 1KB EEPROM. The upper half is reserved for parameters and 00057 // the startup script. The lower half contains the global settings and space for future 00058 // developments. 00059 #define EEPROM_ADDR_GLOBAL 1U 00060 #define EEPROM_ADDR_PARAMETERS 512U 00061 #define EEPROM_ADDR_STARTUP_BLOCK 768U 00062 #define EEPROM_ADDR_BUILD_INFO 942U 00063 00064 // Define EEPROM address indexing for coordinate parameters 00065 #define N_COORDINATE_SYSTEM 6 // Number of supported work coordinate systems (from index 1) 00066 #define SETTING_INDEX_NCOORD N_COORDINATE_SYSTEM+1 // Total number of system stored (from index 0) 00067 // NOTE: Work coordinate indices are (0=G54, 1=G55, ... , 6=G59) 00068 #define SETTING_INDEX_G28 N_COORDINATE_SYSTEM // Home position 1 00069 #define SETTING_INDEX_G30 N_COORDINATE_SYSTEM+1 // Home position 2 00070 // #define SETTING_INDEX_G92 N_COORDINATE_SYSTEM+2 // Coordinate offset (G92.2,G92.3 not supported) 00071 00072 // Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS. 00073 #define AXIS_N_SETTINGS 4 00074 #define AXIS_SETTINGS_START_VAL 100 // NOTE: Reserving settings values >= 100 for axis settings. Up to 255. 00075 #define AXIS_SETTINGS_INCREMENT 10 // Must be greater than the number of axis settings 00076 00077 // Global persistent settings (Stored from byte EEPROM_ADDR_GLOBAL onwards) 00078 typedef struct { 00079 // Axis settings 00080 float steps_per_mm[N_AXIS]; 00081 float max_rate[N_AXIS]; 00082 float acceleration[N_AXIS]; 00083 float max_travel[N_AXIS]; 00084 00085 // Remaining Grbl settings 00086 uint8_t pulse_microseconds; 00087 uint8_t step_invert_mask; 00088 uint8_t dir_invert_mask; 00089 uint8_t stepper_idle_lock_time; // If max value 255, steppers do not disable. 00090 uint8_t status_report_mask; // Mask to indicate desired report data. 00091 float junction_deviation; 00092 float arc_tolerance; 00093 00094 float rpm_max; 00095 float rpm_min; 00096 00097 uint8_t flags; // Contains default boolean settings 00098 00099 uint8_t homing_dir_mask; 00100 float homing_feed_rate; 00101 float homing_seek_rate; 00102 uint16_t homing_debounce_delay; 00103 float homing_pulloff; 00104 } settings_t; 00105 extern settings_t settings; 00106 00107 // Initialize the configuration subsystem (load settings from EEPROM) 00108 void settings_init(); 00109 00110 // Helper function to clear and restore EEPROM defaults 00111 void settings_restore(uint8_t restore_flag); 00112 00113 // A helper method to set new settings from command line 00114 uint8_t settings_store_global_setting(uint8_t parameter, float value); 00115 00116 // Stores the protocol line variable as a startup line in EEPROM 00117 void settings_store_startup_line(uint8_t n, char *line); 00118 00119 // Reads an EEPROM startup line to the protocol line variable 00120 uint8_t settings_read_startup_line(uint8_t n, char *line); 00121 00122 // Stores build info user-defined string 00123 void settings_store_build_info(char *line); 00124 00125 // Reads build info user-defined string 00126 uint8_t settings_read_build_info(char *line); 00127 00128 // Writes selected coordinate data to EEPROM 00129 void settings_write_coord_data(uint8_t coord_select, float *coord_data); 00130 00131 // Reads selected coordinate data from EEPROM 00132 uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data); 00133 00134 #endif
Generated on Tue Jul 12 2022 20:45:31 by
 1.7.2
 1.7.2