mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-17 20:01:42 +02:00
Big BUILD_INFO fix (#632)
-- Changes that affect behavior Fixed the bugs with report_build_info() Build info is no longer stored in the fixed "EEPROM" section; instead it is a proper Setting named $Firmware/Build . You can change it in the usual way with $Firmware/Build=<whatever> $I without the = still works. -- Changes that affect configurability for developers Converted a couple more #defines into enums - SETTINGS_RESTORE_* and BITFLAG_RT_STATUS_* . A side effect of this is that it is no longer possible to configure the behavior of $RST=* by defining SETTINGS_RESTORE_ALL to include only a subset. I think it is a bad idea from a customer support perspective to have the meaning of this command be different for different builds. Changed some of the #define ENABLE_ names to eliminate "EEPROM" -- Changes that are purely cosmetic Clarified descriptions in Config.h, to eliminate spurious/incorrect mentions of "EEPROM" Eliminated all mentions of the name "EEPROM" except the ones that truly mean the EEPROM section, as opposed to generalized non-volatile storage. The contents of SettingsStorage.h and SettingsStorage.cpp, which were really related to coordinate storage in Eeprom, not proper settings, were moved to Eeprom.h and Eeprom.cpp. The SettingsStorage files are gone. Got rid of get_step_pin_mask() and get_direction_pin_mask() because they were just aliases for bit(). That eliminated some junk from the SettingsStorage/Eeprom files. Those files now tightly contain only the residual stuff related to the storage of coordinate data in EEPROM.
This commit is contained in:
@@ -162,9 +162,9 @@ const int DEFAULT_RADIO_MODE = ESP_RADIO_OFF;
|
|||||||
|
|
||||||
// Define realtime command special characters. These characters are 'picked-off' directly from the
|
// Define realtime command special characters. These characters are 'picked-off' directly from the
|
||||||
// serial read data stream and are not passed to the grbl line execution parser. Select characters
|
// serial read data stream and are not passed to the grbl line execution parser. Select characters
|
||||||
// that do not and must not exist in the streamed g-code program. ASCII control characters may be
|
// that do not and must not exist in the streamed GCode program. ASCII control characters may be
|
||||||
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
|
// used, if they are available per user setup. Also, extended ASCII codes (>127), which are never in
|
||||||
// g-code programs, maybe selected for interface programs.
|
// GCode programs, maybe selected for interface programs.
|
||||||
// NOTE: If changed, manually update help message in report.c.
|
// NOTE: If changed, manually update help message in report.c.
|
||||||
|
|
||||||
const uint8_t CMD_RESET = 0x18; // ctrl-x.
|
const uint8_t CMD_RESET = 0x18; // ctrl-x.
|
||||||
@@ -218,9 +218,9 @@ static const uint8_t NHomingLocateCycle = 1; // Integer (1-128)
|
|||||||
// If you have a two-axis machine, DON'T USE THIS. Instead, just alter the homing cycle for two-axes.
|
// If you have a two-axis machine, DON'T USE THIS. Instead, just alter the homing cycle for two-axes.
|
||||||
#define HOMING_SINGLE_AXIS_COMMANDS // Default disabled. Uncomment to enable.
|
#define HOMING_SINGLE_AXIS_COMMANDS // Default disabled. Uncomment to enable.
|
||||||
|
|
||||||
// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
|
// Number of blocks Grbl executes upon startup. These blocks are stored in non-volatile storage.
|
||||||
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
|
// and addresses are defined in settings.h. With the current settings, up to 2 startup blocks may
|
||||||
// be stored and executed in order. These startup blocks would typically be used to set the g-code
|
// be stored and executed in order. These startup blocks would typically be used to set the GCode
|
||||||
// parser state depending on user preferences.
|
// parser state depending on user preferences.
|
||||||
#define N_STARTUP_LINE 2 // Integer (1-2)
|
#define N_STARTUP_LINE 2 // Integer (1-2)
|
||||||
|
|
||||||
@@ -248,7 +248,7 @@ static const uint8_t NHomingLocateCycle = 1; // Integer (1-128)
|
|||||||
// coordinates through Grbl '$#' print parameters.
|
// coordinates through Grbl '$#' print parameters.
|
||||||
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
|
#define MESSAGE_PROBE_COORDINATES // Enabled by default. Comment to disable.
|
||||||
|
|
||||||
// Enables a second coolant control pin via the mist coolant g-code command M7 on the Arduino Uno
|
// Enables a second coolant control pin via the mist coolant GCode command M7 on the Arduino Uno
|
||||||
// analog pin 4. Only use this option if you require a second coolant control pin.
|
// analog pin 4. Only use this option if you require a second coolant control pin.
|
||||||
// NOTE: The M8 flood coolant control pin on analog pin 3 will still be functional regardless.
|
// NOTE: The M8 flood coolant control pin on analog pin 3 will still be functional regardless.
|
||||||
// ESP32 NOTE! This is here for reference only. You enable both M7 and M8 by assigning them a GPIO Pin
|
// ESP32 NOTE! This is here for reference only. You enable both M7 and M8 by assigning them a GPIO Pin
|
||||||
@@ -326,7 +326,7 @@ const int MIN_SPINDLE_SPEED_OVERRIDE = 10; // Percent of programmed spi
|
|||||||
const int SPINDLE_OVERRIDE_COARSE_INCREMENT = 10; // (1-99). Usually 10%.
|
const int SPINDLE_OVERRIDE_COARSE_INCREMENT = 10; // (1-99). Usually 10%.
|
||||||
const int SPINDLE_OVERRIDE_FINE_INCREMENT = 1; // (1-99). Usually 1%.
|
const int SPINDLE_OVERRIDE_FINE_INCREMENT = 1; // (1-99). Usually 1%.
|
||||||
|
|
||||||
// When a M2 or M30 program end command is executed, most g-code states are restored to their defaults.
|
// When a M2 or M30 program end command is executed, most GCode states are restored to their defaults.
|
||||||
// This compile-time option includes the restoring of the feed, rapid, and spindle speed override values
|
// This compile-time option includes the restoring of the feed, rapid, and spindle speed override values
|
||||||
// to their default values at program end.
|
// to their default values at program end.
|
||||||
#define RESTORE_OVERRIDES_AFTER_PROGRAM_END // Default enabled. Comment to disable.
|
#define RESTORE_OVERRIDES_AFTER_PROGRAM_END // Default enabled. Comment to disable.
|
||||||
@@ -438,7 +438,7 @@ const double MINIMUM_FEED_RATE = 1.0; // (mm/min)
|
|||||||
// bogged down by too many trig calculations.
|
// bogged down by too many trig calculations.
|
||||||
const int N_ARC_CORRECTION = 12; // Integer (1-255)
|
const int N_ARC_CORRECTION = 12; // Integer (1-255)
|
||||||
|
|
||||||
// The arc G2/3 g-code standard is problematic by definition. Radius-based arcs have horrible numerical
|
// The arc G2/3 GCode standard is problematic by definition. Radius-based arcs have horrible numerical
|
||||||
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
|
// errors when arc at semi-circles(pi) or full-circles(2*pi). Offset-based arcs are much more accurate
|
||||||
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
|
// but still have a problem when arcs are full-circles (2*pi). This define accounts for the floating
|
||||||
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
|
// point issues when offset-based arcs are commanded as full circles, but get interpreted as extremely
|
||||||
@@ -491,13 +491,10 @@ const int DWELL_TIME_STEP = 50; // Integer (1-255) (milliseconds)
|
|||||||
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
|
// #define SEGMENT_BUFFER_SIZE 6 // Uncomment to override default in stepper.h.
|
||||||
|
|
||||||
// Line buffer size from the serial input stream to be executed. Also, governs the size of
|
// Line buffer size from the serial input stream to be executed. Also, governs the size of
|
||||||
// each of the startup blocks, as they are each stored as a string of this size. Make sure
|
// each of the startup blocks, as they are each stored as a string of this size.
|
||||||
// to account for the available EEPROM at the defined memory address in settings.h and for
|
|
||||||
// the number of desired startup blocks.
|
|
||||||
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
|
// NOTE: 80 characters is not a problem except for extreme cases, but the line buffer size
|
||||||
// can be too small and g-code blocks can get truncated. Officially, the g-code standards
|
// can be too small and GCode blocks can get truncated. Officially, the GCode standards
|
||||||
// support up to 256 characters. In future versions, this default will be increased, when
|
// support up to 256 characters.
|
||||||
// we know how much extra memory space we can re-invest into this.
|
|
||||||
// #define LINE_BUFFER_SIZE 80 // Uncomment to override default in protocol.h
|
// #define LINE_BUFFER_SIZE 80 // Uncomment to override default in protocol.h
|
||||||
|
|
||||||
// Serial send and receive buffer size. The receive buffer is often used as another streaming
|
// Serial send and receive buffer size. The receive buffer is often used as another streaming
|
||||||
@@ -545,19 +542,9 @@ const int DEBOUNCE_PERIOD = 32; // in milliseconds default 32 microseconds
|
|||||||
|
|
||||||
// Enable the '$RST=*', '$RST=$', and '$RST=#' eeprom restore commands. There are cases where
|
// Enable the '$RST=*', '$RST=$', and '$RST=#' eeprom restore commands. There are cases where
|
||||||
// these commands may be undesirable. Simply comment the desired macro to disable it.
|
// these commands may be undesirable. Simply comment the desired macro to disable it.
|
||||||
// NOTE: See SETTINGS_RESTORE_ALL macro for customizing the `$RST=*` command.
|
#define ENABLE_RESTORE_WIPE_ALL // '$RST=*' Default enabled. Comment to disable.
|
||||||
#define ENABLE_RESTORE_EEPROM_WIPE_ALL // '$RST=*' Default enabled. Comment to disable.
|
#define ENABLE_RESTORE_DEFAULT_SETTINGS // '$RST=$' Default enabled. Comment to disable.
|
||||||
#define ENABLE_RESTORE_EEPROM_DEFAULT_SETTINGS // '$RST=$' Default enabled. Comment to disable.
|
#define ENABLE_RESTORE_PARAMETERS // '$RST=#' Default enabled. Comment to disable.
|
||||||
#define ENABLE_RESTORE_EEPROM_CLEAR_PARAMETERS // '$RST=#' Default enabled. Comment to disable.
|
|
||||||
|
|
||||||
// Defines the EEPROM data restored upon a settings version change and `$RST=*` command. Whenever the
|
|
||||||
// the settings or other EEPROM data structure changes between Grbl versions, Grbl will automatically
|
|
||||||
// wipe and restore the EEPROM. This macro controls what data is wiped and restored. This is useful
|
|
||||||
// particularily for OEMs that need to retain certain data. For example, the BUILD_INFO string can be
|
|
||||||
// written into the Arduino EEPROM via a seperate .INO sketch to contain product data. Altering this
|
|
||||||
// macro to not restore the build info EEPROM will ensure this data is retained after firmware upgrades.
|
|
||||||
// NOTE: Uncomment to override defaults in settings.h
|
|
||||||
// #define SETTINGS_RESTORE_ALL (SETTINGS_RESTORE_DEFAULTS | SETTINGS_RESTORE_PARAMETERS | SETTINGS_RESTORE_STARTUP_LINES | SETTINGS_RESTORE_BUILD_INFO)
|
|
||||||
|
|
||||||
// Additional settings have been added to the original set that you see with the $$ command
|
// Additional settings have been added to the original set that you see with the $$ command
|
||||||
// Some senders may not be able to parse anything different from the original set
|
// Some senders may not be able to parse anything different from the original set
|
||||||
@@ -565,30 +552,20 @@ const int DEBOUNCE_PERIOD = 32; // in milliseconds default 32 microseconds
|
|||||||
// Default is off to limit support issues...you can enable here or in your machine definition file
|
// Default is off to limit support issues...you can enable here or in your machine definition file
|
||||||
// #define SHOW_EXTENDED_SETTINGS
|
// #define SHOW_EXTENDED_SETTINGS
|
||||||
|
|
||||||
// Enable the '$I=(string)' build info write command. If disabled, any existing build info data must
|
// Writing to non-volatile storage (NVS) can take a long time and interfere with timely instruction
|
||||||
// be placed into EEPROM via external means with a valid checksum value. This macro option is useful
|
// execution, causing problems for the stepper ISRs and serial comm ISRs and subsequent loss of
|
||||||
// to prevent this data from being over-written by a user, when used to store OEM product data.
|
// stepper position and serial data. This configuration option forces the planner buffer to completely
|
||||||
// NOTE: If disabled and to ensure Grbl can never alter the build info line, you'll also need to enable
|
// empty whenever the NVS is written, to prevent any chance of lost steps.
|
||||||
// the SETTING_RESTORE_ALL macro above and remove SETTINGS_RESTORE_BUILD_INFO from the mask.
|
// It doesn't prevent loss of serial Rx data, especially if a GUI is premptively filling up the
|
||||||
// NOTE: See the included grblWrite_BuildInfo.ino example file to write this string seperately.
|
// serial Rx buffer. GUIs should detect GCodes that write to NVS - notably G10,G28.1,G30.1 -
|
||||||
#define ENABLE_BUILD_INFO_WRITE_COMMAND // '$I=' Default enabled. Comment to disable.
|
// and wait for an 'ok' before sending more data.
|
||||||
|
// NOTE: Most setting changes - $ commands - are blocked when a job is running. Coordinate setting
|
||||||
// AVR processors require all interrupts to be disabled during an EEPROM write. This includes both
|
// GCode commands (G10,G28/30.1) are not blocked, since they are part of an active streaming job.
|
||||||
// the stepper ISRs and serial comm ISRs. In the event of a long EEPROM write, this ISR pause can
|
// This option forces a planner buffer sync only with such GCode commands.
|
||||||
// cause active stepping to lose position and serial receive data to be lost. This configuration
|
#define FORCE_BUFFER_SYNC_DURING_NVS_WRITE // Default enabled. Comment to disable.
|
||||||
// option forces the planner buffer to completely empty whenever the EEPROM is written to prevent
|
|
||||||
// any chance of lost steps.
|
|
||||||
// However, this doesn't prevent issues with lost serial RX data during an EEPROM write, especially
|
|
||||||
// if a GUI is premptively filling up the serial RX buffer simultaneously. It's highly advised for
|
|
||||||
// GUIs to flag these gcodes (G10,G28.1,G30.1) to always wait for an 'ok' after a block containing
|
|
||||||
// one of these commands before sending more data to eliminate this issue.
|
|
||||||
// NOTE: Most EEPROM write commands are implicitly blocked during a job (all '$' commands). However,
|
|
||||||
// coordinate set g-code commands (G10,G28/30.1) are not, since they are part of an active streaming
|
|
||||||
// job. At this time, this option only forces a planner buffer sync with these g-code commands.
|
|
||||||
#define FORCE_BUFFER_SYNC_DURING_EEPROM_WRITE // Default enabled. Comment to disable.
|
|
||||||
|
|
||||||
// In Grbl v0.9 and prior, there is an old outstanding bug where the `WPos:` work position reported
|
// In Grbl v0.9 and prior, there is an old outstanding bug where the `WPos:` work position reported
|
||||||
// may not correlate to what is executing, because `WPos:` is based on the g-code parser state, which
|
// may not correlate to what is executing, because `WPos:` is based on the GCode parser state, which
|
||||||
// can be several motions behind. This option forces the planner buffer to empty, sync, and stop
|
// can be several motions behind. This option forces the planner buffer to empty, sync, and stop
|
||||||
// motion whenever there is a command that alters the work coordinate offsets `G10,G43.1,G92,G54-59`.
|
// motion whenever there is a command that alters the work coordinate offsets `G10,G43.1,G92,G54-59`.
|
||||||
// This is the simplest way to ensure `WPos:` is always correct. Fortunately, it's exceedingly rare
|
// This is the simplest way to ensure `WPos:` is always correct. Fortunately, it's exceedingly rare
|
||||||
@@ -624,8 +601,8 @@ const double PARKING_PULLOUT_INCREMENT = 5.0; // Spindle pull-out and plunge
|
|||||||
|
|
||||||
// Enables a special set of M-code commands that enables and disables the parking motion.
|
// Enables a special set of M-code commands that enables and disables the parking motion.
|
||||||
// These are controlled by `M56`, `M56 P1`, or `M56 Px` to enable and `M56 P0` to disable.
|
// These are controlled by `M56`, `M56 P1`, or `M56 Px` to enable and `M56 P0` to disable.
|
||||||
// The command is modal and will be set after a planner sync. Since it is g-code, it is
|
// The command is modal and will be set after a planner sync. Since it is GCode, it is
|
||||||
// executed in sync with g-code commands. It is not a real-time command.
|
// executed in sync with GCode commands. It is not a real-time command.
|
||||||
// NOTE: PARKING_ENABLE is required. By default, M56 is active upon initialization. Use
|
// NOTE: PARKING_ENABLE is required. By default, M56 is active upon initialization. Use
|
||||||
// DEACTIVATE_PARKING_UPON_INIT to set M56 P0 as the power-up default.
|
// DEACTIVATE_PARKING_UPON_INIT to set M56 P0 as the power-up default.
|
||||||
// #define ENABLE_PARKING_OVERRIDE_CONTROL // Default disabled. Uncomment to enable
|
// #define ENABLE_PARKING_OVERRIDE_CONTROL // Default disabled. Uncomment to enable
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Eeprom.cpp - Header for system level commands and real-time processes
|
Eeprom.cpp - Coordinate data stored in EEPROM
|
||||||
Part of Grbl
|
Part of Grbl
|
||||||
Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
|
Copyright (c) 2014-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||||
|
|
||||||
@@ -57,3 +57,25 @@ int memcpy_from_eeprom_with_checksum(char* destination, unsigned int source, uns
|
|||||||
}
|
}
|
||||||
return (checksum == EEPROM.read(source));
|
return (checksum == EEPROM.read(source));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read selected coordinate data from EEPROM. Updates pointed coord_data value.
|
||||||
|
// This is now a compatibility routine that is used to propagate coordinate data
|
||||||
|
// in the old EEPROM format to the new tagged NVS format.
|
||||||
|
bool old_settings_read_coord_data(uint8_t coord_select, float* coord_data) {
|
||||||
|
uint32_t addr = coord_select * (sizeof(float) * N_AXIS + 1) + EEPROM_ADDR_PARAMETERS;
|
||||||
|
if (!(memcpy_from_eeprom_with_old_checksum((char*)coord_data, addr, sizeof(float) * N_AXIS)) &&
|
||||||
|
!(memcpy_from_eeprom_with_checksum((char*)coord_data, addr, sizeof(float) * MAX_N_AXIS))) {
|
||||||
|
// Reset with default zero vector
|
||||||
|
clear_vector_float(coord_data);
|
||||||
|
// The old code used to rewrite the zeroed data but now that is done
|
||||||
|
// elsewhere, in a different format.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow iteration over CoordIndex values
|
||||||
|
CoordIndex& operator ++ (CoordIndex& i) {
|
||||||
|
i = static_cast<CoordIndex>(static_cast<uint8_t>(i) + 1);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
@@ -22,8 +22,40 @@
|
|||||||
|
|
||||||
#include "Grbl.h"
|
#include "Grbl.h"
|
||||||
|
|
||||||
|
// Define EEPROM memory address location values for saved coordinate data.
|
||||||
|
const int EEPROM_SIZE = 1024U;
|
||||||
|
const int EEPROM_ADDR_PARAMETERS = 512U;
|
||||||
|
|
||||||
//unsigned char eeprom_get_char(unsigned int addr);
|
//unsigned char eeprom_get_char(unsigned int addr);
|
||||||
//void eeprom_put_char(unsigned int addr, unsigned char new_value);
|
//void eeprom_put_char(unsigned int addr, unsigned char new_value);
|
||||||
void memcpy_to_eeprom_with_checksum(unsigned int destination, const char* source, unsigned int size);
|
void memcpy_to_eeprom_with_checksum(unsigned int destination, const char* source, unsigned int size);
|
||||||
int memcpy_from_eeprom_with_checksum(char* destination, unsigned int source, unsigned int size);
|
int memcpy_from_eeprom_with_checksum(char* destination, unsigned int source, unsigned int size);
|
||||||
int memcpy_from_eeprom_with_old_checksum(char* destination, unsigned int source, unsigned int size);
|
int memcpy_from_eeprom_with_old_checksum(char* destination, unsigned int source, unsigned int size);
|
||||||
|
|
||||||
|
// Reads selected coordinate data from EEPROM
|
||||||
|
bool old_settings_read_coord_data(uint8_t coord_select, float* coord_data);
|
||||||
|
|
||||||
|
// Various places in the code access saved coordinate system data
|
||||||
|
// by a small integer index according to the values below.
|
||||||
|
enum CoordIndex : uint8_t{
|
||||||
|
Begin = 0,
|
||||||
|
G54 = Begin,
|
||||||
|
G55,
|
||||||
|
G56,
|
||||||
|
G57,
|
||||||
|
G58,
|
||||||
|
G59,
|
||||||
|
// To support 9 work coordinate systems it would be necessary to define
|
||||||
|
// the following 3 and modify GCode.cpp to support G59.1, G59.2, G59.3
|
||||||
|
// G59_1,
|
||||||
|
// G59_2,
|
||||||
|
// G59_3,
|
||||||
|
NWCSystems,
|
||||||
|
G28 = NWCSystems,
|
||||||
|
G30,
|
||||||
|
// G92_2,
|
||||||
|
// G92_3,
|
||||||
|
End,
|
||||||
|
};
|
||||||
|
// Allow iteration over CoordIndex values
|
||||||
|
CoordIndex& operator ++ (CoordIndex& i);
|
||||||
|
@@ -873,10 +873,10 @@ Error gc_execute_line(char* line, uint8_t client) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// [15. Coordinate system selection ]: *N/A. Error, if cutter radius comp is active.
|
// [15. Coordinate system selection ]: *N/A. Error, if cutter radius comp is active.
|
||||||
// TODO: An EEPROM read of the coordinate data may require a buffer sync when the cycle
|
// TODO: Reading the coordinate data may require a buffer sync when the cycle
|
||||||
// is active. The read pauses the processor temporarily and may cause a rare crash. For
|
// is active. The read pauses the processor temporarily and may cause a rare crash. For
|
||||||
// future versions on processors with enough memory, all coordinate data should be stored
|
// future versions on processors with enough memory, all coordinate data should be stored
|
||||||
// in memory and written to EEPROM only when there is not a cycle active.
|
// in memory and written to non-volatile storage only when there is not a cycle active.
|
||||||
float block_coord_system[MAX_N_AXIS];
|
float block_coord_system[MAX_N_AXIS];
|
||||||
memcpy(block_coord_system, gc_state.coord_system, sizeof(gc_state.coord_system));
|
memcpy(block_coord_system, gc_state.coord_system, sizeof(gc_state.coord_system));
|
||||||
if (bit_istrue(command_words, bit(ModalGroup::MG12))) { // Check if called in block
|
if (bit_istrue(command_words, bit(ModalGroup::MG12))) { // Check if called in block
|
||||||
@@ -1002,7 +1002,7 @@ Error gc_execute_line(char* line, uint8_t client) {
|
|||||||
case NonModal::GoHome0: // G28
|
case NonModal::GoHome0: // G28
|
||||||
case NonModal::GoHome1: // G30
|
case NonModal::GoHome1: // G30
|
||||||
// [G28/30 Errors]: Cutter compensation is enabled.
|
// [G28/30 Errors]: Cutter compensation is enabled.
|
||||||
// Retreive G28/30 go-home position data (in machine coordinates) from EEPROM
|
// Retreive G28/30 go-home position data (in machine coordinates) from non-volatile storage
|
||||||
if (gc_block.non_modal_command == NonModal::GoHome0) {
|
if (gc_block.non_modal_command == NonModal::GoHome0) {
|
||||||
coords[CoordIndex::G28]->get(coord_data);
|
coords[CoordIndex::G28]->get(coord_data);
|
||||||
} else { // == NonModal::GoHome1
|
} else { // == NonModal::GoHome1
|
||||||
|
@@ -286,7 +286,7 @@ typedef struct {
|
|||||||
float position[MAX_N_AXIS]; // Where the interpreter considers the tool to be at this point in the code
|
float position[MAX_N_AXIS]; // Where the interpreter considers the tool to be at this point in the code
|
||||||
|
|
||||||
float coord_system[MAX_N_AXIS]; // Current work coordinate system (G54+). Stores offset from absolute machine
|
float coord_system[MAX_N_AXIS]; // Current work coordinate system (G54+). Stores offset from absolute machine
|
||||||
// position in mm. Loaded from EEPROM when called.
|
// position in mm. Loaded from non-volatile storage when called.
|
||||||
float coord_offset[MAX_N_AXIS]; // Retains the G92 coordinate offset (work coordinates) relative to
|
float coord_offset[MAX_N_AXIS]; // Retains the G92 coordinate offset (work coordinates) relative to
|
||||||
// machine zero in mm. Non-persistent. Cleared upon reset and boot.
|
// machine zero in mm. Non-persistent. Cleared upon reset and boot.
|
||||||
float tool_length_offset; // Tracks tool length offset value when enabled.
|
float tool_length_offset; // Tracks tool length offset value when enabled.
|
||||||
|
@@ -37,7 +37,7 @@ void grbl_init() {
|
|||||||
#ifdef MACHINE_NAME
|
#ifdef MACHINE_NAME
|
||||||
report_machine_type(CLIENT_SERIAL);
|
report_machine_type(CLIENT_SERIAL);
|
||||||
#endif
|
#endif
|
||||||
settings_init(); // Load Grbl settings from EEPROM
|
settings_init(); // Load Grbl settings from non-volatile storage
|
||||||
stepper_init(); // Configure stepper pins and interrupt timers
|
stepper_init(); // Configure stepper pins and interrupt timers
|
||||||
init_motors();
|
init_motors();
|
||||||
system_ini(); // Configure pinout pins and pin-change interrupt (Renamed due to conflict with esp32 files)
|
system_ini(); // Configure pinout pins and pin-change interrupt (Renamed due to conflict with esp32 files)
|
||||||
|
@@ -41,14 +41,13 @@ const char* const GRBL_VERSION_BUILD = "20201004";
|
|||||||
|
|
||||||
#include "Defaults.h"
|
#include "Defaults.h"
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
#include "SettingsStorage.h"
|
#include "Eeprom.h"
|
||||||
#include "WebUI/Authentication.h"
|
#include "WebUI/Authentication.h"
|
||||||
#include "WebUI/Commands.h"
|
#include "WebUI/Commands.h"
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
|
|
||||||
#include "GCode.h"
|
#include "GCode.h"
|
||||||
#include "Planner.h"
|
#include "Planner.h"
|
||||||
#include "Eeprom.h"
|
|
||||||
#include "CoolantControl.h"
|
#include "CoolantControl.h"
|
||||||
#include "Limits.h"
|
#include "Limits.h"
|
||||||
#include "MotionControl.h"
|
#include "MotionControl.h"
|
||||||
|
@@ -113,10 +113,10 @@ void limits_go_home(uint8_t cycle_mask) {
|
|||||||
|
|
||||||
for (uint8_t idx = 0; idx < n_axis; idx++) {
|
for (uint8_t idx = 0; idx < n_axis; idx++) {
|
||||||
// Initialize step pin masks
|
// Initialize step pin masks
|
||||||
step_pin[idx] = get_step_pin_mask(idx);
|
step_pin[idx] = bit(idx);
|
||||||
#ifdef COREXY
|
#ifdef COREXY
|
||||||
if ((idx == A_MOTOR) || (idx == B_MOTOR)) {
|
if ((idx == A_MOTOR) || (idx == B_MOTOR)) {
|
||||||
step_pin[idx] = (get_step_pin_mask(X_AXIS) | get_step_pin_mask(Y_AXIS));
|
step_pin[idx] = (bit(X_AXIS) | bit(Y_AXIS));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (bit_istrue(cycle_mask, bit(idx))) {
|
if (bit_istrue(cycle_mask, bit(idx))) {
|
||||||
|
@@ -140,8 +140,8 @@
|
|||||||
|
|
||||||
// === Default settings
|
// === Default settings
|
||||||
// Grbl has many run-time settings that the user can changed by
|
// Grbl has many run-time settings that the user can changed by
|
||||||
// commands like $110=2000 . Their values are stored in EEPROM
|
// commands like $110=2000 . Their values are stored in non-volatile
|
||||||
// so they persist after the controller has been powered down.
|
// storage so they persist after the controller has been powered down.
|
||||||
// Those settings have default values that are used if the user
|
// Those settings have default values that are used if the user
|
||||||
// has not altered them, or if the settings are explicitly reset
|
// has not altered them, or if the settings are explicitly reset
|
||||||
// to the default values wth $RST=$.
|
// to the default values wth $RST=$.
|
||||||
|
@@ -358,7 +358,7 @@ uint8_t plan_buffer_line(float* target, plan_line_data_t* pl_data) {
|
|||||||
unit_vec[idx] = delta_mm; // Store unit vector numerator
|
unit_vec[idx] = delta_mm; // Store unit vector numerator
|
||||||
// Set direction bits. Bit enabled always means direction is negative.
|
// Set direction bits. Bit enabled always means direction is negative.
|
||||||
if (delta_mm < 0.0) {
|
if (delta_mm < 0.0) {
|
||||||
block->direction_bits |= get_direction_pin_mask(idx);
|
block->direction_bits |= bit(idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Bail if this is a zero-length block. Highly unlikely to occur.
|
// Bail if this is a zero-length block. Highly unlikely to occur.
|
||||||
|
@@ -33,7 +33,7 @@ void show_setting(const char* name, const char* value, const char* description,
|
|||||||
|
|
||||||
void settings_restore(uint8_t restore_flag) {
|
void settings_restore(uint8_t restore_flag) {
|
||||||
#ifdef WIFI_OR_BLUETOOTH
|
#ifdef WIFI_OR_BLUETOOTH
|
||||||
if (restore_flag & SETTINGS_RESTORE_WIFI_SETTINGS) {
|
if (restore_flag & SettingsRestore::Wifi) {
|
||||||
# ifdef ENABLE_WIFI
|
# ifdef ENABLE_WIFI
|
||||||
WebUI::wifi_config.reset_settings();
|
WebUI::wifi_config.reset_settings();
|
||||||
# endif
|
# endif
|
||||||
@@ -42,8 +42,8 @@ void settings_restore(uint8_t restore_flag) {
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (restore_flag & SETTINGS_RESTORE_DEFAULTS) {
|
if (restore_flag & SettingsRestore::Defaults) {
|
||||||
bool restore_startup = restore_flag & SETTINGS_RESTORE_STARTUP_LINES;
|
bool restore_startup = restore_flag & SettingsRestore::StartupLines;
|
||||||
for (Setting* s = Setting::List; s; s = s->next()) {
|
for (Setting* s = Setting::List; s; s = s->next()) {
|
||||||
if (!s->getDescription()) {
|
if (!s->getDescription()) {
|
||||||
const char* name = s->getName();
|
const char* name = s->getName();
|
||||||
@@ -55,16 +55,11 @@ void settings_restore(uint8_t restore_flag) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (restore_flag & SETTINGS_RESTORE_PARAMETERS) {
|
if (restore_flag & SettingsRestore::Parameters) {
|
||||||
for (auto idx = CoordIndex::Begin; idx < CoordIndex::End; ++idx) {
|
for (auto idx = CoordIndex::Begin; idx < CoordIndex::End; ++idx) {
|
||||||
coords[idx]->setDefault();
|
coords[idx]->setDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (restore_flag & SETTINGS_RESTORE_BUILD_INFO) {
|
|
||||||
EEPROM.write(EEPROM_ADDR_BUILD_INFO, 0);
|
|
||||||
EEPROM.write(EEPROM_ADDR_BUILD_INFO + 1, 0); // Checksum
|
|
||||||
EEPROM.commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get settings values from non volatile storage into memory
|
// Get settings values from non volatile storage into memory
|
||||||
@@ -277,17 +272,10 @@ Error sleep_grbl(const char* value, WebUI::AuthenticationLevel auth_level, WebUI
|
|||||||
}
|
}
|
||||||
Error get_report_build_info(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
Error get_report_build_info(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
char line[128];
|
report_build_info(build_info->get(), out->client());
|
||||||
settings_read_build_info(line);
|
|
||||||
report_build_info(line, out->client());
|
|
||||||
return Error::Ok;
|
return Error::Ok;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_BUILD_INFO_WRITE_COMMAND
|
|
||||||
settings_store_build_info(value);
|
|
||||||
return Error::Ok;
|
|
||||||
#else
|
|
||||||
return Error::InvalidStatement;
|
return Error::InvalidStatement;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
Error report_startup_lines(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
Error report_startup_lines(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
||||||
report_startup_line(0, startup_line_0->get(), out->client());
|
report_startup_line(0, startup_line_0->get(), out->client());
|
||||||
@@ -296,16 +284,16 @@ Error report_startup_lines(const char* value, WebUI::AuthenticationLevel auth_le
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::map<const char*, uint8_t, cmp_str> restoreCommands = {
|
std::map<const char*, uint8_t, cmp_str> restoreCommands = {
|
||||||
#ifdef ENABLE_RESTORE_EEPROM_DEFAULT_SETTINGS
|
#ifdef ENABLE_RESTORE_DEFAULT_SETTINGS
|
||||||
{ "$", SETTINGS_RESTORE_DEFAULTS }, { "settings", SETTINGS_RESTORE_DEFAULTS },
|
{ "$", SettingsRestore::Defaults }, { "settings", SettingsRestore::Defaults },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_RESTORE_EEPROM_CLEAR_PARAMETERS
|
#ifdef ENABLE_RESTORE_CLEAR_PARAMETERS
|
||||||
{ "#", SETTINGS_RESTORE_PARAMETERS }, { "gcode", SETTINGS_RESTORE_PARAMETERS },
|
{ "#", SettingsRestore::Parameters }, { "gcode", SettingsRestore::Parameters },
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_RESTORE_EEPROM_WIPE_ALL
|
#ifdef ENABLE_RESTORE_WIPE_ALL
|
||||||
{ "*", SETTINGS_RESTORE_ALL }, { "all", SETTINGS_RESTORE_ALL },
|
{ "*", SettingsRestore::All }, { "all", SettingsRestore::All },
|
||||||
#endif
|
#endif
|
||||||
{ "@", SETTINGS_RESTORE_WIFI_SETTINGS }, { "wifi", SETTINGS_RESTORE_WIFI_SETTINGS },
|
{ "@", SettingsRestore::Wifi }, { "wifi", SettingsRestore::Wifi },
|
||||||
};
|
};
|
||||||
Error restore_settings(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
Error restore_settings(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
@@ -513,69 +513,56 @@ void report_execute_startup_message(const char* line, Error status_code, uint8_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prints build info line
|
// Prints build info line
|
||||||
void report_build_info(char* line, uint8_t client) {
|
void report_build_info(const char* line, uint8_t client) {
|
||||||
char build_info[50];
|
grbl_sendf(client, "[VER:%s.%s:%s]\r\n[OPT:", GRBL_VERSION, GRBL_VERSION_BUILD, line);
|
||||||
strcpy(build_info, "[VER:");
|
|
||||||
strcat(build_info, GRBL_VERSION);
|
|
||||||
strcat(build_info, ".");
|
|
||||||
strcat(build_info, GRBL_VERSION_BUILD);
|
|
||||||
strcat(build_info, ":");
|
|
||||||
strcat(build_info, line);
|
|
||||||
strcat(build_info, "]\r\n[OPT:");
|
|
||||||
strcat(build_info, "V"); // variable spindle..always on now
|
|
||||||
strcat(build_info, "N");
|
|
||||||
#ifdef COOLANT_MIST_PIN
|
#ifdef COOLANT_MIST_PIN
|
||||||
strcat(build_info, "M"); // TODO Need to deal with M8...it could be disabled
|
grbl_send(client, "M"); // TODO Need to deal with M8...it could be disabled
|
||||||
#endif
|
#endif
|
||||||
#ifdef COREXY
|
#ifdef COREXY
|
||||||
strcat(build_info, "C");
|
grbl_send(client, "C");
|
||||||
#endif
|
#endif
|
||||||
#ifdef PARKING_ENABLE
|
#ifdef PARKING_ENABLE
|
||||||
strcat(build_info, "P");
|
grbl_send(client, "P");
|
||||||
#endif
|
#endif
|
||||||
#ifdef HOMING_SINGLE_AXIS_COMMANDS
|
#ifdef HOMING_SINGLE_AXIS_COMMANDS
|
||||||
strcat(build_info, "H");
|
grbl_send(client, "H");
|
||||||
#endif
|
#endif
|
||||||
#ifdef LIMITS_TWO_SWITCHES_ON_AXES
|
#ifdef LIMITS_TWO_SWITCHES_ON_AXES
|
||||||
strcat(build_info, "L");
|
grbl_send(client, "L");
|
||||||
#endif
|
#endif
|
||||||
#ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES
|
#ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES
|
||||||
strcat(build_info, "A");
|
grbl_send(client, "A");
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_BLUETOOTH
|
#ifdef ENABLE_BLUETOOTH
|
||||||
strcat(build_info, "B");
|
grbl_send(client, "B");
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_SD_CARD
|
#ifdef ENABLE_SD_CARD
|
||||||
strcat(build_info, "S");
|
grbl_send(client, "S");
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
|
||||||
serial_write('R');
|
grbl_send(client, "R");
|
||||||
#endif
|
#endif
|
||||||
#if defined(ENABLE_WIFI)
|
#if defined(ENABLE_WIFI)
|
||||||
strcat(build_info, "W");
|
grbl_send(client, "W");
|
||||||
#endif
|
#endif
|
||||||
#ifndef ENABLE_RESTORE_EEPROM_WIPE_ALL // NOTE: Shown when disabled.
|
#ifndef ENABLE_RESTORE_WIPE_ALL // NOTE: Shown when disabled.
|
||||||
strcat(build_info, "*");
|
grbl_send(client, "*");
|
||||||
#endif
|
#endif
|
||||||
#ifndef ENABLE_RESTORE_EEPROM_DEFAULT_SETTINGS // NOTE: Shown when disabled.
|
#ifndef ENABLE_RESTORE_DEFAULT_SETTINGS // NOTE: Shown when disabled.
|
||||||
strcat(build_info, "$");
|
grbl_send(client, "$");
|
||||||
#endif
|
#endif
|
||||||
#ifndef ENABLE_RESTORE_EEPROM_CLEAR_PARAMETERS // NOTE: Shown when disabled.
|
#ifndef ENABLE_RESTORE_CLEAR_PARAMETERS // NOTE: Shown when disabled.
|
||||||
strcat(build_info, "#");
|
grbl_send(client, "#");
|
||||||
#endif
|
#endif
|
||||||
#ifndef ENABLE_BUILD_INFO_WRITE_COMMAND // NOTE: Shown when disabled.
|
#ifndef FORCE_BUFFER_SYNC_DURING_NVS_WRITE // NOTE: Shown when disabled.
|
||||||
strcat(build_info, "I");
|
grbl_send(client, "E");
|
||||||
#endif
|
|
||||||
#ifndef FORCE_BUFFER_SYNC_DURING_EEPROM_WRITE // NOTE: Shown when disabled.
|
|
||||||
strcat(build_info, "E");
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef FORCE_BUFFER_SYNC_DURING_WCO_CHANGE // NOTE: Shown when disabled.
|
#ifndef FORCE_BUFFER_SYNC_DURING_WCO_CHANGE // NOTE: Shown when disabled.
|
||||||
strcat(build_info, "W");
|
grbl_send(client, "W");
|
||||||
#endif
|
#endif
|
||||||
// NOTE: Compiled values, like override increments/max/min values, may be added at some point later.
|
// NOTE: Compiled values, like override increments/max/min values, may be added at some point later.
|
||||||
// These will likely have a comma delimiter to separate them.
|
// These will likely have a comma delimiter to separate them.
|
||||||
strcat(build_info, "]\r\n");
|
grbl_send(client, "]\r\n");
|
||||||
grbl_send(client, build_info); // ok to send to all
|
|
||||||
report_machine_type(client);
|
report_machine_type(client);
|
||||||
#if defined(ENABLE_WIFI)
|
#if defined(ENABLE_WIFI)
|
||||||
grbl_send(client, (char*)WebUI::wifi_config.info());
|
grbl_send(client, (char*)WebUI::wifi_config.info());
|
||||||
@@ -657,7 +644,7 @@ void report_realtime_status(uint8_t client) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
float wco[MAX_N_AXIS];
|
float wco[MAX_N_AXIS];
|
||||||
if (bit_isfalse(status_mask->get(), BITFLAG_RT_STATUS_POSITION_TYPE) || (sys.report_wco_counter == 0)) {
|
if (bit_isfalse(status_mask->get(), RtStatus::Position) || (sys.report_wco_counter == 0)) {
|
||||||
auto n_axis = number_axis->get();
|
auto n_axis = number_axis->get();
|
||||||
for (idx = 0; idx < n_axis; idx++) {
|
for (idx = 0; idx < n_axis; idx++) {
|
||||||
// Apply work coordinate offsets and tool length offset to current position.
|
// Apply work coordinate offsets and tool length offset to current position.
|
||||||
@@ -665,13 +652,13 @@ void report_realtime_status(uint8_t client) {
|
|||||||
if (idx == TOOL_LENGTH_OFFSET_AXIS) {
|
if (idx == TOOL_LENGTH_OFFSET_AXIS) {
|
||||||
wco[idx] += gc_state.tool_length_offset;
|
wco[idx] += gc_state.tool_length_offset;
|
||||||
}
|
}
|
||||||
if (bit_isfalse(status_mask->get(), BITFLAG_RT_STATUS_POSITION_TYPE)) {
|
if (bit_isfalse(status_mask->get(), RtStatus::Position)) {
|
||||||
print_position[idx] -= wco[idx];
|
print_position[idx] -= wco[idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Report machine position
|
// Report machine position
|
||||||
if (bit_istrue(status_mask->get(), BITFLAG_RT_STATUS_POSITION_TYPE)) {
|
if (bit_istrue(status_mask->get(), RtStatus::Position)) {
|
||||||
strcat(status, "|MPos:");
|
strcat(status, "|MPos:");
|
||||||
} else {
|
} else {
|
||||||
#ifdef USE_FWD_KINEMATICS
|
#ifdef USE_FWD_KINEMATICS
|
||||||
@@ -683,7 +670,7 @@ void report_realtime_status(uint8_t client) {
|
|||||||
strcat(status, temp);
|
strcat(status, temp);
|
||||||
// Returns planner and serial read buffer states.
|
// Returns planner and serial read buffer states.
|
||||||
#ifdef REPORT_FIELD_BUFFER_STATE
|
#ifdef REPORT_FIELD_BUFFER_STATE
|
||||||
if (bit_istrue(status_mask->get(), BITFLAG_RT_STATUS_BUFFER_STATE)) {
|
if (bit_istrue(status_mask->get(), RtStatus::Buffer)) {
|
||||||
int bufsize = DEFAULTBUFFERSIZE;
|
int bufsize = DEFAULTBUFFERSIZE;
|
||||||
# if defined(ENABLE_WIFI) && defined(ENABLE_TELNET)
|
# if defined(ENABLE_WIFI) && defined(ENABLE_TELNET)
|
||||||
if (client == CLIENT_TELNET) {
|
if (client == CLIENT_TELNET) {
|
||||||
|
@@ -20,6 +20,12 @@
|
|||||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Define status reporting boolean enable bit flags in status_report_mask
|
||||||
|
enum RtStatus {
|
||||||
|
Position = bit(0),
|
||||||
|
Buffer = bit(1),
|
||||||
|
};
|
||||||
|
|
||||||
const char* errorString(Error errorNumber);
|
const char* errorString(Error errorNumber);
|
||||||
|
|
||||||
// Define Grbl feedback message codes. Valid values (0-255).
|
// Define Grbl feedback message codes. Valid values (0-255).
|
||||||
@@ -103,7 +109,7 @@ void report_startup_line(uint8_t n, const char* line, uint8_t client);
|
|||||||
void report_execute_startup_message(const char* line, Error status_code, uint8_t client);
|
void report_execute_startup_message(const char* line, Error status_code, uint8_t client);
|
||||||
|
|
||||||
// Prints build info and user info
|
// Prints build info and user info
|
||||||
void report_build_info(char* line, uint8_t client);
|
void report_build_info(const char* line, uint8_t client);
|
||||||
|
|
||||||
void report_gcode_comment(char* comment);
|
void report_gcode_comment(char* comment);
|
||||||
|
|
||||||
|
@@ -718,7 +718,7 @@ bool Coordinates::load() {
|
|||||||
|
|
||||||
void Coordinates::set(float value[MAX_N_AXIS]) {
|
void Coordinates::set(float value[MAX_N_AXIS]) {
|
||||||
memcpy(&_currentValue, value, sizeof(_currentValue));
|
memcpy(&_currentValue, value, sizeof(_currentValue));
|
||||||
#ifdef FORCE_BUFFER_SYNC_DURING_EEPROM_WRITE
|
#ifdef FORCE_BUFFER_SYNC_DURING_NVS_WRITE
|
||||||
protocol_buffer_synchronize();
|
protocol_buffer_synchronize();
|
||||||
#endif
|
#endif
|
||||||
nvs_set_blob(Setting::_handle, _name, _currentValue, sizeof(_currentValue));
|
nvs_set_blob(Setting::_handle, _name, _currentValue, sizeof(_currentValue));
|
||||||
|
@@ -5,6 +5,22 @@
|
|||||||
#include <nvs.h>
|
#include <nvs.h>
|
||||||
#include "WebUI/ESPResponse.h"
|
#include "WebUI/ESPResponse.h"
|
||||||
|
|
||||||
|
// Initialize the configuration subsystem
|
||||||
|
void settings_init();
|
||||||
|
|
||||||
|
// Define settings restore bitflags.
|
||||||
|
enum SettingsRestore {
|
||||||
|
Defaults = bit(0),
|
||||||
|
Parameters = bit(1),
|
||||||
|
StartupLines = bit(2),
|
||||||
|
// BuildInfo = bit(3), // Obsolete
|
||||||
|
Wifi = bit(4),
|
||||||
|
All = 0xff,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Restore subsets of settings to default values
|
||||||
|
void settings_restore(uint8_t restore_flag);
|
||||||
|
|
||||||
// Command::List is a linked list of all settings,
|
// Command::List is a linked list of all settings,
|
||||||
// so common code can enumerate them.
|
// so common code can enumerate them.
|
||||||
class Command;
|
class Command;
|
||||||
|
@@ -359,6 +359,7 @@ void make_settings() {
|
|||||||
hard_limits = new FlagSetting(GRBL, WG, "21", "Limits/Hard", DEFAULT_HARD_LIMIT_ENABLE);
|
hard_limits = new FlagSetting(GRBL, WG, "21", "Limits/Hard", DEFAULT_HARD_LIMIT_ENABLE);
|
||||||
soft_limits = new FlagSetting(GRBL, WG, "20", "Limits/Soft", DEFAULT_SOFT_LIMIT_ENABLE, NULL);
|
soft_limits = new FlagSetting(GRBL, WG, "20", "Limits/Soft", DEFAULT_SOFT_LIMIT_ENABLE, NULL);
|
||||||
|
|
||||||
|
build_info = new StringSetting(EXTENDED, WG, NULL, "Firmware/Build", "");
|
||||||
report_inches = new FlagSetting(GRBL, WG, "13", "Report/Inches", DEFAULT_REPORT_INCHES);
|
report_inches = new FlagSetting(GRBL, WG, "13", "Report/Inches", DEFAULT_REPORT_INCHES);
|
||||||
// TODO Settings - also need to clear, but not set, soft_limits
|
// TODO Settings - also need to clear, but not set, soft_limits
|
||||||
arc_tolerance = new FloatSetting(GRBL, WG, "12", "GCode/ArcTolerance", DEFAULT_ARC_TOLERANCE, 0, 1);
|
arc_tolerance = new FloatSetting(GRBL, WG, "12", "GCode/ArcTolerance", DEFAULT_ARC_TOLERANCE, 0, 1);
|
||||||
|
@@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
SettingsStorage.cpp - EEPROM configuration handling
|
|
||||||
Part of Grbl
|
|
||||||
|
|
||||||
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
|
|
||||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
|
||||||
|
|
||||||
2018 - Bart Dring This file was modifed for use on the ESP32
|
|
||||||
CPU. Do not use this with Grbl for atMega328P
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Grbl.h"
|
|
||||||
|
|
||||||
// Read selected coordinate data from EEPROM. Updates pointed coord_data value.
|
|
||||||
// This is now a compatibility routine that is used to propagate coordinate data
|
|
||||||
// in the old EEPROM format to the new tagged NVS format.
|
|
||||||
bool old_settings_read_coord_data(uint8_t coord_select, float* coord_data) {
|
|
||||||
uint32_t addr = coord_select * (sizeof(float) * N_AXIS + 1) + EEPROM_ADDR_PARAMETERS;
|
|
||||||
if (!(memcpy_from_eeprom_with_old_checksum((char*)coord_data, addr, sizeof(float) * N_AXIS)) &&
|
|
||||||
!(memcpy_from_eeprom_with_checksum((char*)coord_data, addr, sizeof(float) * MAX_N_AXIS))) {
|
|
||||||
// Reset with default zero vector
|
|
||||||
clear_vector_float(coord_data);
|
|
||||||
// The old code used to rewrite the zeroed data but now that is done
|
|
||||||
// elsewhere, in a different format.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Method to store build info into EEPROM
|
|
||||||
// NOTE: This function can only be called in IDLE state.
|
|
||||||
void settings_store_build_info(const char* line) {
|
|
||||||
// Build info can only be stored when state is IDLE.
|
|
||||||
memcpy_to_eeprom_with_checksum(EEPROM_ADDR_BUILD_INFO, (char*)line, LINE_BUFFER_SIZE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reads startup line from EEPROM. Updated pointed line string data.
|
|
||||||
uint8_t settings_read_build_info(char* line) {
|
|
||||||
if (!(memcpy_from_eeprom_with_checksum((char*)line, EEPROM_ADDR_BUILD_INFO, LINE_BUFFER_SIZE))) {
|
|
||||||
// Reset line with default value
|
|
||||||
line[0] = 0; // Empty line
|
|
||||||
settings_store_build_info(line);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns step pin mask according to Grbl internal axis indexing.
|
|
||||||
uint8_t get_step_pin_mask(uint8_t axis_idx) {
|
|
||||||
// todo clean this up further up stream
|
|
||||||
return bit(axis_idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns direction pin mask according to Grbl internal axis indexing.
|
|
||||||
uint8_t get_direction_pin_mask(uint8_t axis_idx) {
|
|
||||||
return bit(axis_idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow iteration over CoordIndex values
|
|
||||||
CoordIndex& operator ++ (CoordIndex& i) {
|
|
||||||
i = static_cast<CoordIndex>(static_cast<uint8_t>(i) + 1);
|
|
||||||
return i;
|
|
||||||
}
|
|
@@ -1,92 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
/*
|
|
||||||
SettingsStorage.h - eeprom configuration handling
|
|
||||||
Part of Grbl
|
|
||||||
|
|
||||||
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
|
|
||||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
|
||||||
|
|
||||||
2018 - Bart Dring This file was modifed for use on the ESP32
|
|
||||||
CPU. Do not use this with Grbl for atMega328P
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Grbl.h"
|
|
||||||
|
|
||||||
// Define status reporting boolean enable bit flags in status_report_mask
|
|
||||||
#define BITFLAG_RT_STATUS_POSITION_TYPE bit(0)
|
|
||||||
#define BITFLAG_RT_STATUS_BUFFER_STATE bit(1)
|
|
||||||
|
|
||||||
// Define settings restore 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 SETTINGS_RESTORE_WIFI_SETTINGS bit(4)
|
|
||||||
#ifndef SETTINGS_RESTORE_ALL
|
|
||||||
# define SETTINGS_RESTORE_ALL 0xFF // All bitflags
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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
|
|
||||||
// developments.
|
|
||||||
const int EEPROM_SIZE = 1024U;
|
|
||||||
const int EEPROM_ADDR_PARAMETERS = 512U;
|
|
||||||
const int EEPROM_ADDR_BUILD_INFO = 942U;
|
|
||||||
|
|
||||||
// Initialize the configuration subsystem (load settings from EEPROM)
|
|
||||||
void settings_init();
|
|
||||||
void settings_restore(uint8_t restore_flag);
|
|
||||||
void write_global_settings();
|
|
||||||
|
|
||||||
uint8_t settings_read_build_info(char* line);
|
|
||||||
void settings_store_build_info(const char* line);
|
|
||||||
|
|
||||||
// Reads selected coordinate data from EEPROM
|
|
||||||
bool old_settings_read_coord_data(uint8_t coord_select, float* coord_data);
|
|
||||||
|
|
||||||
// Returns the step pin mask according to Grbl's internal axis numbering
|
|
||||||
uint8_t get_step_pin_mask(uint8_t i);
|
|
||||||
|
|
||||||
// Returns the direction pin mask according to Grbl's internal axis numbering
|
|
||||||
uint8_t get_direction_pin_mask(uint8_t i);
|
|
||||||
|
|
||||||
// Various places in the code access saved coordinate system data
|
|
||||||
// by a small integer index according to the values below.
|
|
||||||
enum CoordIndex : uint8_t{
|
|
||||||
Begin = 0,
|
|
||||||
G54 = Begin,
|
|
||||||
G55,
|
|
||||||
G56,
|
|
||||||
G57,
|
|
||||||
G58,
|
|
||||||
G59,
|
|
||||||
// To support 9 work coordinate systems it would be necessary to define
|
|
||||||
// the following 3 and modify GCode.cpp to support G59.1, G59.2, G59.3
|
|
||||||
// G59_1,
|
|
||||||
// G59_2,
|
|
||||||
// G59_3,
|
|
||||||
NWCSystems,
|
|
||||||
G28 = NWCSystems,
|
|
||||||
G30,
|
|
||||||
// G92_2,
|
|
||||||
// G92_3,
|
|
||||||
End,
|
|
||||||
};
|
|
||||||
// Allow iteration over CoordIndex values
|
|
||||||
CoordIndex& operator ++ (CoordIndex& i);
|
|
||||||
|
|
@@ -75,7 +75,8 @@ like to have. For example:
|
|||||||
If you want to query the current [running] status, that's
|
If you want to query the current [running] status, that's
|
||||||
command 0x3000, and the status is 1 byte, so you might as
|
command 0x3000, and the status is 1 byte, so you might as
|
||||||
well add `0001` as parameter. There are exceptions here,
|
well add `0001` as parameter. There are exceptions here,
|
||||||
obviously when writing data to the EEPROM or the speed.
|
such as when writing data to non-volatile storage or
|
||||||
|
changing the speed.
|
||||||
|
|
||||||
I hereby list the most important command sequences, and how
|
I hereby list the most important command sequences, and how
|
||||||
they work:
|
they work:
|
||||||
|
@@ -190,7 +190,7 @@ void system_set_exec_accessory_override_flag(uint8_t mask);
|
|||||||
void system_clear_exec_motion_overrides();
|
void system_clear_exec_motion_overrides();
|
||||||
void system_clear_exec_accessory_overrides();
|
void system_clear_exec_accessory_overrides();
|
||||||
|
|
||||||
// Execute the startup script lines stored in EEPROM upon initialization
|
// Execute the startup script lines stored in non-volatile storage upon initialization
|
||||||
void system_execute_startup(char* line);
|
void system_execute_startup(char* line);
|
||||||
Error execute_line(char* line, uint8_t client, WebUI::AuthenticationLevel auth_level);
|
Error execute_line(char* line, uint8_t client, WebUI::AuthenticationLevel auth_level);
|
||||||
Error system_execute_line(char* line, WebUI::ESPResponseStream*, WebUI::AuthenticationLevel);
|
Error system_execute_line(char* line, WebUI::ESPResponseStream*, WebUI::AuthenticationLevel);
|
||||||
|
Reference in New Issue
Block a user