gnea\grbl-Mega  1.0f
Source Code Documentation ( Internal Workings )
settings.h File Reference
#include "grbl.h"

Go to the source code of this file.

Data Structures

struct  settings_t
 Global persistent settings (Stored from byte EEPROM_ADDR_GLOBAL onwards) More...
 

Macros

#define SETTINGS_VERSION   10
 Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl. More...
 
#define BITFLAG_REPORT_INCHES   bit(0)
 NOTE: Check settings_reset() when moving to next version. More...
 
#define BITFLAG_LASER_MODE   bit(1)
 
#define BITFLAG_INVERT_ST_ENABLE   bit(2)
 
#define BITFLAG_HARD_LIMIT_ENABLE   bit(3)
 
#define BITFLAG_HOMING_ENABLE   bit(4)
 
#define BITFLAG_SOFT_LIMIT_ENABLE   bit(5)
 
#define BITFLAG_INVERT_LIMIT_PINS   bit(6)
 
#define BITFLAG_INVERT_PROBE_PIN   bit(7)
 
#define BITFLAG_RT_STATUS_POSITION_TYPE   bit(0)
 Define status reporting boolean enable bit flags in settings.status_report_mask. More...
 
#define BITFLAG_RT_STATUS_BUFFER_STATE   bit(1)
 
#define SETTINGS_RESTORE_DEFAULTS   bit(0)
 Define settings restore bitflags. More...
 
#define SETTINGS_RESTORE_PARAMETERS   bit(1)
 
#define SETTINGS_RESTORE_STARTUP_LINES   bit(2)
 
#define SETTINGS_RESTORE_BUILD_INFO   bit(3)
 
#define EEPROM_ADDR_GLOBAL   1U
 Define EEPROM memory address location values for Grbl settings and parameters. More...
 
#define EEPROM_ADDR_PARAMETERS   512U
 
#define EEPROM_ADDR_STARTUP_BLOCK   768U
 
#define EEPROM_ADDR_BUILD_INFO   942U
 
#define N_COORDINATE_SYSTEM   6
 Define EEPROM address indexing for coordinate parameters. More...
 
#define SETTING_INDEX_NCOORD   N_COORDINATE_SYSTEM+1
 Total number of system stored (from index 0) More...
 
#define SETTING_INDEX_G28   N_COORDINATE_SYSTEM
 NOTE: Work coordinate indices are (0=G54, 1=G55, ... , 6=G59) More...
 
#define SETTING_INDEX_G30   N_COORDINATE_SYSTEM+1
 Home position 2. More...
 
#define AXIS_N_SETTINGS   4
 Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS. More...
 
#define AXIS_SETTINGS_START_VAL   100
 
#define AXIS_SETTINGS_INCREMENT   10
 NOTE: Reserving settings values >= 100 for axis settings. Up to 255. More...
 

Functions

void settings_init ()
 Initialize the configuration subsystem (load settings from EEPROM) More...
 
void settings_restore (uint8_t restore_flag)
 Helper function to clear and restore EEPROM defaults. More...
 
uint8_t settings_store_global_setting (uint8_t parameter, float value)
 A helper method to set new settings from command line. More...
 
void settings_store_startup_line (uint8_t n, char *line)
 Stores the protocol line variable as a startup line in EEPROM. More...
 
uint8_t settings_read_startup_line (uint8_t n, char *line)
 Reads an EEPROM startup line to the protocol line variable. More...
 
void settings_store_build_info (char *line)
 Stores build info user-defined string. More...
 
uint8_t settings_read_build_info (char *line)
 Reads build info user-defined string. More...
 
void settings_write_coord_data (uint8_t coord_select, float *coord_data)
 Writes selected coordinate data to EEPROM. More...
 
uint8_t settings_read_coord_data (uint8_t coord_select, float *coord_data)
 Reads selected coordinate data from EEPROM. More...
 
uint8_t get_step_pin_mask (uint8_t i)
 Returns the step pin mask according to Grbl's internal axis numbering. More...
 
uint8_t get_direction_pin_mask (uint8_t i)
 Returns the direction pin mask according to Grbl's internal axis numbering. More...
 
