Fixed typos and added grbl.on_gcode_comment event.

This commit is contained in:
Terje Io
2023-05-01 12:01:57 +02:00
parent c652eee852
commit 750f60ce74
13 changed files with 58 additions and 38 deletions

View File

@@ -13,7 +13,7 @@ It has been written to complement grblHAL and has features such as proper keyboa
---
Latest build date is 20230427 see the [changelog](changelog.md) for details.
Latest build date is 20230501 see the [changelog](changelog.md) for details.
__NOTE:__ A settings reset will be performed on an update of builds earlier than 20230125. Backup and restore of settings is recommended.
__IMPORTANT!__ A new setting has been introduced for ganged axes motors in build 20211121.
I have only bench tested this for a couple of drivers, correct function should be verified after updating by those who have more than three motors configured.

View File

@@ -1,5 +1,19 @@
## grblHAL changelog
<a name="20230501"/>20230501
Core:
* Fixed typos.
* Added `grbl.on_gcode_comment` event - can be subscribed to by plugin code to trap comments and act upon them. Intended for implementation of non-standard functionality outside the scope of gcode and $-commands.
Drivers:
* ESP32: fix for spindle PWM not turning off on stop or soft reset.
---
<a name="20230429"/>Build 20230429
Core:

View File

@@ -1833,28 +1833,28 @@ __NOTE:__ Must be a positive values.
*/
///@{
#if !defined DEFAULT_X_CURRENT || defined __DOXYGEN__
#define DEFAULT_X_CURRENT 0.0 // amps
#define DEFAULT_X_CURRENT 0.0 // mA
#endif
#if !defined DEFAULT_Y_CURRENT || defined __DOXYGEN__
#define DEFAULT_Y_CURRENT 0.0 // amps
#define DEFAULT_Y_CURRENT 0.0 // mA
#endif
#if !defined DEFAULT_Z_CURRENT || defined __DOXYGEN__
#define DEFAULT_Z_CURRENT 0.0 // amps
#define DEFAULT_Z_CURRENT 0.0 // mA
#endif
#if (defined A_AXIS && !defined DEFAULT_A_CURRENT) || defined __DOXYGEN__
#define DEFAULT_A_CURRENT 0.0 // amps
#define DEFAULT_A_CURRENT 0.0 // mA
#endif
#if (defined B_AXIS && !defined DEFAULT_B_CURRENT) || defined __DOXYGEN__
#define DEFAULT_B_CURRENT 0.0 // amps
#define DEFAULT_B_CURRENT 0.0 // mA
#endif
#if (defined C_AXIS && !defined DEFAULT_C_CURRENT) || defined __DOXYGEN__
#define DEFAULT_C_CURRENT 0.0 // amps
#define DEFAULT_C_CURRENT 0.0 // mA
#endif
#if (defined U_AXIS && !defined DEFAULT_U_CURRENT) || defined __DOXYGEN__
#define DEFAULT_U_CURRENT 0.0 // amps
#define DEFAULT_U_CURRENT 0.0 // mA
#endif
#if (defined V_AXIS && !defined DEFAULT_V_CURRENT) || defined __DOXYGEN__
#define DEFAULT_V_CURRENT 0.0 // amps
#define DEFAULT_V_CURRENT 0.0 // mA
#endif
///@}

View File

