mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-01 18:32:37 +02:00
More ->get()s bite the dust
This commit is contained in:
@@ -27,6 +27,13 @@ namespace Configuration {
|
||||
value = uint32_t(v);
|
||||
}
|
||||
|
||||
// TODO: This will accept values that cannot fit in the variable
|
||||
virtual void handle(const char* name, uint8_t& value) {
|
||||
int32_t v = int32_t(value);
|
||||
handle(name, v);
|
||||
value = uint8_t(v);
|
||||
}
|
||||
|
||||
virtual void handle(const char* name, double& value) = 0;
|
||||
virtual void handle(const char* name, float& value) = 0;
|
||||
virtual void handle(const char* name, StringRange& value) = 0;
|
||||
|
@@ -125,4 +125,5 @@ void CoolantControl::validate() const {}
|
||||
void CoolantControl::handle(Configuration::HandlerBase& handler) {
|
||||
handler.handle("flood", flood_);
|
||||
handler.handle("mist", mist_);
|
||||
handler.handle("delay", delay_);
|
||||
}
|
||||
|
@@ -31,6 +31,8 @@ class CoolantControl : public Configuration::Configurable {
|
||||
Pin mist_;
|
||||
Pin flood_;
|
||||
|
||||
float delay_ = 0.0;
|
||||
|
||||
void write(CoolantState state);
|
||||
|
||||
public:
|
||||
@@ -52,6 +54,8 @@ public:
|
||||
void off();
|
||||
void set_state(CoolantState state);
|
||||
|
||||
float delay() { return delay_; }
|
||||
|
||||
// G-code parser entry-point for setting coolant states. Checks for and executes additional conditions.
|
||||
void sync(CoolantState state);
|
||||
|
||||
|
@@ -38,22 +38,10 @@
|
||||
*/
|
||||
|
||||
// Grbl generic default settings. Should work across different machines.
|
||||
#ifndef DEFAULT_STEPPER_IDLE_LOCK_TIME
|
||||
# define DEFAULT_STEPPER_IDLE_LOCK_TIME 250 // $1 msec (0-254, 255 keeps steppers enabled)
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_STATUS_REPORT_MASK
|
||||
# define DEFAULT_STATUS_REPORT_MASK 1 // $10
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_VERBOSE_ERRORS
|
||||
# define DEFAULT_VERBOSE_ERRORS 0
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_REPORT_INCHES
|
||||
# define DEFAULT_REPORT_INCHES 0 // $13 false
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_HOMING_ENABLE
|
||||
# define DEFAULT_HOMING_ENABLE 0 // $22 false
|
||||
#endif
|
||||
@@ -111,10 +99,6 @@
|
||||
# define SPINDLE_TYPE SpindleType::NONE
|
||||
#endif
|
||||
|
||||
#ifndef DEFAULT_COOLANT_DELAY_TURNON
|
||||
# define DEFAULT_COOLANT_DELAY_TURNON 1.0
|
||||
#endif
|
||||
|
||||
// ================ user settings =====================
|
||||
#ifndef DEFAULT_USER_INT_80
|
||||
# define DEFAULT_USER_INT_80 0 // $80 User integer setting
|
||||
|
@@ -350,10 +350,16 @@ void MachineConfig::handle(Configuration::HandlerBase& handler) {
|
||||
handler.handle("spi", _spi);
|
||||
handler.handle("coolant", _coolant);
|
||||
handler.handle("probe", _probe);
|
||||
handler.handle("laser_mode", _laserMode);
|
||||
handler.handle("pulse_microseconds", _pulseMicroSeconds);
|
||||
handler.handle("board", _board);
|
||||
handler.handle("name", _name);
|
||||
handler.handle("idle_time", _idleTime);
|
||||
// TODO: Consider putting these under a gcode: hierarchy level
|
||||
handler.handle("laser_mode", _laserMode);
|
||||
handler.handle("arc_tolerance", _arcTolerance);
|
||||
handler.handle("junction_deviation", _junctionDeviation);
|
||||
handler.handle("verbose_errors", _verboseErrors);
|
||||
handler.handle("report_inches", _reportInches);
|
||||
}
|
||||
|
||||
void MachineConfig::afterParse() {
|
||||
|
@@ -350,9 +350,12 @@ public:
|
||||
int _directionDelayMilliSeconds = 0;
|
||||
int _disableDelayMilliSeconds = 0;
|
||||
|
||||
bool _laserMode = false;
|
||||
float _arcTolerance = 0.002;
|
||||
float _junctionDeviation = 0.01;
|
||||
bool _laserMode = false;
|
||||
float _arcTolerance = 0.002;
|
||||
float _junctionDeviation = 0.01;
|
||||
uint8_t _idleTime = 255;
|
||||
bool _verboseErrors = false;
|
||||
bool _reportInches = false;
|
||||
|
||||
String _board = "None";
|
||||
String _name = "None";
|
||||
|
@@ -86,10 +86,6 @@
|
||||
|
||||
#define DEFAULT_STATUS_REPORT_MASK 1
|
||||
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
|
||||
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
|
||||
#define DEFAULT_REPORT_INCHES 0 // false
|
||||
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
|
||||
|
@@ -66,10 +66,6 @@
|
||||
|
||||
#define DEFAULT_STATUS_REPORT_MASK 1
|
||||
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
|
||||
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
|
||||
#define DEFAULT_REPORT_INCHES 0 // false
|
||||
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
|
||||
|
@@ -89,10 +89,6 @@
|
||||
|
||||
#define DEFAULT_STATUS_REPORT_MASK 1
|
||||
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
|
||||
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
|
||||
#define DEFAULT_REPORT_INCHES 0 // false
|
||||
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
|
||||
|
@@ -95,10 +95,6 @@
|
||||
|
||||
#define DEFAULT_STATUS_REPORT_MASK 1
|
||||
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
|
||||
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
|
||||
#define DEFAULT_REPORT_INCHES 0 // false
|
||||
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
|
||||
|
@@ -99,10 +99,6 @@
|
||||
|
||||
#define DEFAULT_STATUS_REPORT_MASK 1
|
||||
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
|
||||
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
|
||||
#define DEFAULT_REPORT_INCHES 0 // false
|
||||
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
|
||||
|
@@ -71,10 +71,6 @@
|
||||
|
||||
#define DEFAULT_STATUS_REPORT_MASK 1
|
||||
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
|
||||
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
|
||||
#define DEFAULT_REPORT_INCHES 0 // false
|
||||
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
|
||||
|
@@ -87,10 +87,6 @@
|
||||
|
||||
#define DEFAULT_STATUS_REPORT_MASK 2 // MPos enabled
|
||||
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
|
||||
#define DEFAULT_ARC_TOLERANCE 0.002 // mm
|
||||
#define DEFAULT_REPORT_INCHES 0 // false
|
||||
|
||||
#define DEFAULT_SOFT_LIMIT_ENABLE 0 // false
|
||||
#define DEFAULT_HARD_LIMIT_ENABLE 0 // false
|
||||
|
||||
|
@@ -195,7 +195,7 @@ void protocol_main_loop() {
|
||||
return; // Bail to main() program loop to reset system.
|
||||
}
|
||||
// check to see if we should disable the stepper drivers ... esp32 work around for disable in main loop.
|
||||
if (stepper_idle && stepper_idle_lock_time->get() != 0xff) {
|
||||
if (stepper_idle && config->_idleTime != 0xff) {
|
||||
if (esp_timer_get_time() > stepper_idle_counter) {
|
||||
config->_axes->set_disable(true);
|
||||
}
|
||||
@@ -684,7 +684,7 @@ static void protocol_exec_rt_suspend() {
|
||||
if (!sys.suspend.bit.restartRetract) {
|
||||
// NOTE: Laser mode will honor this delay. An exhaust system is often controlled by this pin.
|
||||
config->_coolant->set_state(restore_coolant);
|
||||
delay_msec(int32_t(1000.0 * coolant_start_delay->get()), DwellMode::SysSuspend);
|
||||
delay_msec(int32_t(1000.0 * config->_coolant->delay()), DwellMode::SysSuspend);
|
||||
}
|
||||
}
|
||||
#ifdef PARKING_ENABLE
|
||||
|
@@ -162,7 +162,7 @@ static void report_util_axis_values(float* axis_value, char* rpt) {
|
||||
float unit_conv = 1.0; // unit conversion multiplier..default is mm
|
||||
const char* format = "%4.3f"; // Default - report mm to 3 decimal places
|
||||
rpt[0] = '\0';
|
||||
if (report_inches->get()) {
|
||||
if (config->_reportInches) {
|
||||
unit_conv = 1.0 / MM_PER_INCH;
|
||||
format = "%4.4f"; // Report inches to 4 decimal places
|
||||
}
|
||||
@@ -183,7 +183,7 @@ static String report_util_axis_values(const float* axis_value) {
|
||||
char axisVal[coordStringLen];
|
||||
float unit_conv = 1.0; // unit conversion multiplier..default is mm
|
||||
int decimals = 3; // Default - report mm to 3 decimal places
|
||||
if (report_inches->get()) {
|
||||
if (config->_reportInches) {
|
||||
unit_conv = 1.0 / MM_PER_INCH;
|
||||
decimals = 4; // Report inches to 4 decimal places
|
||||
}
|
||||
@@ -236,7 +236,7 @@ void report_status_message(Error status_code, uint8_t client) {
|
||||
// With verbose errors, the message text is displayed instead of the number.
|
||||
// Grbl 0.9 used to display the text, while Grbl 1.1 switched to the number.
|
||||
// Many senders support both formats.
|
||||
if (verbose_errors->get()) {
|
||||
if (config->_verboseErrors) {
|
||||
grbl_sendf(client, "error: %s\r\n", errorString(status_code));
|
||||
} else {
|
||||
grbl_sendf(client, "error:%d\r\n", static_cast<int>(status_code));
|
||||
@@ -333,7 +333,7 @@ void report_ngc_parameters(uint8_t client) {
|
||||
ngc_rpt += "]\r\n";
|
||||
ngc_rpt += "[TLO:"; // Print tool length offset
|
||||
float tlo = gc_state.tool_length_offset;
|
||||
if (report_inches->get()) {
|
||||
if (config->_reportInches) {
|
||||
tlo *= INCH_PER_MM;
|
||||
}
|
||||
ngc_rpt += String(tlo, 3);
|
||||
@@ -492,7 +492,7 @@ void report_gcode_modes(uint8_t client) {
|
||||
|
||||
sprintf(temp, " T%d", gc_state.tool);
|
||||
strcat(modes_rpt, temp);
|
||||
sprintf(temp, report_inches->get() ? " F%.1f" : " F%.0f", gc_state.feed_rate);
|
||||
sprintf(temp, config->_reportInches ? " F%.1f" : " F%.0f", gc_state.feed_rate);
|
||||
strcat(modes_rpt, temp);
|
||||
sprintf(temp, " S%d", uint32_t(gc_state.spindle_speed));
|
||||
strcat(modes_rpt, temp);
|
||||
@@ -637,7 +637,7 @@ void report_realtime_status(uint8_t client) {
|
||||
#endif
|
||||
// Report realtime feed speed
|
||||
#ifdef REPORT_FIELD_CURRENT_FEED_SPEED
|
||||
if (report_inches->get()) {
|
||||
if (config->_reportInches) {
|
||||
sprintf(temp, "|FS:%.1f,%d", st_get_realtime_rate() / MM_PER_INCH, sys.spindle_speed);
|
||||
} else {
|
||||
sprintf(temp, "|FS:%.0f,%d", st_get_realtime_rate(), sys.spindle_speed);
|
||||
|
@@ -47,7 +47,7 @@
|
||||
Realtime commands can be anywhere in the stream.
|
||||
|
||||
To allow the realtime commands to be randomly mixed in the stream of data, we
|
||||
read all clients as fast as possible. The realtime commands are acted upon and the other charcters are
|
||||
read all clients as fast as possible. The realtime commands are acted upon and the other characters are
|
||||
placed into a client_buffer[client].
|
||||
|
||||
The main protocol loop reads from client_buffer[]
|
||||
|
@@ -1,20 +1,12 @@
|
||||
#include "Grbl.h"
|
||||
|
||||
FlagSetting* verbose_errors;
|
||||
|
||||
StringSetting* startup_line_0;
|
||||
StringSetting* startup_line_1;
|
||||
StringSetting* build_info;
|
||||
|
||||
IntSetting* stepper_idle_lock_time;
|
||||
|
||||
// TODO Settings - need to call st_generate_step_invert_masks;
|
||||
AxisMaskSetting* homing_dir_mask;
|
||||
AxisMaskSetting* homing_squared_axes;
|
||||
|
||||
FlagSetting* report_inches;
|
||||
|
||||
// TODO Settings - need to call limits_init;
|
||||
FlagSetting* homing_enable;
|
||||
|
||||
IntSetting* status_mask;
|
||||
@@ -134,14 +126,10 @@ void make_settings() {
|
||||
make_coordinate(CoordIndex::G28, "G28");
|
||||
make_coordinate(CoordIndex::G30, "G30");
|
||||
|
||||
verbose_errors = new FlagSetting(EXTENDED, WG, NULL, "Errors/Verbose", DEFAULT_VERBOSE_ERRORS);
|
||||
|
||||
// Spindle Settings
|
||||
spindle_type =
|
||||
new EnumSetting(NULL, EXTENDED, WG, NULL, "Spindle/Type", static_cast<int8_t>(SPINDLE_TYPE), &spindleTypes, checkSpindleChange);
|
||||
|
||||
coolant_start_delay = new FloatSetting(EXTENDED, WG, NULL, "Coolant/Delay/TurnOn", DEFAULT_COOLANT_DELAY_TURNON, 0, 30);
|
||||
|
||||
// GRBL Non-numbered settings
|
||||
startup_line_0 = new StringSetting(EXTENDED, WG, "N0", "GCode/Line0", "", checkStartupLine);
|
||||
startup_line_1 = new StringSetting(EXTENDED, WG, "N1", "GCode/Line1", "", checkStartupLine);
|
||||
@@ -153,20 +141,19 @@ void make_settings() {
|
||||
homing_feed_rate = new FloatSetting(GRBL, WG, "24", "Homing/Feed", DEFAULT_HOMING_FEED_RATE, 0, 10000);
|
||||
homing_squared_axes = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Squared", DEFAULT_HOMING_SQUARED_AXES);
|
||||
|
||||
// TODO Settings - need to call st_generate_step_invert_masks()
|
||||
homing_dir_mask = new AxisMaskSetting(GRBL, WG, "23", "Homing/DirInvert", DEFAULT_HOMING_DIR_MASK);
|
||||
|
||||
// TODO Settings - need to call limits_init();
|
||||
homing_enable = new FlagSetting(GRBL, WG, "22", "Homing/Enable", DEFAULT_HOMING_ENABLE);
|
||||
// TODO Settings - need to check for HOMING_ENABLE
|
||||
|
||||
build_info = new StringSetting(EXTENDED, WG, NULL, "Firmware/Build", "");
|
||||
report_inches = new FlagSetting(GRBL, WG, "13", "Report/Inches", DEFAULT_REPORT_INCHES);
|
||||
build_info = new StringSetting(EXTENDED, WG, NULL, "Firmware/Build", "");
|
||||
|
||||
// TODO: These affect the sender communication protocol so they
|
||||
// need to be be available as $ commands
|
||||
// verbose_errors = new FlagSetting(EXTENDED, WG, NULL, "Errors/Verbose", DEFAULT_VERBOSE_ERRORS);
|
||||
// report_inches = new FlagSetting(GRBL, WG, "13", "Report/Inches", DEFAULT_REPORT_INCHES);
|
||||
|
||||
status_mask = new IntSetting(GRBL, WG, "10", "Report/Status", DEFAULT_STATUS_REPORT_MASK, 0, 3);
|
||||
|
||||
stepper_idle_lock_time = new IntSetting(GRBL, WG, "1", "Stepper/IdleTime", DEFAULT_STEPPER_IDLE_LOCK_TIME, 0, 255);
|
||||
|
||||
homing_cycle[5] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle5", DEFAULT_HOMING_CYCLE_5);
|
||||
homing_cycle[4] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle4", DEFAULT_HOMING_CYCLE_4);
|
||||
homing_cycle[3] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle3", DEFAULT_HOMING_CYCLE_3);
|
||||
|
@@ -1,18 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
extern FlagSetting* verbose_errors;
|
||||
|
||||
extern StringSetting* startup_line_0;
|
||||
extern StringSetting* startup_line_1;
|
||||
extern StringSetting* build_info;
|
||||
|
||||
extern IntSetting* stepper_idle_lock_time;
|
||||
|
||||
extern AxisMaskSetting* homing_dir_mask;
|
||||
extern AxisMaskSetting* homing_squared_axes;
|
||||
extern AxisMaskSetting* homing_cycle[MAX_N_AXIS];
|
||||
|
||||
extern FlagSetting* report_inches;
|
||||
extern FlagSetting* homing_enable;
|
||||
|
||||
extern IntSetting* status_mask;
|
||||
@@ -21,9 +16,6 @@ extern FloatSetting* homing_feed_rate;
|
||||
extern FloatSetting* homing_seek_rate;
|
||||
extern FloatSetting* homing_debounce;
|
||||
extern FloatSetting* homing_pulloff;
|
||||
extern FloatSetting* coolant_start_delay;
|
||||
|
||||
extern IntSetting* spindle_pwm_bit_precision;
|
||||
|
||||
extern EnumSetting* spindle_type;
|
||||
|
||||
|
@@ -439,16 +439,15 @@ void st_go_idle() {
|
||||
Stepper_Timer_Stop();
|
||||
|
||||
// Set stepper driver idle state, disabled or enabled, depending on settings and circumstances.
|
||||
if (((stepper_idle_lock_time->get() != 0xff) || sys_rt_exec_alarm != ExecAlarm::None || sys.state == State::Sleep) &&
|
||||
sys.state != State::Homing) {
|
||||
if (((config->_idleTime != 0xff) || sys_rt_exec_alarm != ExecAlarm::None || sys.state == State::Sleep) && sys.state != State::Homing) {
|
||||
// Force stepper dwell to lock axes for a defined amount of time to ensure the axes come to a complete
|
||||
// stop and not drift from residual inertial forces at the end of the last movement.
|
||||
|
||||
if (sys.state == State::Sleep || sys_rt_exec_alarm != ExecAlarm::None) {
|
||||
config->_axes->set_disable(true);
|
||||
} else {
|
||||
stepper_idle = true; // esp32 work around for disable in main loop
|
||||
stepper_idle_counter = esp_timer_get_time() + (stepper_idle_lock_time->get() * 1000); // * 1000 because the time is in uSecs
|
||||
stepper_idle = true; // esp32 work around for disable in main loop
|
||||
stepper_idle_counter = esp_timer_get_time() + (config->_idleTime * 1000); // * 1000 because the time is in uSecs
|
||||
// after idle countdown will be disabled in protocol loop
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user