diff --git a/changelog.md b/changelog.md
index 46a57d2..06c798e 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,27 @@
## grblHAL changelog
+Build 20240408
+
+Core:
+
+* Fix for bug in NGC expressions return statement handling. Ref issue [#485](https://github.com/grblHAL/core/issues/485).
+
+Drivers:
+
+* RP2040: fix for incorrect handling of safety door input inversion. Ref. issue [#85](https://github.com/grblHAL/RP2040/issues/85).
+
+* STM32F7xx: removed stray project folder from Eclipse debug build configuration.
+
+* All \(remaining\): now calls stepper enable via HAL.
+
+Plugins:
+
+* SD card: fix for potential expression stack issue when macro is terminated early with `M99`.
+
+* Spindle: improved logic, switched polling to new task handling code. Ref. issue [#27](https://github.com/grblHAL/Plugins_spindle/issues/27).
+
+---
+
Build 20240404
Core:
diff --git a/grbl.h b/grbl.h
index 89e142e..06c940e 100644
--- a/grbl.h
+++ b/grbl.h
@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
-#define GRBL_BUILD 20240404
+#define GRBL_BUILD 20240408
#define GRBL_URL "https://github.com/grblHAL"
diff --git a/ngc_flowctrl.c b/ngc_flowctrl.c
index eb21a43..7ae9b74 100644
--- a/ngc_flowctrl.c
+++ b/ngc_flowctrl.c
@@ -5,20 +5,20 @@
Part of grblHAL
- Copyright (c) 2023 Terje Io
+ Copyright (c) 2023-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL 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,
+ grblHAL 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
+ 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 .
+ along with grblHAL. If not, see .
*/
#include "hal.h"
@@ -192,9 +192,14 @@ static bool stack_pull (void)
return ok;
}
-
// Public functions
+void ngc_flowctrl_unwind_stack (vfs_file_t *file)
+{
+ while(stack_idx >= 0 && stack[stack_idx].file == file)
+ stack_pull();
+}
+
void ngc_flowctrl_init (void)
{
while(stack_idx >= 0)
@@ -417,16 +422,16 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
break;
case NGCFlowCtrl_Return:
- if(!skipping && grbl.on_macro_return) {
- vfs_file_t *file = stack[stack_idx].file;
- while(stack_idx >= 0 && file == stack[stack_idx].file)
- stack_pull();
- if(ngc_eval_expression(line, pos, &value) == Status_OK) {
- ngc_named_param_set("_value", value);
- ngc_named_param_set("_value_returned", 1.0f);
- } else
- ngc_named_param_set("_value_returned", 0.0f);
- grbl.on_macro_return();
+ if(hal.stream.file) {
+ if(!skipping && grbl.on_macro_return) {
+ ngc_flowctrl_unwind_stack(stack[stack_idx].file);
+ if(ngc_eval_expression(line, pos, &value) == Status_OK) {
+ ngc_named_param_set("_value", value);
+ ngc_named_param_set("_value_returned", 1.0f);
+ } else
+ ngc_named_param_set("_value_returned", 0.0f);
+ grbl.on_macro_return();
+ }
} else
status = Status_FlowControlNotExecutingMacro;
break;
diff --git a/ngc_flowctrl.h b/ngc_flowctrl.h
index 2544981..f2b6d20 100644
--- a/ngc_flowctrl.h
+++ b/ngc_flowctrl.h
@@ -5,26 +5,27 @@
Part of grblHAL
- Copyright (c) 2023 Terje Io
+ Copyright (c) 2023-2024 Terje Io
- Grbl is free software: you can redistribute it and/or modify
+ grblHAL 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,
+ grblHAL 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
+ 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 .
+ along with grblHAL. If not, see .
*/
#ifndef _NGC_FLOWCTRL_H_
#define _NGC_FLOWCTRL_H_
void ngc_flowctrl_init (void);
+void ngc_flowctrl_unwind_stack (vfs_file_t *file);
status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, bool *skip);
#endif