Skip to content

Commit

Permalink
Added event definition for SD card file open, fix for issue #118.
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeio committed Mar 13, 2023
1 parent 71aa2a4 commit 20aa4ec
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 134 deletions.
19 changes: 18 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
## grblHAL changelog

<a name="20230312"/>20230312

Core:

* Added event definition for SD card file open, fix for issue #118.

Drivers:

* ESP32: Added aux I/O and cycle start/feed hold inputs to MKS DLC32 board, expanded max aux out to 4.
__NOTE:__ The aux input 0 port on the MKS DLC32 board does not have an internal pullup.

Plugins:

* SD card: added publish for file open event allowing plugins to take over stream handling. Added `$F+` command for listing all files on card.

---

<a name="20230311"/>20230311

Core:

* Fix for isisue #264, stepper motors not disabled when entering sleep mode.
* Fix for issue #264, stepper motors not disabled when entering sleep mode.
__NOTE:__ all stepper motors will now be disabled even if the $37 setting is set to keep some enabled.

* Fix for recent regression that disabled G7/G8 handling in lathe mode.
Expand Down
7 changes: 5 additions & 2 deletions core_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "report.h"
#include "planner.h"
#include "machine_limits.h"
#include "vfs.h"

typedef enum {
OverrideChanged_FeedRate = 0,
Expand Down Expand Up @@ -107,6 +108,7 @@ 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 void (*on_rt_reports_added_ptr)(report_tracking_flags_t report);
typedef status_code_t (*on_file_open_ptr)(const char *fname, vfs_file_t *handle, bool stream);
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);
Expand Down Expand Up @@ -148,9 +150,10 @@ typedef struct {
on_toolchange_ack_ptr on_toolchange_ack; //!< Called from interrupt context.
on_jog_cancel_ptr on_jog_cancel; //!< Called from interrupt context.
on_laser_ppi_enable_ptr on_laser_ppi_enable;
on_spindle_select_ptr on_spindle_select; //!< Called before spindle is selected, hook in HAL overrides here
on_spindle_selected_ptr on_spindle_selected; //!< Called when spindle is selected, do not change HAL pointers here!
on_spindle_select_ptr on_spindle_select; //!< Called before spindle is selected, hook in HAL overrides here
on_spindle_selected_ptr on_spindle_selected; //!< Called when spindle is selected, do not change HAL pointers here!
on_reset_ptr on_reset; //!< Called from interrupt context.
on_file_open_ptr on_file_open; //!< Called when a file is opened for streaming.
// core entry points - set up by core before driver_init() is called.
enqueue_gcode_ptr enqueue_gcode;
enqueue_realtime_command_ptr enqueue_realtime_command;
Expand Down
6 changes: 3 additions & 3 deletions gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ status_code_t gc_execute_block (char *block)
word_bit.modal_group.M7 = On;
gc_block.modal.spindle.state.on = !(int_value == 5);
gc_block.modal.spindle.state.ccw = int_value == 4;
sys.flags.delay_overrides = On;
sys.override_delay.spindle = On;
break;

case 6:
Expand All @@ -1028,7 +1028,7 @@ status_code_t gc_execute_block (char *block)

case 7: case 8: case 9:
word_bit.modal_group.M8 = On;
sys.flags.delay_overrides = On;
sys.override_delay.coolant = On;
gc_parser_flags.set_coolant = On;
switch(int_value) {

Expand Down Expand Up @@ -2856,7 +2856,7 @@ status_code_t gc_execute_block (char *block)

plan_data.condition.coolant = gc_state.modal.coolant; // Set condition flag for planner use.

sys.flags.delay_overrides = Off;
sys.override_delay.flags = 0;

// [9. Override control ]:
if (gc_state.modal.override_ctrl.value != gc_block.modal.override_ctrl.value) {
Expand Down
2 changes: 1 addition & 1 deletion grbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
#define GRBL_BUILD 20230311
#define GRBL_BUILD 20230312

#define GRBL_URL "https://github.com/grblHAL"

Expand Down
53 changes: 39 additions & 14 deletions override.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Part of grblHAL
Copyright (c) 2017-2019 Terje Io
Copyright (c) 2017-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
Expand All @@ -30,7 +30,7 @@ typedef struct {
uint8_t buf[OVERRIDE_BUFSIZE];
} override_queue_t;

static override_queue_t feed = {0}, accessory = {0};
static override_queue_t feed = {0}, spindle = {0}, coolant = {0};

ISR_CODE void ISR_FUNC(enqueue_feed_override)(uint8_t cmd)
{
Expand All @@ -56,30 +56,55 @@ uint8_t get_feed_override (void)
return data;
}

ISR_CODE void ISR_FUNC(enqueue_accessory_override)(uint8_t cmd)
ISR_CODE void ISR_FUNC(enqueue_spindle_override)(uint8_t cmd)
{
uint_fast8_t bptr = (accessory.head + 1) & (OVERRIDE_BUFSIZE - 1); // Get next head pointer
uint_fast8_t bptr = (spindle.head + 1) & (OVERRIDE_BUFSIZE - 1); // Get next head pointer

if(bptr != accessory.tail) { // If not buffer full
accessory.buf[accessory.head] = cmd; // add data to buffer
accessory.head = bptr; // and update pointer
if(bptr != spindle.tail) { // If not buffer full
spindle.buf[spindle.head] = cmd; // add data to buffer
spindle.head = bptr; // and update pointer
}
}

// Returns 0 if no commands enqueued
uint8_t get_accessory_override (void)
uint8_t get_spindle_override (void)
{
uint8_t data = 0;
uint_fast8_t bptr = accessory.tail;
uint_fast8_t bptr = spindle.tail;

if(bptr != accessory.head) {
data = accessory.buf[bptr++]; // Get next character, increment tmp pointer
accessory.tail = bptr & (OVERRIDE_BUFSIZE - 1); // and update pointer
if(bptr != spindle.head) {
data = spindle.buf[bptr++]; // Get next character, increment tmp pointer
spindle.tail = bptr & (OVERRIDE_BUFSIZE - 1); // and update pointer
}

return data;
}

void flush_override_buffers () {
feed.head = feed.tail = accessory.head = accessory.tail = 0;
ISR_CODE void ISR_FUNC(enqueue_coolant_override)(uint8_t cmd)
{
uint_fast8_t bptr = (coolant.head + 1) & (OVERRIDE_BUFSIZE - 1); // Get next head pointer

if(bptr != coolant.tail) { // If not buffer full
coolant.buf[coolant.head] = cmd; // add data to buffer
coolant.head = bptr; // and update pointer
}
}

// Returns 0 if no commands enqueued
uint8_t get_coolant_override (void)
{
uint8_t data = 0;
uint_fast8_t bptr = coolant.tail;

if(bptr != coolant.head) {
data = coolant.buf[bptr++]; // Get next character, increment tmp pointer
coolant.tail = bptr & (OVERRIDE_BUFSIZE - 1); // and update pointer
}

return data;
}

void flush_override_buffers (void)
{
feed.head = feed.tail = spindle.head = spindle.tail = coolant.head = coolant.tail = 0;
}
8 changes: 5 additions & 3 deletions override.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Part of grblHAL
Copyright (c) 2016-2019 Terje Io
Copyright (c) 2016-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
Expand All @@ -31,7 +31,9 @@
void flush_override_buffers ();
void enqueue_feed_override (uint8_t cmd);
uint8_t get_feed_override (void);
void enqueue_accessory_override (uint8_t cmd);
uint8_t get_accessory_override (void);
void enqueue_spindle_override (uint8_t cmd);
uint8_t get_spindle_override (void);
void enqueue_coolant_override (uint8_t cmd);
uint8_t get_coolant_override (void);

#endif
5 changes: 5 additions & 0 deletions plugins_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@
webui_init();
#endif

#if EMBROIDERY_ENABLE
extern void embroidery_init (void);
embroidery_init();
#endif

extern void my_plugin_init (void);
my_plugin_init();

Expand Down
Loading

0 comments on commit 20aa4ec

Please sign in to comment.