See the changelog for details, changes are relevant for developers only.

This commit is contained in:
Terje Io
2023-02-22 09:19:49 +01:00
parent b1f14577d7
commit 0c6233d709
9 changed files with 75 additions and 27 deletions

View File

@@ -1,6 +1,31 @@
## grblHAL changelog
<a name="20230218"/>20230220
20230221
Core:
* Added definitions for some "standard" I2C API calls, for driver/plugin use.
* Added _grbl.on_gcode_message_ event, can be used by driver/plugin writers to parse the message for extending functionality etc.
Triggered by `(MSG, "some message")` gcode comments.
Drivers:
* Almost all: updated to match new core defined I2C API. Note that some drivers only has a partial implementation, to be updated on demand.
* ESP32: fixed up W5500 ethernet middle layer driver code, now works in DHCP mode with telnet enabled. Other protocols may work, not extensively tested.
Note that board map definitions has to be adjusted \(or added\) for ethernet as a SPI port in addtion to an interrupt input is required, none is presently set up for that.
* STM32F4xx: updated some board maps/[Web Builder](http://svn.io-engineering.com:8080/) definitions to allow selection of EEPROM size or disabling EEPROM support altogether.
Plugins:
* Keypad: I2C display plugins updated to probe for display on startup, no longer attaches themself if not present.
Expanded I2C display interface protocol to add gcode message, when present, by dynamically adjusting I2C message length.
---
<a name="20230220"/>20230220
Plugins:
@@ -8,7 +33,7 @@ Plugins:
* Spindle: Fix for issue #255 - fails to compile when single VFD spindle is selected.
* Initial commit of I2C display interface protocol. __NOTE:__ this is not yet available for compilation.
* Keypad: Initial commit of I2C display interface protocol. __NOTE:__ this is not yet available for compilation.
---

View File

@@ -103,6 +103,7 @@ typedef void (*on_reset_ptr)(void);
typedef void (*on_jog_cancel_ptr)(sys_state_t state);
typedef bool (*on_spindle_select_ptr)(spindle_ptrs_t *spindle);
typedef void (*on_spindle_selected_ptr)(spindle_ptrs_t *spindle);
typedef void (*on_gcode_message_ptr)(char *msg);
typedef status_code_t (*on_unknown_sys_command_ptr)(sys_state_t state, char *line); // return Status_Unhandled.
typedef status_code_t (*on_user_command_ptr)(char *line);
typedef sys_commands_t *(*on_get_commands_ptr)(void);
@@ -137,6 +138,7 @@ typedef struct {
on_probe_fixture_ptr on_probe_fixture;
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_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.

View File

@@ -147,7 +147,7 @@
#endif
#ifndef I2C_ENABLE
#if EEPROM_ENABLE || KEYPAD_ENABLE == 1 || I2C_STROBE_ENABLE || (TRINAMIC_ENABLE && TRINAMIC_I2C)
#if EEPROM_ENABLE || KEYPAD_ENABLE == 1 || DISPLAY_ENABLE == 1 || DISPLAY_ENABLE == 2 || I2C_STROBE_ENABLE || (TRINAMIC_ENABLE && TRINAMIC_I2C)
#define I2C_ENABLE 1
#else
#define I2C_ENABLE 0

40
gcode.c
View File

@@ -402,6 +402,17 @@ static status_code_t init_sync_motion (plan_line_data_t *pl_data, float pitch)
return Status_OK;
}
// 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);
free(message);
}
// Remove whitespace, control characters, comments and if block delete is active block delete lines
// else the block delete character. Remaining characters are converted to upper case.
// If the driver handles message comments then the first is extracted and returned in a dynamically
@@ -446,7 +457,13 @@ char *gc_normalize_block (char *block, char **message)
size_t len = s1 - comment - 4;
if(message && *message == NULL && !strncmp(comment, "(MSG,", 5) && (*message = malloc(len))) {
*s1 = '\0';
memcpy(*message, comment + 5, len);
comment += 5;
// trim leading spaces
while(*comment == ' ') {
comment++;
len--;
}
memcpy(*message, comment, len);
}
}
comment = NULL;
@@ -581,10 +598,8 @@ status_code_t gc_execute_block (char *block)
block = gc_normalize_block(block, &message);
if(block[0] == '\0') {
if(message) {
report_message(message, Message_Plain);
free(message);
}
if(message)
output_message(message);
return Status_OK;
}
@@ -596,10 +611,8 @@ status_code_t gc_execute_block (char *block)
// functions that empty the planner buffer to execute its task on-time.
if (block[0] == CMD_PROGRAM_DEMARCATION && block[1] == '\0') {
gc_state.file_run = !gc_state.file_run;
if(message) {
report_message(message, Message_Plain);
free(message);
}
if(message)
output_message(message);
return Status_OK;
}
@@ -2758,8 +2771,7 @@ status_code_t gc_execute_block (char *block)
protocol_buffer_synchronize();
if(plan_data.message) {
report_message(plan_data.message, Message_Plain);
free(plan_data.message);
output_message(plan_data.message);
plan_data.message = NULL;
}
@@ -3149,10 +3161,8 @@ status_code_t gc_execute_block (char *block)
// == GCUpdatePos_None
}
if(plan_data.message) {
report_message(plan_data.message, Message_Plain);
free(plan_data.message);
}
if(plan_data.message)
output_message(plan_data.message);
// [21. Program flow ]:
// M0,M1,M2,M30,M60: Perform non-running program flow actions. During a program pause, the buffer may

2
grbl.h
View File

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

View File

@@ -208,7 +208,7 @@ bool nvs_buffer_alloc (void)
assert(NVS_SIZE >= GRBL_NVS_SIZE);
if((nvsbuffer = malloc(NVS_SIZE)))
memset(nvsbuffer, 0, NVS_SIZE);
memset(nvsbuffer, 0xFF, NVS_SIZE);
return nvsbuffer != NULL;
}

View File

@@ -7,7 +7,7 @@
Part of grblHAL
Copyright (c) 2020-2021 Terje Io
Copyright (c) 2020-2023 Terje Io
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -213,4 +213,12 @@ typedef struct {
extern nvs_transfer_result_t i2c_nvs_transfer (nvs_transfer_t *i2c, bool read);
// I2C interface
typedef void (*keycode_callback_ptr)(const char c);
extern bool i2c_probe (uint_fast16_t i2c_address);
extern bool i2c_send (uint_fast16_t i2c_address, uint8_t *data, size_t size, bool block);
extern void i2c_get_keycode (uint_fast16_t i2c_address, keycode_callback_ptr callback);
#endif

View File

@@ -248,7 +248,6 @@ static status_code_t report_status_message (status_code_t status_code)
return status_code;
}
// Prints alarm messages.
alarm_code_t report_alarm_message (alarm_code_t alarm_code)
{
@@ -291,20 +290,19 @@ static message_code_t report_feedback_message (message_code_t id)
const char *msg = NULL;
uint_fast16_t idx = 0;
hal.stream.write_all("[MSG:");
do {
if(messages[idx].id == id)
msg = messages[idx].msg;
} while(msg == NULL && ++idx < Message_NextMessage);
hal.stream.write_all(msg ? msg : "");
hal.stream.write_all("]" ASCII_EOL);
report_message(msg ? msg : "", Message_Plain);
if(id == Message_None && grbl.on_gcode_message)
grbl.on_gcode_message("");
return id;
}
// Welcome message
void report_init_message (void)
{

View File

@@ -182,7 +182,12 @@ static st_prep_t prep;
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);
free(message);
message = NULL;
}