mirror of
https://github.com/grblHAL/core.git
synced 2026-09-22 19:43:43 +08:00
Minor fix for the grbl.on_state_changed event - incorrect state published following stop signal when streaming gcode.
Added core event for real-time report elements beeing forced++
This commit is contained in:
@@ -13,7 +13,7 @@ It has been written to complement grblHAL and has features such as proper keyboa
|
||||
|
||||
---
|
||||
|
||||
Latest build date is 20230228, see the [changelog](changelog.md) for details.
|
||||
Latest build date is 20230302, 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.
|
||||
@@ -87,4 +87,4 @@ List of Supported G-Codes:
|
||||
Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes.
|
||||
|
||||
---
|
||||
2023-02-13
|
||||
2023-03-06
|
||||
|
||||
+21
-1
@@ -1,5 +1,25 @@
|
||||
## grblHAL changelog
|
||||
|
||||
<a name="2023032"/>20230302
|
||||
|
||||
Core:
|
||||
|
||||
* Minor fix for the `grbl.on_state_changed` event - incorrect state published following stop signal when streaming gcode.
|
||||
|
||||
Drivers:
|
||||
|
||||
* RP2040: Added initial support for I2C display protocol, using DMA transfers.
|
||||
|
||||
* STM32F4xx: Fix for EEPROM issue for ST Morpho CNC board maps.
|
||||
|
||||
* STM32F7xx: Fix for missing motor enable outputs for ganged axes and fix for IRQ conflicts for 7+ axis configurations \(reference map\).
|
||||
|
||||
Plugins:
|
||||
|
||||
* Keypad: Type fix for homed status field.
|
||||
|
||||
---
|
||||
|
||||
<a name="20230228"/>20230228
|
||||
|
||||
Core:
|
||||
@@ -8,7 +28,7 @@ Core:
|
||||
|
||||
Drivers:
|
||||
|
||||
* STM32F4xx: Fixed missing pullup enable for EStop input. __NOTE:__ this may trigger EStop alarm for those who have not wired a switch to this input.
|
||||
* STM32F4xx: Fixed missing pullup enable for EStop input. __NOTE:__ this may trigger EStop alarm for those who have not wired a switch to this input.
|
||||
|
||||
Plugins:
|
||||
|
||||
|
||||
+2
-3
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2016-2021 Terje Io
|
||||
Copyright (c) 2016-2023 Terje Io
|
||||
Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
|
||||
|
||||
Grbl is free software: you can redistribute it and/or modify
|
||||
@@ -36,11 +36,10 @@ void coolant_set_state (coolant_state_t mode)
|
||||
{
|
||||
if (!ABORTED) { // Block during abort.
|
||||
hal.coolant.set_state(mode);
|
||||
sys.report.coolant = On; // Set to report change immediately
|
||||
system_add_rt_report(Report_Coolant); // Set to report change immediately
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// G-code parser entry-point for setting coolant state. Forces a planner buffer sync and bails
|
||||
// if an abort or check-mode is active.
|
||||
bool coolant_sync (coolant_state_t mode)
|
||||
|
||||
@@ -106,6 +106,7 @@ 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 void (*on_rt_reports_added_ptr)(report_tracking_flags_t report);
|
||||
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);
|
||||
@@ -125,6 +126,7 @@ typedef struct {
|
||||
on_unknown_accessory_override_ptr on_unknown_accessory_override;
|
||||
on_report_options_ptr on_report_options;
|
||||
on_report_command_help_ptr on_report_command_help;
|
||||
on_rt_reports_added_ptr on_rt_reports_added;
|
||||
on_global_settings_restore_ptr on_global_settings_restore;
|
||||
on_get_alarms_ptr on_get_alarms;
|
||||
on_get_errors_ptr on_get_errors;
|
||||
|
||||
@@ -108,7 +108,7 @@ typedef enum {
|
||||
|
||||
Status_Unhandled, // For internal use only
|
||||
Status_StatusMax = Status_Unhandled
|
||||
} status_code_t;
|
||||
} __attribute__ ((__packed__)) status_code_t;
|
||||
|
||||
typedef struct {
|
||||
status_code_t id;
|
||||
|
||||
@@ -171,7 +171,7 @@ static void set_scaling (float factor)
|
||||
gc_state.modal.scaling_active = factor != 1.0f;
|
||||
|
||||
if(state.value != gc_get_g51_state().value)
|
||||
sys.report.scaling = On;
|
||||
system_add_rt_report(Report_Scaling);
|
||||
}
|
||||
|
||||
float *gc_get_scaling (void)
|
||||
@@ -240,7 +240,7 @@ void gc_set_tool_offset (tool_offset_mode_t mode, uint_fast8_t idx, int32_t offs
|
||||
gc_state.modal.tool_offset_mode = mode;
|
||||
|
||||
if(tlo_changed) {
|
||||
sys.report.tool_offset = true;
|
||||
system_add_rt_report(Report_ToolOffset);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
}
|
||||
@@ -345,15 +345,14 @@ void gc_spindle_off (void)
|
||||
gc_state.modal.spindle.state.value = 0;
|
||||
|
||||
spindle_all_off();
|
||||
|
||||
sys.report.spindle = On;
|
||||
system_add_rt_report(Report_Spindle);
|
||||
}
|
||||
|
||||
void gc_coolant_off (void)
|
||||
{
|
||||
gc_state.modal.coolant.value = 0;
|
||||
hal.coolant.set_state(gc_state.modal.coolant);
|
||||
sys.report.coolant = On;
|
||||
system_add_rt_report(Report_Coolant);
|
||||
}
|
||||
|
||||
spindle_ptrs_t *gc_spindle_get (void)
|
||||
@@ -1696,9 +1695,9 @@ status_code_t gc_execute_block (char *block)
|
||||
gc_block.values.xyz[idx] *= MM_PER_INCH;
|
||||
} while(idx);
|
||||
|
||||
if (command_words.G15) {
|
||||
sys.report.xmode |= gc_state.modal.diameter_mode != gc_block.modal.diameter_mode;
|
||||
if (command_words.G1 && gc_state.modal.diameter_mode != gc_block.modal.diameter_mode) {
|
||||
gc_state.modal.diameter_mode = gc_block.modal.diameter_mode;
|
||||
system_add_rt_report(Report_LatheXMode);
|
||||
}
|
||||
|
||||
if(gc_state.modal.diameter_mode && bit_istrue(axis_words.mask, bit(X_AXIS)))
|
||||
@@ -1709,6 +1708,8 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
if(gc_block.modal.scaling_active) {
|
||||
|
||||
bool report_scaling = false;
|
||||
|
||||
// TODO: precheck for 0.0f and fail if found?
|
||||
|
||||
gc_block.modal.scaling_active = false;
|
||||
@@ -1721,9 +1722,10 @@ status_code_t gc_execute_block (char *block)
|
||||
idx = N_AXIS;
|
||||
do {
|
||||
if(bit_istrue(axis_words.mask, bit(--idx))) {
|
||||
sys.report.scaling = sys.report.scaling || scale_factor.ijk[idx] != gc_block.values.xyz[idx];
|
||||
report_scaling |= scale_factor.ijk[idx] != gc_block.values.xyz[idx];
|
||||
scale_factor.ijk[idx] = gc_block.values.xyz[idx];
|
||||
bit_false(axis_words.mask, bit(idx));
|
||||
system_add_rt_report(Report_Scaling);
|
||||
}
|
||||
gc_block.modal.scaling_active = gc_block.modal.scaling_active || (scale_factor.xyz[idx] != 1.0f);
|
||||
} while(idx);
|
||||
@@ -1747,10 +1749,10 @@ status_code_t gc_execute_block (char *block)
|
||||
do {
|
||||
idx--;
|
||||
if(gc_block.words.p) {
|
||||
sys.report.scaling = sys.report.scaling || scale_factor.ijk[idx] != gc_block.values.p;
|
||||
report_scaling |= scale_factor.ijk[idx] != gc_block.values.p;
|
||||
scale_factor.ijk[idx] = gc_block.values.p;
|
||||
} else if(bit_istrue(ijk_words.mask, bit(idx))) {
|
||||
sys.report.scaling = sys.report.scaling || scale_factor.ijk[idx] != gc_block.values.ijk[idx];
|
||||
report_scaling |= scale_factor.ijk[idx] != gc_block.values.ijk[idx];
|
||||
scale_factor.ijk[idx] = gc_block.values.ijk[idx];
|
||||
}
|
||||
gc_block.modal.scaling_active = gc_block.modal.scaling_active || (scale_factor.ijk[idx] != 1.0f);
|
||||
@@ -1761,9 +1763,12 @@ status_code_t gc_execute_block (char *block)
|
||||
else
|
||||
gc_block.words.i = gc_block.words.j = gc_block.words.k = Off;
|
||||
#endif
|
||||
sys.report.scaling = sys.report.scaling || gc_state.modal.scaling_active != gc_block.modal.scaling_active;
|
||||
report_scaling |= gc_state.modal.scaling_active != gc_block.modal.scaling_active;
|
||||
gc_state.modal.scaling_active = gc_block.modal.scaling_active;
|
||||
|
||||
if(report_scaling)
|
||||
system_add_rt_report(Report_Scaling);
|
||||
|
||||
} else
|
||||
set_scaling(1.0f);
|
||||
}
|
||||
@@ -2725,7 +2730,7 @@ status_code_t gc_execute_block (char *block)
|
||||
gc_block.modal.spindle.state = gc_state.modal.spindle.state;
|
||||
}
|
||||
|
||||
sys.report.tool = On;
|
||||
system_add_rt_report(Report_Tool);
|
||||
}
|
||||
|
||||
// Prepare tool carousel when available
|
||||
@@ -2736,7 +2741,7 @@ status_code_t gc_execute_block (char *block)
|
||||
hal.tool.select(gc_state.tool, !set_tool);
|
||||
#endif
|
||||
} else
|
||||
sys.report.tool = On;
|
||||
system_add_rt_report(Report_Tool);
|
||||
}
|
||||
|
||||
// [5a. HAL pin I/O ]: M62 - M68. (Modal group M10)
|
||||
@@ -2757,7 +2762,7 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
case IoMCode_WaitOnInput:
|
||||
sys.var5399 = hal.port.wait_on_input((io_port_type_t)gc_block.output_command.is_digital, gc_block.output_command.port, (wait_mode_t)gc_block.values.l, gc_block.values.q);
|
||||
sys.report.m66result = On;
|
||||
system_add_rt_report(Report_M66Result);
|
||||
break;
|
||||
|
||||
case IoMCode_AnalogOutSynced:
|
||||
@@ -2799,7 +2804,7 @@ status_code_t gc_execute_block (char *block)
|
||||
if(hal.tool.change) { // ATC
|
||||
if((int_value = (uint_fast16_t)hal.tool.change(&gc_state)) != Status_OK)
|
||||
FAIL((status_code_t)int_value);
|
||||
sys.report.tool = On;
|
||||
system_add_rt_report(Report_Tool);
|
||||
} else { // Manual
|
||||
gc_state.tool_change = true;
|
||||
system_set_exec_state_flag(EXEC_TOOL_CHANGE); // Set up program pause for manual tool change
|
||||
@@ -2938,7 +2943,7 @@ status_code_t gc_execute_block (char *block)
|
||||
} while(idx);
|
||||
|
||||
if(tlo_changed) {
|
||||
sys.report.tool_offset = true;
|
||||
system_add_rt_report(Report_ToolOffset);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
}
|
||||
@@ -2946,7 +2951,7 @@ status_code_t gc_execute_block (char *block)
|
||||
// [15. Coordinate system selection ]:
|
||||
if (gc_state.modal.coord_system.id != gc_block.modal.coord_system.id) {
|
||||
memcpy(&gc_state.modal.coord_system, &gc_block.modal.coord_system, sizeof(gc_state.modal.coord_system));
|
||||
sys.report.gwco = On;
|
||||
system_add_rt_report(Report_GWCO);
|
||||
system_flag_wco_change();
|
||||
}
|
||||
|
||||
@@ -3204,8 +3209,10 @@ status_code_t gc_execute_block (char *block)
|
||||
gc_state.modal.feed_mode = FeedMode_UnitsPerMin;
|
||||
// TODO: check gc_state.distance_per_rev = 0.0f;
|
||||
// gc_state.modal.cutter_comp = CUTTER_COMP_DISABLE; // Not supported.
|
||||
if((sys.report.gwco = gc_state.modal.coord_system.id != CoordinateSystem_G54))
|
||||
if(gc_state.modal.coord_system.id != CoordinateSystem_G54) {
|
||||
gc_state.modal.coord_system.id = CoordinateSystem_G54;
|
||||
system_add_rt_report(Report_GWCO);
|
||||
}
|
||||
gc_state.modal.spindle.state = (spindle_state_t){0};
|
||||
gc_state.modal.coolant = (coolant_state_t){0};
|
||||
gc_state.modal.override_ctrl.feed_rate_disable = Off;
|
||||
@@ -3247,7 +3254,8 @@ status_code_t gc_execute_block (char *block)
|
||||
|
||||
spindle_all_off();
|
||||
hal.coolant.set_state(gc_state.modal.coolant);
|
||||
sys.report.spindle = sys.report.coolant = On; // Set to report change immediately
|
||||
system_add_rt_report(Report_Spindle); // Set to report change
|
||||
system_add_rt_report(Report_Coolant); // immediately.
|
||||
}
|
||||
|
||||
if(grbl.on_program_completed)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#else
|
||||
#define GRBL_VERSION "1.1f"
|
||||
#endif
|
||||
#define GRBL_BUILD 20230228
|
||||
#define GRBL_BUILD 20230302
|
||||
|
||||
#define GRBL_URL "https://github.com/grblHAL"
|
||||
|
||||
|
||||
+1
-1
@@ -924,7 +924,7 @@ status_code_t mc_homing_cycle (axes_signals_t cycle)
|
||||
sync_position();
|
||||
}
|
||||
|
||||
sys.report.homed = On;
|
||||
system_add_rt_report(Report_Homed);
|
||||
|
||||
homed_status = settings.limits.flags.hard_enabled && settings.limits.flags.check_at_init && limit_signals_merge(hal.limits.get_state()).value
|
||||
? Status_LimitsEngaged
|
||||
|
||||
@@ -661,7 +661,7 @@ void plan_feed_override (override_t feed_override, override_t rapid_override)
|
||||
(rapidrate_changed = rapid_override != sys.override.rapid_rate)) {
|
||||
sys.override.feed_rate = feed_override;
|
||||
sys.override.rapid_rate = rapid_override;
|
||||
sys.report.overrides = On; // Set to report change immediately
|
||||
system_add_rt_report(Report_Overrides); // Set to report change immediately
|
||||
plan_update_velocity_profile_parameters();
|
||||
plan_cycle_reinitialize();
|
||||
if(grbl.on_override_changed) {
|
||||
|
||||
+7
-4
@@ -773,10 +773,13 @@ ISR_CODE bool ISR_FUNC(protocol_enqueue_realtime_command)(char c)
|
||||
|
||||
case CMD_STATUS_REPORT_ALL: // Add all statuses to report
|
||||
{
|
||||
bool tlo = sys.report.tool_offset;
|
||||
sys.report.value = (uint32_t)-1;
|
||||
sys.report.tool_offset = tlo;
|
||||
sys.report.m66result = sys.var5399 > -2;
|
||||
report_tracking_flags_t report;
|
||||
|
||||
report.value = (uint32_t)Report_All;
|
||||
report.tool_offset = sys.report.tool_offset;
|
||||
report.m66result = sys.var5399 > -2;
|
||||
|
||||
system_add_rt_report((report_tracking_t)report.value);
|
||||
}
|
||||
system_set_exec_state_flag(EXEC_STATUS_REPORT);
|
||||
drop = true;
|
||||
|
||||
@@ -1068,6 +1068,7 @@ void report_realtime_status (void)
|
||||
static bool probing = false;
|
||||
|
||||
float print_position[N_AXIS];
|
||||
report_tracking_flags_t report = system_get_rt_report_flags();
|
||||
probe_state_t probe_state = {
|
||||
.connected = On,
|
||||
.triggered = Off
|
||||
@@ -1115,7 +1116,7 @@ void report_realtime_status (void)
|
||||
|
||||
case STATE_ESTOP:
|
||||
case STATE_ALARM:
|
||||
if((sys.report.all || settings.status_report.alarm_substate) && sys.alarm)
|
||||
if((report.all || settings.status_report.alarm_substate) && sys.alarm)
|
||||
hal.stream.write_all(appendbuf(2, "Alarm:", uitoa((uint32_t)sys.alarm)));
|
||||
else
|
||||
hal.stream.write_all("Alarm");
|
||||
@@ -1140,7 +1141,7 @@ void report_realtime_status (void)
|
||||
|
||||
uint_fast8_t idx;
|
||||
float wco[N_AXIS];
|
||||
if (!settings.status_report.machine_position || sys.report.wco) {
|
||||
if (!settings.status_report.machine_position || report.wco) {
|
||||
for (idx = 0; idx < N_AXIS; idx++) {
|
||||
// Apply work coordinate offsets and tool length offset to current position.
|
||||
wco[idx] = gc_get_offset(idx);
|
||||
@@ -1234,7 +1235,7 @@ void report_realtime_status (void)
|
||||
|
||||
if(settings.status_report.work_coord_offset) {
|
||||
|
||||
if(wco_counter > 0 && !sys.report.wco) {
|
||||
if(wco_counter > 0 && !report.wco) {
|
||||
if(wco_counter > (REPORT_WCO_REFRESH_IDLE_COUNT - 1) && state_get() == STATE_IDLE)
|
||||
wco_counter = REPORT_WCO_REFRESH_IDLE_COUNT - 1;
|
||||
wco_counter--;
|
||||
@@ -1243,41 +1244,41 @@ void report_realtime_status (void)
|
||||
? (REPORT_WCO_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh
|
||||
: (REPORT_WCO_REFRESH_IDLE_COUNT - 1);
|
||||
} else
|
||||
sys.report.wco = Off;
|
||||
report.wco = Off;
|
||||
|
||||
if(settings.status_report.overrides) {
|
||||
|
||||
if (override_counter > 0 && !sys.report.overrides)
|
||||
if (override_counter > 0 && !report.overrides)
|
||||
override_counter--;
|
||||
else if((sys.report.overrides = !sys.report.wco)) {
|
||||
sys.report.spindle = sys.report.spindle || spindle_0_state.on;
|
||||
sys.report.coolant = sys.report.coolant || hal.coolant.get_state().value != 0;
|
||||
else if((report.overrides = !report.wco)) {
|
||||
report.spindle = report.spindle || spindle_0_state.on;
|
||||
report.coolant = report.coolant || hal.coolant.get_state().value != 0;
|
||||
override_counter = state_get() & (STATE_HOMING|STATE_CYCLE|STATE_HOLD|STATE_JOG|STATE_SAFETY_DOOR)
|
||||
? (REPORT_OVERRIDE_REFRESH_BUSY_COUNT - 1) // Reset counter for slow refresh
|
||||
: (REPORT_OVERRIDE_REFRESH_IDLE_COUNT - 1);
|
||||
}
|
||||
} else
|
||||
sys.report.overrides = Off;
|
||||
report.overrides = Off;
|
||||
|
||||
if(sys.report.value || gc_state.tool_change) {
|
||||
if(report.value || gc_state.tool_change) {
|
||||
|
||||
if(sys.report.wco) {
|
||||
if(report.wco) {
|
||||
hal.stream.write_all("|WCO:");
|
||||
hal.stream.write_all(get_axis_values(wco));
|
||||
}
|
||||
|
||||
if(sys.report.gwco) {
|
||||
if(report.gwco) {
|
||||
hal.stream.write_all("|WCS:G");
|
||||
hal.stream.write_all(map_coord_system(gc_state.modal.coord_system.id));
|
||||
}
|
||||
|
||||
if(sys.report.overrides) {
|
||||
if(report.overrides) {
|
||||
hal.stream.write_all(appendbuf(2, "|Ov:", uitoa((uint32_t)sys.override.feed_rate)));
|
||||
hal.stream.write_all(appendbuf(2, ",", uitoa((uint32_t)sys.override.rapid_rate)));
|
||||
hal.stream.write_all(appendbuf(2, ",", uitoa((uint32_t)spindle_0->param->override_pct)));
|
||||
}
|
||||
|
||||
if(sys.report.spindle || sys.report.coolant || sys.report.tool || gc_state.tool_change) {
|
||||
if(report.spindle || report.coolant || report.tool || gc_state.tool_change) {
|
||||
|
||||
coolant_state_t cl_state = hal.coolant.get_state();
|
||||
|
||||
@@ -1300,39 +1301,39 @@ void report_realtime_status (void)
|
||||
if (cl_state.mist)
|
||||
*append++ = 'M';
|
||||
|
||||
if(gc_state.tool_change && !sys.report.tool)
|
||||
if(gc_state.tool_change && !report.tool)
|
||||
*append++ = 'T';
|
||||
|
||||
*append = '\0';
|
||||
hal.stream.write_all(buf);
|
||||
}
|
||||
|
||||
if(sys.report.scaling) {
|
||||
if(report.scaling) {
|
||||
axis_signals_tostring(buf, gc_get_g51_state());
|
||||
hal.stream.write_all("|Sc:");
|
||||
hal.stream.write_all(buf);
|
||||
}
|
||||
|
||||
if(sys.report.mpg_mode && hal.driver_cap.mpg_mode)
|
||||
if(report.mpg_mode && hal.driver_cap.mpg_mode)
|
||||
hal.stream.write_all(sys.mpg_mode ? "|MPG:1" : "|MPG:0");
|
||||
|
||||
if(sys.report.homed && (sys.homing.mask || settings.homing.flags.single_axis_commands || settings.homing.flags.manual)) {
|
||||
if(report.homed && (sys.homing.mask || settings.homing.flags.single_axis_commands || settings.homing.flags.manual)) {
|
||||
axes_signals_t homing = {sys.homing.mask ? sys.homing.mask : AXES_BITMASK};
|
||||
hal.stream.write_all(appendbuf(2, "|H:", (homing.mask & sys.homed.mask) == homing.mask ? "1" : "0"));
|
||||
if(settings.homing.flags.single_axis_commands)
|
||||
hal.stream.write_all(appendbuf(2, ",", uitoa(sys.homed.mask)));
|
||||
}
|
||||
|
||||
if(sys.report.xmode && settings.mode == Mode_Lathe)
|
||||
if(report.xmode && settings.mode == Mode_Lathe)
|
||||
hal.stream.write_all(gc_state.modal.diameter_mode ? "|D:1" : "|D:0");
|
||||
|
||||
if(sys.report.tool)
|
||||
if(report.tool)
|
||||
hal.stream.write_all(appendbuf(2, "|T:", uitoa(gc_state.tool->tool)));
|
||||
|
||||
if(sys.report.tlo_reference)
|
||||
if(report.tlo_reference)
|
||||
hal.stream.write_all(appendbuf(2, "|TLR:", uitoa(sys.tlo_reference_set.mask != 0)));
|
||||
|
||||
if(sys.report.m66result && sys.var5399 > -2) { // M66 result
|
||||
if(report.m66result && sys.var5399 > -2) { // M66 result
|
||||
if(sys.var5399 >= 0)
|
||||
hal.stream.write_all(appendbuf(2, "|In:", uitoa(sys.var5399)));
|
||||
else
|
||||
@@ -1344,7 +1345,7 @@ void report_realtime_status (void)
|
||||
grbl.on_realtime_report(hal.stream.write_all, sys.report);
|
||||
|
||||
#if COMPATIBILITY_LEVEL <= 1
|
||||
if(sys.report.all) {
|
||||
if(report.all) {
|
||||
hal.stream.write_all("|FW:grblHAL");
|
||||
if(settings.report_interval) {
|
||||
hal.stream.write_all(sys.flags.auto_reporting ? "|AR:" : "|AR");
|
||||
@@ -1376,14 +1377,15 @@ void report_realtime_status (void)
|
||||
if (is_changed)
|
||||
system_set_exec_state_flag(EXEC_GCODE_REPORT);
|
||||
|
||||
if(sys.report.tool_offset)
|
||||
if(report.tool_offset)
|
||||
system_set_exec_state_flag(EXEC_TLO_REPORT);
|
||||
}
|
||||
|
||||
hal.stream.write_all(">" ASCII_EOL);
|
||||
|
||||
sys.report.value = 0;
|
||||
sys.report.wco = settings.status_report.work_coord_offset && wco_counter == 0; // Set to report on next request
|
||||
system_add_rt_report(Report_ClearAll);
|
||||
if(settings.status_report.work_coord_offset && wco_counter == 0)
|
||||
system_add_rt_report(Report_WCO); // Set to report on next request
|
||||
}
|
||||
|
||||
static void report_bitfield (const char *format, bool bitmap)
|
||||
|
||||
+3
-1
@@ -1279,8 +1279,10 @@ static status_code_t set_axis_setting (setting_id_t setting, float value)
|
||||
break;
|
||||
|
||||
case Setting_AxisMaxTravel:
|
||||
if((sys.report.homed = settings.axis[idx].max_travel != -value))
|
||||
if(settings.axis[idx].max_travel != -value) {
|
||||
bit_false(sys.homed.mask, bit(idx));
|
||||
system_add_rt_report(Report_Homed);
|
||||
}
|
||||
settings.axis[idx].max_travel = -value; // Store as negative for grbl internal use.
|
||||
if(settings.homing.flags.init_lock && (sys.homing.mask & sys.homed.mask) != sys.homing.mask) {
|
||||
system_raise_alarm(Alarm_HomingRequried);
|
||||
|
||||
+3
-2
@@ -451,7 +451,7 @@ void spindle_set_override (spindle_ptrs_t *spindle, override_t speed_override)
|
||||
else
|
||||
sys.step_control.update_spindle_rpm = On;
|
||||
|
||||
sys.report.overrides = On; // Set to report change immediately
|
||||
system_add_rt_report(Report_Overrides); // Set to report change immediately
|
||||
|
||||
if(grbl.on_spindle_programmed)
|
||||
grbl.on_spindle_programmed(spindle, gc_state.modal.spindle.state, spindle_set_rpm(spindle, gc_state.spindle.rpm, speed_override), gc_state.modal.spindle.rpm_mode);
|
||||
@@ -484,7 +484,8 @@ static bool set_state (spindle_ptrs_t *spindle, spindle_state_t state, float rpm
|
||||
|
||||
spindle->set_state(state, spindle_set_rpm(spindle, rpm, spindle->param->override_pct));
|
||||
}
|
||||
sys.report.spindle = On; // Set to report change immediately
|
||||
|
||||
system_add_rt_report(Report_Spindle); // Set to report change immediately
|
||||
|
||||
st_rpm_changed(rpm);
|
||||
}
|
||||
|
||||
+37
-5
@@ -193,9 +193,41 @@ ISR_CODE sys_state_t ISR_FUNC(state_get)(void)
|
||||
return sys_state;
|
||||
}
|
||||
|
||||
uint8_t state_get_substate (void)
|
||||
{
|
||||
uint8_t substate = 0;
|
||||
|
||||
switch(sys_state) {
|
||||
|
||||
case STATE_CYCLE:
|
||||
if(sys.flags.feed_hold_pending)
|
||||
substate = 1;
|
||||
else if(sys.probing_state == Probing_Active || (hal.probe.get_state && hal.probe.get_state().triggered))
|
||||
substate = 2;
|
||||
break;
|
||||
|
||||
case STATE_HOLD:
|
||||
substate = sys.holding_state - 1;
|
||||
break;
|
||||
|
||||
case STATE_ESTOP:
|
||||
case STATE_ALARM:
|
||||
substate = sys.alarm;
|
||||
break;
|
||||
|
||||
case STATE_SAFETY_DOOR:
|
||||
substate = sys.parking_state;
|
||||
break;
|
||||
}
|
||||
|
||||
return substate;
|
||||
}
|
||||
|
||||
void state_set (sys_state_t new_state)
|
||||
{
|
||||
if (new_state != sys_state) {
|
||||
if(new_state != sys_state) {
|
||||
|
||||
sys_state_t org_state = sys_state;
|
||||
|
||||
switch(new_state) { // Set up new state and handler
|
||||
|
||||
@@ -284,11 +316,11 @@ void state_set (sys_state_t new_state)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(sys_state & (STATE_ALARM|STATE_ESTOP)))
|
||||
if(!(sys_state & (STATE_ALARM|STATE_ESTOP)))
|
||||
sys.alarm = Alarm_None;
|
||||
|
||||
if (grbl.on_state_change)
|
||||
grbl.on_state_change(new_state);
|
||||
if(sys_state != org_state && grbl.on_state_change)
|
||||
grbl.on_state_change(sys_state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +422,7 @@ static void state_await_toolchanged (uint_fast16_t rt_exec)
|
||||
if (!gc_state.tool_change) {
|
||||
if (hal.stream.suspend_read)
|
||||
hal.stream.suspend_read(false); // Tool change complete, restore "normal" stream input.
|
||||
sys.report.tool = On;
|
||||
system_add_rt_report(Report_Tool);
|
||||
}
|
||||
pending_state = gc_state.tool_change ? STATE_TOOL_CHANGE : STATE_IDLE;
|
||||
state_set(STATE_IDLE);
|
||||
|
||||
+2
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2018-2021 Terje Io
|
||||
Copyright (c) 2018-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
|
||||
@@ -25,6 +25,7 @@
|
||||
#define _STATE_MACHINE_H_
|
||||
|
||||
sys_state_t state_get (void);
|
||||
uint8_t state_get_substate (void);
|
||||
void state_set (sys_state_t state);
|
||||
void state_update (rt_exec_t rt_exec);
|
||||
bool state_door_reopened (void);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
Part of grblHAL
|
||||
|
||||
Copyright (c) 2021-2022 Terje Io
|
||||
Copyright (c) 2021-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
|
||||
@@ -463,7 +463,7 @@ bool stream_mpg_enable (bool on)
|
||||
hal.stream.reset_read_buffer();
|
||||
|
||||
sys.mpg_mode = on;
|
||||
sys.report.mpg_mode = On;
|
||||
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);
|
||||
|
||||
@@ -549,7 +549,7 @@ static status_code_t output_all_settings (sys_state_t state, char *args)
|
||||
static status_code_t output_parser_state (sys_state_t state, char *args)
|
||||
{
|
||||
report_gcode_modes();
|
||||
sys.report.homed = On; // Report homed state on next realtime report
|
||||
system_add_rt_report(Report_Homed); // Report homed state on next realtime report
|
||||
|
||||
return Status_OK;
|
||||
}
|
||||
@@ -772,7 +772,7 @@ static status_code_t set_tool_reference (sys_state_t state, char *args)
|
||||
} else
|
||||
sys.tlo_reference_set.mask = 0;
|
||||
#endif
|
||||
sys.report.tlo_reference = On;
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
|
||||
return Status_OK;
|
||||
}
|
||||
@@ -968,7 +968,7 @@ void system_flag_wco_change (void)
|
||||
if(grbl.on_wco_changed)
|
||||
grbl.on_wco_changed();
|
||||
|
||||
sys.report.wco = On;
|
||||
system_add_rt_report(Report_WCO);
|
||||
}
|
||||
|
||||
// Sets machine position. Must be sent a 'step' array.
|
||||
@@ -1073,3 +1073,21 @@ void system_raise_alarm (alarm_code_t alarm)
|
||||
grbl.report.alarm_message(alarm);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: encapsulate sys.report
|
||||
|
||||
report_tracking_flags_t system_get_rt_report_flags (void)
|
||||
{
|
||||
return sys.report;
|
||||
}
|
||||
|
||||
void system_add_rt_report (report_tracking_t report)
|
||||
{
|
||||
if(report == Report_ClearAll)
|
||||
sys.report.value = 0;
|
||||
else
|
||||
sys.report.value |= (uint32_t)report;
|
||||
|
||||
if(sys.report.value && grbl.on_rt_reports_added)
|
||||
grbl.on_rt_reports_added((report_tracking_flags_t)((uint32_t)report));
|
||||
}
|
||||
|
||||
@@ -164,6 +164,28 @@ typedef struct {
|
||||
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
Report_ClearAll = 0,
|
||||
Report_MPGMode = (1 << 0),
|
||||
Report_Scaling = (1 << 1),
|
||||
Report_Homed = (1 << 2),
|
||||
Report_LatheXMode = (1 << 3),
|
||||
Report_Spindle = (1 << 4),
|
||||
Report_Coolant = (1 << 5),
|
||||
Report_Overrides = (1 << 6),
|
||||
Report_Tool = (1 << 7),
|
||||
Report_WCO = (1 << 8),
|
||||
Report_GWCO = (1 << 9),
|
||||
Report_ToolOffset = (1 << 10),
|
||||
Report_M66Result = (1 << 11),
|
||||
Report_PWM = (1 << 12),
|
||||
Report_Motor = (1 << 13),
|
||||
Report_Encoder = (1 << 14),
|
||||
Report_TLOReference = (1 << 15),
|
||||
Report_Fan = (1 << 16),
|
||||
Report_All = 0x8001FFFF
|
||||
} report_tracking_t;
|
||||
|
||||
typedef union {
|
||||
uint32_t value;
|
||||
struct {
|
||||
@@ -192,7 +214,7 @@ typedef union {
|
||||
typedef struct {
|
||||
override_t feed_rate; //!< Feed rate override value in percent
|
||||
override_t rapid_rate; //!< Rapids override value in percent
|
||||
// Spindle override has been moved to per spindle in spindle_param_t
|
||||
override_t spindle_rpm; //!< __NOTE:_ Not used by the core, it maintain per spindle override in \ref spindle_param_t
|
||||
spindle_stop_t spindle_stop; //!< Tracks spindle stop override states
|
||||
gc_override_flags_t control; //!< Tracks override control states.
|
||||
} overrides_t;
|
||||
@@ -311,6 +333,9 @@ void system_raise_alarm (alarm_code_t alarm);
|
||||
//! Provide system command help
|
||||
void system_command_help (void);
|
||||
|
||||
void system_add_rt_report (report_tracking_t report);
|
||||
report_tracking_flags_t system_get_rt_report_flags (void);
|
||||
|
||||
// Special handlers for setting and clearing Grbl's real-time execution flags.
|
||||
#define system_set_exec_state_flag(mask) hal.set_bits_atomic(&sys.rt_exec_state, (mask))
|
||||
#define system_clear_exec_state_flag(mask) hal.clear_bits_atomic(&sys.rt_exec_state, (mask))
|
||||
|
||||
+16
-8
@@ -93,11 +93,15 @@ static void reset (void)
|
||||
if(next_tool) { //TODO: move to gc_xxx() function?
|
||||
// Restore previous tool if reset is during change
|
||||
#if N_TOOLS
|
||||
if((sys.report.tool = current_tool.tool != next_tool->tool))
|
||||
if(current_tool.tool != next_tool->tool) {
|
||||
memcpy(gc_state.tool, ¤t_tool, sizeof(tool_data_t));
|
||||
system_add_rt_report(Report_Tool);
|
||||
}
|
||||
#else
|
||||
if((sys.report.tool = current_tool.tool != next_tool->tool))
|
||||
if(current_tool.tool != next_tool->tool) {
|
||||
memcpy(next_tool, ¤t_tool, sizeof(tool_data_t));
|
||||
system_add_rt_report(Report_Tool);
|
||||
}
|
||||
#endif
|
||||
gc_state.tool_pending = gc_state.tool->tool;
|
||||
next_tool = NULL;
|
||||
@@ -217,7 +221,7 @@ static void execute_probe (sys_state_t state)
|
||||
if(!(sys.tlo_reference_set.mask & bit(plane.axis_linear))) {
|
||||
sys.tlo_reference[plane.axis_linear] = sys.probe_position[plane.axis_linear];
|
||||
sys.tlo_reference_set.mask |= bit(plane.axis_linear);
|
||||
sys.report.tlo_reference = On;
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
grbl.report.feedback_message(Message_ReferenceTLOEstablished);
|
||||
} else
|
||||
gc_set_tool_offset(ToolLengthOffset_EnableDynamic, plane.axis_linear,
|
||||
@@ -404,10 +408,12 @@ void tc_init (void)
|
||||
if(!hal.stream.suspend_read) // Tool change requires support for suspending input stream.
|
||||
return;
|
||||
|
||||
sys.report.tlo_reference = sys.tlo_reference_set.mask != 0;
|
||||
sys.tlo_reference_set.mask = 0;
|
||||
if(sys.tlo_reference_set.mask != 0) {
|
||||
sys.tlo_reference_set.mask = 0;
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
}
|
||||
|
||||
gc_set_tool_offset(ToolLengthOffset_Cancel, 0, 0.0f);
|
||||
gc_set_tool_offset(ToolLengthOffset_Cancel, 0, 0.0f);
|
||||
|
||||
if(settings.tool_change.mode == ToolChange_Disabled || settings.tool_change.mode == ToolChange_Ignore) {
|
||||
hal.tool.select = NULL;
|
||||
@@ -436,8 +442,10 @@ void tc_clear_tlo_reference (axes_signals_t homing_cycle)
|
||||
gc_get_plane_data(&plane, gc_state.modal.plane_select);
|
||||
#endif
|
||||
if(homing_cycle.mask & (settings.mode == Mode_Lathe ? (X_AXIS_BIT|Z_AXIS_BIT) : bit(plane.axis_linear))) {
|
||||
sys.report.tlo_reference = sys.tlo_reference_set.mask != 0;
|
||||
sys.tlo_reference_set.mask = 0; // Invalidate tool length offset reference
|
||||
if(sys.tlo_reference_set.mask != 0) {
|
||||
sys.tlo_reference_set.mask = 0; // Invalidate tool length offset reference
|
||||
system_add_rt_report(Report_TLOReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user