uint8_t get_limit_pin_mask (uint8_t i)
 Returns the limit pin mask according to Grbl's internal axis numbering. More...
 

Variables

settings_t settings
 

Data Structure Documentation

struct settings_t

Global persistent settings (Stored from byte EEPROM_ADDR_GLOBAL onwards)

Definition at line 73 of file settings.h.

Data Fields
float acceleration[N_AXIS]
float arc_tolerance
uint8_t dir_invert_mask
uint8_t flags Contains default boolean settings.
uint16_t homing_debounce_delay
uint8_t homing_dir_mask
float homing_feed_rate
float homing_pulloff
float homing_seek_rate
float junction_deviation
float max_rate[N_AXIS]
float max_travel[N_AXIS]
uint8_t pulse_microseconds
float rpm_max
float rpm_min
uint8_t status_report_mask Mask to indicate desired report data.
uint8_t step_invert_mask
uint8_t stepper_idle_lock_time If max value 255, steppers do not disable.
float steps_per_mm[N_AXIS]

Macro Definition Documentation

#define AXIS_N_SETTINGS   4

Define Grbl axis settings numbering scheme. Starts at START_VAL, every INCREMENT, over N_SETTINGS.

Definition at line 68 of file settings.h.

#define AXIS_SETTINGS_INCREMENT   10

NOTE: Reserving settings values >= 100 for axis settings. Up to 255.

Must be greater than the number of axis settings

Definition at line 71 of file settings.h.

#define AXIS_SETTINGS_START_VAL   100

Definition at line 69 of file settings.h.

#define BITFLAG_HARD_LIMIT_ENABLE   bit(3)

Definition at line 38 of file settings.h.

#define BITFLAG_HOMING_ENABLE   bit(4)

Definition at line 39 of file settings.h.

#define BITFLAG_INVERT_LIMIT_PINS   bit(6)

Definition at line 41 of file settings.h.

#define BITFLAG_INVERT_PROBE_PIN   bit(7)

Definition at line 42 of file settings.h.

#define BITFLAG_INVERT_ST_ENABLE   bit(2)

Definition at line 37 of file settings.h.

#define BITFLAG_LASER_MODE   bit(1)

Definition at line 36 of file settings.h.

#define BITFLAG_REPORT_INCHES   bit(0)

NOTE: Check settings_reset() when moving to next version.

Define bit flag masks for the boolean settings in settings.flag.

Definition at line 35 of file settings.h.

#define BITFLAG_RT_STATUS_BUFFER_STATE   bit(1)

Definition at line 45 of file settings.h.

#define BITFLAG_RT_STATUS_POSITION_TYPE   bit(0)

Define status reporting boolean enable bit flags in settings.status_report_mask.

Definition at line 44 of file settings.h.

#define BITFLAG_SOFT_LIMIT_ENABLE   bit(5)

Definition at line 40 of file settings.h.

#define EEPROM_ADDR_BUILD_INFO   942U

Definition at line 58 of file settings.h.

#define EEPROM_ADDR_GLOBAL   1U

Define EEPROM memory address location values for Grbl settings and parameters.

Definition at line 55 of file settings.h.

#define EEPROM_ADDR_PARAMETERS   512U

Definition at line 56 of file settings.h.

#define EEPROM_ADDR_STARTUP_BLOCK   768U

Definition at line 57 of file settings.h.

#define N_COORDINATE_SYSTEM   6

Define EEPROM address indexing for coordinate parameters.

Number of supported work coordinate systems (from index 1)

Definition at line 60 of file settings.h.

#define SETTING_INDEX_G28   N_COORDINATE_SYSTEM

NOTE: Work coordinate indices are (0=G54, 1=G55, ... , 6=G59)

Home position 1

Definition at line 64 of file settings.h.

#define SETTING_INDEX_G30   N_COORDINATE_SYSTEM+1

Home position 2.

Definition at line 65 of file settings.h.

#define SETTING_INDEX_NCOORD   N_COORDINATE_SYSTEM+1

Total number of system stored (from index 0)

Definition at line 61 of file settings.h.

