mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-01 02:21:46 +02:00
Factor and reorder init
mainly so the pin messages all come before the WiFi connect dance.
This commit is contained in:
@@ -91,6 +91,10 @@ void grbl_init() {
|
||||
}
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Initializing spindle...");
|
||||
|
||||
config->_coolant->init();
|
||||
limits_init();
|
||||
config->_probe->init();
|
||||
|
||||
#ifdef ENABLE_WIFI
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Initializing WiFi-config...");
|
||||
WebUI::wifi_config.begin();
|
||||
@@ -113,37 +117,11 @@ void grbl_init() {
|
||||
}
|
||||
|
||||
static void reset_variables() {
|
||||
// Reset system variables.
|
||||
State prior_state = sys.state;
|
||||
memset(&sys, 0, sizeof(system_t)); // Clear system struct variable.
|
||||
sys.state = prior_state;
|
||||
sys.f_override = FeedOverride::Default; // Set to 100%
|
||||
sys.r_override = RapidOverride::Default; // Set to 100%
|
||||
sys.spindle_speed_ovr = SpindleSpeedOverride::Default; // Set to 100%
|
||||
memset(sys_probe_position, 0, sizeof(sys_probe_position)); // Clear probe position.
|
||||
|
||||
sys_probe_state = ProbeState::Off;
|
||||
rtStatusReport = false;
|
||||
rtCycleStart = false;
|
||||
rtFeedHold = false;
|
||||
rtReset = false;
|
||||
rtSafetyDoor = false;
|
||||
rtMotionCancel = false;
|
||||
rtSleep = false;
|
||||
rtCycleStop = false;
|
||||
sys_rt_exec_accessory_override.value = 0;
|
||||
sys_rt_exec_alarm = ExecAlarm::None;
|
||||
sys_rt_f_override = FeedOverride::Default;
|
||||
sys_rt_r_override = RapidOverride::Default;
|
||||
sys_rt_s_override = SpindleSpeedOverride::Default;
|
||||
|
||||
// Reset Grbl primary systems.
|
||||
client_reset_read_buffer(CLIENT_ALL); // Clear serial read buffer
|
||||
gc_init(); // Set g-code parser to default state
|
||||
system_reset();
|
||||
protocol_reset();
|
||||
gc_init(); // Set g-code parser to default state
|
||||
config->_spindle->stop();
|
||||
config->_coolant->init();
|
||||
limits_init();
|
||||
config->_probe->init();
|
||||
plan_reset(); // Clear block buffer and planner variables
|
||||
st_reset(); // Clear stepper subsystem variables
|
||||
// Sync cleared gcode and planner positions to current system position.
|
||||
|
@@ -101,6 +101,23 @@ bool can_park() {
|
||||
homingAxes() && !config->_laserMode;
|
||||
}
|
||||
|
||||
void protocol_reset() {
|
||||
sys_probe_state = ProbeState::Off;
|
||||
rtStatusReport = false;
|
||||
rtCycleStart = false;
|
||||
rtFeedHold = false;
|
||||
rtReset = false;
|
||||
rtSafetyDoor = false;
|
||||
rtMotionCancel = false;
|
||||
rtSleep = false;
|
||||
rtCycleStop = false;
|
||||
sys_rt_exec_accessory_override.value = 0;
|
||||
sys_rt_exec_alarm = ExecAlarm::None;
|
||||
sys_rt_f_override = FeedOverride::Default;
|
||||
sys_rt_r_override = RapidOverride::Default;
|
||||
sys_rt_s_override = SpindleSpeedOverride::Default;
|
||||
}
|
||||
|
||||
/*
|
||||
GRBL PRIMARY LOOP:
|
||||
*/
|
||||
|
@@ -34,6 +34,8 @@
|
||||
# define LINE_BUFFER_SIZE 256
|
||||
#endif
|
||||
|
||||
void protocol_reset();
|
||||
|
||||
// Starts Grbl main loop. It handles all incoming characters from the serial port and executes
|
||||
// them as they complete. It is also responsible for finishing the initialization procedures.
|
||||
void protocol_main_loop();
|
||||
|
@@ -57,6 +57,17 @@ UserOutput::DigitalOutput* myDigitalOutputs[MaxUserDigitalPin];
|
||||
xQueueHandle control_sw_queue; // used by control switch debouncing
|
||||
bool debouncing = false; // debouncing in process
|
||||
|
||||
void system_reset() {
|
||||
// Reset system variables.
|
||||
State prior_state = sys.state;
|
||||
memset(&sys, 0, sizeof(system_t)); // Clear system struct variable.
|
||||
sys.state = prior_state;
|
||||
sys.f_override = FeedOverride::Default; // Set to 100%
|
||||
sys.r_override = RapidOverride::Default; // Set to 100%
|
||||
sys.spindle_speed_ovr = SpindleSpeedOverride::Default; // Set to 100%
|
||||
memset(sys_probe_position, 0, sizeof(sys_probe_position)); // Clear probe position.
|
||||
}
|
||||
|
||||
void init_output_pins() {
|
||||
//customize pin definition if needed
|
||||
#if (GRBL_SPI_SS != -1) || (GRBL_SPI_MISO != -1) || (GRBL_SPI_MOSI != -1) || (GRBL_SPI_SCK != -1)
|
||||
|
@@ -143,6 +143,8 @@ extern volatile bool sys_rt_exec_debug;
|
||||
|
||||
void init_output_pins(); // Renamed from system_init() due to conflict with esp32 files
|
||||
|
||||
void system_reset();
|
||||
|
||||
// Execute the startup script lines stored in non-volatile storage upon initialization
|
||||
void system_execute_startup(char* line);
|
||||
Error execute_line(char* line, uint8_t client, WebUI::AuthenticationLevel auth_level);
|
||||
|
Reference in New Issue
Block a user