@@ -146,6 +146,7 @@ typedef struct {
on_probe_start_ptr on_probe_start;
on_probe_completed_ptr on_probe_completed;
on_gcode_message_ptr on_gcode_message; //!< Called on output of message parsed from gcode. NOTE: string pointed to is freed after this call.
on_gcode_message_ptr on_gcode_comment; //!< Called when a plain gcode comment has been parsed.
on_tool_selected_ptr on_tool_selected; //!< Called prior to executing M6 or after executing M61.
on_toolchange_ack_ptr on_toolchange_ack; //!< Called from interrupt context.
on_jog_cancel_ptr on_jog_cancel; //!< Called from interrupt context.

29
gcode.c
View File

@@ -409,11 +409,12 @@ static status_code_t init_sync_motion (plan_line_data_t *pl_data, float pitch)
// Output and free previously allocated message
static void output_message (char *message)
{
report_message(message, Message_Plain);
if(grbl.on_gcode_message)
grbl.on_gcode_message(message);
if(*message)
report_message(message, Message_Plain);
free(message);
}
@@ -457,18 +458,22 @@ char *gc_normalize_block (char *block, char **message)
break;
case ')':
if(comment && !hal.driver_cap.no_gcode_message_handling) {
size_t len = s1 - comment - 4;
if(message && *message == NULL && !strncmp(comment, "(MSG,", 5) && (*message = malloc(len))) {
*s1 = '\0';
comment += 5;
// trim leading spaces
while(*comment == ' ') {
comment++;
len--;
if(comment) {
*s1 = '\0';
if(!hal.driver_cap.no_gcode_message_handling) {
size_t len = s1 - comment - 4;
if(message && *message == NULL && !strncmp(comment, "(MSG,", 5) && (*message = malloc(len))) {
comment += 5;
// trim leading spaces
while(*comment == ' ') {
comment++;
len--;
}
memcpy(*message, comment, len);
}
memcpy(*message, comment, len);
}
if(*comment && *message == NULL && grbl.on_gcode_comment)
grbl.on_gcode_comment(comment);
}
comment = NULL;
break;

2
grbl.h
View File

@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20230429
#define GRBL_BUILD 20230501
#define GRBL_URL "https://github.com/grblHAL"

View File

@@ -234,7 +234,7 @@ void mc_arc (float *target, plan_line_data_t *pl_data, float *position, float *o
do {
idx--;
if(!(idx == plane.axis_0 || idx == plane.axis_1))
linear_per_turn[idx] = (target[idx] - position[idx]) / arc_travel * 2.0f * M_PI;;
linear_per_turn[idx] = (target[idx] - position[idx]) / arc_travel * 2.0f * M_PI;
} while(idx);
#else
float linear_per_turn = (target[plane.axis_linear] - position[plane.axis_linear]) / arc_travel * 2.0f * M_PI;

View File

@@ -451,7 +451,7 @@ static status_code_t read_operation (char *line, uint_fast8_t *pos, ngc_binary_o
(*pos)++;
}
else
status = Status_ExpressionUknownOp;; // Unknown operation name starting with L
status = Status_ExpressionUknownOp; // Unknown operation name starting with L
break;
// case '\0':

View File

@@ -54,6 +54,13 @@ PROGMEM const settings_t defaults = {
.version = SETTINGS_VERSION,
#if DEFAULT_LASER_MODE
.mode = Mode_Laser,
#elif DEFAULT_LATHE_MODE
.mode = Mode_Lathe,
#else
.mode = Mode_Standard,
#endif
.junction_deviation = DEFAULT_JUNCTION_DEVIATION,
.arc_tolerance = DEFAULT_ARC_TOLERANCE,
.g73_retract = DEFAULT_G73_RETRACT,
@@ -69,15 +76,7 @@ PROGMEM const settings_t defaults = {
#else
.flags.g92_is_volatile = 0,
#endif
#if DEFAULT_LASER_MODE
.mode = Mode_Laser,
.flags.disable_laser_during_hold = DDEFAULT_DISABLE_LASER_DURING_HOLD
#else
.flags.disable_laser_during_hold = 0,
#if DEFAULT_LATHE_MODE
.mode = Mode_Lathe,
#endif
#endif
.flags.disable_laser_during_hold = DEFAULT_DISABLE_LASER_DURING_HOLD,
.flags.restore_after_feed_hold = DEFAULT_RESTORE_AFTER_FEED_HOLD,
.flags.force_initialization_alarm = DEFAULT_FORCE_INITIALIZATION_ALARM,
.flags.restore_overrides = DEFAULT_RESET_OVERRIDES,

View File

@@ -23,7 +23,7 @@
#include "hal.h"
#include "state_machine.h"
volatile bool slumber;
static volatile bool slumber;
static void fall_asleep()
{

View File

@@ -366,7 +366,7 @@ void state_suspend_manager (void)
} else if (sys.step_control.update_spindle_rpm && restore_condition.spindle[0].hal->get_state().on) {
// Handles spindle state during hold. NOTE: Spindle speed overrides may be altered during hold state.
state_spindle_set_state(&restore_condition.spindle[restore_condition.spindle_num]);;
state_spindle_set_state(&restore_condition.spindle[restore_condition.spindle_num]);
sys.step_control.update_spindle_rpm = Off;
}
}

View File

@@ -183,11 +183,12 @@ static void output_message (sys_state_t state)
{
if(message) {
report_message(message, Message_Plain);
if(grbl.on_gcode_message)
grbl.on_gcode_message(message);
if(*message)
report_message(message, Message_Plain);
free(message);
message = NULL;
}

View File

@@ -463,7 +463,7 @@ bool stream_mpg_enable (bool on)
hal.stream.reset_read_buffer();
sys.mpg_mode = on;
system_add_rt_report(Report_MPGMode);;
system_add_rt_report(Report_MPGMode);
// Force a realtime status report, all reports when MPG mode active
protocol_enqueue_realtime_command(on ? CMD_STATUS_REPORT_ALL : CMD_STATUS_REPORT);