#define SETTINGS_RESTORE_BUILD_INFO   bit(3)

Definition at line 50 of file settings.h.

#define SETTINGS_RESTORE_DEFAULTS   bit(0)

Define settings restore bitflags.

Definition at line 47 of file settings.h.

#define SETTINGS_RESTORE_PARAMETERS   bit(1)

Definition at line 48 of file settings.h.

#define SETTINGS_RESTORE_STARTUP_LINES   bit(2)

Definition at line 49 of file settings.h.

#define SETTINGS_VERSION   10

Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl.

Definition at line 32 of file settings.h.

Function Documentation

uint8_t get_direction_pin_mask ( uint8_t  axis_idx)

Returns the direction pin mask according to Grbl's internal axis numbering.

Returns the direction pin mask according to Grbl's internal axis numbering.

Definition at line 316 of file settings.c.

uint8_t get_limit_pin_mask ( uint8_t  axis_idx)

Returns the limit pin mask according to Grbl's internal axis numbering.

Returns the limit pin mask according to Grbl's internal axis numbering.

Definition at line 324 of file settings.c.

uint8_t get_step_pin_mask ( uint8_t  axis_idx)

Returns the step pin mask according to Grbl's internal axis numbering.

Returns the step pin mask according to Grbl's internal axis numbering.

Definition at line 308 of file settings.c.

void settings_init ( )

Initialize the configuration subsystem (load settings from EEPROM)

Initialize the configuration subsystem (load settings from EEPROM)

< Force restore all EEPROM data.

Definition at line 299 of file settings.c.

uint8_t settings_read_build_info ( char *  line)

Reads build info user-defined string.

Reads build info user-defined string.

< Empty line

Definition at line 148 of file settings.c.

uint8_t settings_read_coord_data ( uint8_t  coord_select,
float *  coord_data 
)

Reads selected coordinate data from EEPROM.

Reads selected coordinate data from EEPROM.

Definition at line 160 of file settings.c.

uint8_t settings_read_startup_line ( uint8_t  n,
char *  line 
)

Reads an EEPROM startup line to the protocol line variable.

Reads an EEPROM startup line to the protocol line variable.

< Empty line

Definition at line 135 of file settings.c.

void settings_restore ( uint8_t  restore_flag)

Helper function to clear and restore EEPROM defaults.

Helper function to clear and restore EEPROM defaults.

< Checksum

< Checksum

< Checksum

Definition at line 65 of file settings.c.

void settings_store_build_info ( char *  line)

Stores build info user-defined string.

Stores build info user-defined string.

NOTE: This function can only be called in IDLE state.

Definition at line 39 of file settings.c.

uint8_t settings_store_global_setting ( uint8_t  parameter,
float  value 
)

A helper method to set new settings from command line.

A helper method to set new settings from command line.

NOTE: Ensure the setting index corresponds to the report.c settings printout.

< Convert to mm/min^2 for grbl internal use.

< Store as negative for grbl internal use.

< Exit while-loop after setting has been configured and proceed to the EEPROM write call.

< Regenerate step and direction port invert masks.

< Regenerate step and direction port invert masks.

< Reset to ensure change. Immediate re-init may cause problems.

< Reset to ensure change. Immediate re-init may cause problems.

< Reset to ensure change. Immediate re-init may cause problems.

< Make sure WCO is immediately updated.

< Re-init to immediately change.

NOTE: Nice to have but could be problematic later.

< Force disable soft-limits.

< Re-initialize spindle rpm calibration

< Re-initialize spindle rpm calibration

Definition at line 188 of file settings.c.

void settings_store_startup_line ( uint8_t  n,
char *  line 
)

Stores the protocol line variable as a startup line in EEPROM.

Stores the protocol line variable as a startup line in EEPROM.

< A startup line may contain a motion and be executing.

Definition at line 27 of file settings.c.

void settings_write_coord_data ( uint8_t  coord_select,
float *  coord_data 
)

Writes selected coordinate data to EEPROM.

Writes selected coordinate data to EEPROM.

Definition at line 46 of file settings.c.

Variable Documentation

settings_t settings

Definition at line 24 of file settings.c.