Merge pull request #802 from engigeer/PR_dist_to_go

Add realtime report of distance-to-go
This commit is contained in:
Terje Io
2025-09-10 20:22:45 +02:00
committed by GitHub
6 changed files with 31 additions and 3 deletions
+9
View File
@@ -730,6 +730,15 @@ Enabling this setting enables status reporting while homing.
#define DEFAULT_REPORT_WHEN_HOMING Off // Default off. Set to \ref On or 1 to enable.
#endif
/*! \def DEFAULT_REPORT_DISTANCE_TO_GO
\brief
If set to \ref Off or 0 the `|DTG:` distance-to-go element is not included in the real time report.
\internal Bit 13 in settings.status_report.
*/
#if !defined DEFAULT_REPORT_DISTANCE_TO_GO || defined __DOXYGEN__
#define DEFAULT_REPORT_DISTANCE_TO_GO On // Default on. Set to \ref Off or 0 to disable.
#endif
///@}
/*! @name $11 - Setting_JunctionDeviation
+1
View File
@@ -417,6 +417,7 @@ bool plan_buffer_line (float *target, plan_line_data_t *pl_data)
block->offset_id = pl_data->offset_id;
block->output_commands = pl_data->output_commands;
block->message = pl_data->message;
memcpy(block->target_mm, target, sizeof(float) * N_AXIS);
// Copy position data based on type of motion being planned.
memcpy(position_steps, block->condition.system_motion ? sys.position : pl.position, sizeof(position_steps));
+1
View File
@@ -82,6 +82,7 @@ typedef struct plan_block {
gc_override_flags_t overrides; // Block bitfield variable for overrides
planner_cond_t condition; // Block bitfield variable defining block run conditions. Copied from pl_line_data.
int32_t line_number; // Block line number for real-time reporting. Copied from pl_line_data.
float target_mm[N_AXIS]; // Block target end location in mm for real-time reporting of distance to go.
// Fields used by the motion planner to manage acceleration. Some of these values may be updated
// by the stepper module during execution of special motion cases for replanning purposes.
+16 -1
View File
@@ -1154,7 +1154,7 @@ void report_realtime_status (stream_write_ptr stream_write)
static bool probing = false;
uint_fast8_t idx;
float print_position[N_AXIS], wco[N_AXIS];
float print_position[N_AXIS], wco[N_AXIS], dist_remaining[N_AXIS];
report_tracking_flags_t report = system_get_rt_report_flags(), delayed_report = {};
probe_state_t probe_state = {
.connected = On,
@@ -1254,6 +1254,21 @@ void report_realtime_status (stream_write_ptr stream_write)
stream_write(appendbuf(2, "|Ln:", uitoa((uint32_t)cur_block->line_number)));
}
if(settings.status_report.distance_to_go) {
// Report distance-to-go in current block (i.e., difference between target / end-of-block) and current position)
plan_block_t *cur_block = plan_get_current_block();
if (cur_block != NULL) {
system_convert_array_steps_to_mpos(dist_remaining, sys.position);
for(idx = 0; idx < N_AXIS; idx++) {
dist_remaining[idx] = cur_block->target_mm[idx] - dist_remaining[idx];
}
hal.stream.write_all("|DTG:");
hal.stream.write_all(get_axis_values(dist_remaining));
}
}
spindle_ptrs_t *spindle_0;
spindle_state_t spindle_0_state;
+2 -1
View File
@@ -162,6 +162,7 @@ PROGMEM const settings_t defaults = {
.status_report.alarm_substate = DEFAULT_REPORT_ALARM_SUBSTATE,
.status_report.run_substate = DEFAULT_REPORT_RUN_SUBSTATE,
.status_report.when_homing = DEFAULT_REPORT_WHEN_HOMING,
.status_report.distance_to_go = DEFAULT_REPORT_DISTANCE_TO_GO,
.limits.flags.hard_enabled = DEFAULT_HARD_LIMIT_ENABLE,
.limits.flags.jog_soft_limited = DEFAULT_JOG_LIMIT_ENABLE,
.limits.flags.check_at_init = DEFAULT_CHECK_LIMITS_AT_INIT,
@@ -2014,7 +2015,7 @@ PROGMEM static const setting_detail_t setting_detail[] = {
{ Setting_GangedDirInvertMask, Group_Stepper, "Ganged axes direction invert", NULL, Format_Bitfield, ganged_axes, NULL, NULL, Setting_IsExtendedFn, set_ganged_dir_invert, get_int, is_setting_available },
{ Setting_SpindlePWMOptions, Group_Spindle, "PWM spindle options", NULL, Format_XBitfield, "Enable,RPM controls spindle enable signal,Disable laser mode capability", NULL, NULL, Setting_IsExtendedFn, set_pwm_options, get_int, is_setting_available },
#if COMPATIBILITY_LEVEL <= 1
{ Setting_StatusReportMask, Group_General, "Status report options", NULL, Format_Bitfield, "Position in machine coordinate,Buffer state,Line numbers,Feed & speed,Pin state,Work coordinate offset,Overrides,Probe coordinates,Buffer sync on WCO change,Parser state,Alarm substatus,Run substatus,Enable when homing", NULL, NULL, Setting_IsExtendedFn, set_report_mask, get_int, NULL },
{ Setting_StatusReportMask, Group_General, "Status report options", NULL, Format_Bitfield, "Position in machine coordinate,Buffer state,Line numbers,Feed & speed,Pin state,Work coordinate offset,Overrides,Probe coordinates,Buffer sync on WCO change,Parser state,Alarm substatus,Run substatus,Enable when homing,Distance-to-go", NULL, NULL, Setting_IsExtendedFn, set_report_mask, get_int, NULL },
#else
{ Setting_StatusReportMask, Group_General, "Status report options", NULL, Format_Bitfield, "Position in machine coordinate,Buffer state", NULL, NULL, Setting_IsLegacyFn, set_report_mask, get_int, NULL },
#endif
+2 -1
View File
@@ -641,7 +641,8 @@ typedef union {
alarm_substate :1,
run_substate :1,
when_homing :1,
unassigned :3;
distance_to_go :1,
unassigned :2;
};
} reportmask_t;