diff --git a/planner.c b/planner.c index d554ba6..0a62267 100644 --- a/planner.c +++ b/planner.c @@ -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)); diff --git a/planner.h b/planner.h index 33864c3..ed06b8b 100644 --- a/planner.h +++ b/planner.h @@ -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. diff --git a/report.c b/report.c index 6974887..4e249ad 100644 --- a/report.c +++ b/report.c @@ -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,19 @@ void report_realtime_status (stream_write_ptr stream_write) stream_write(appendbuf(2, "|Ln:", uitoa((uint32_t)cur_block->line_number))); } + // Report distance remaining as 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]; + } + // Report distance to go + hal.stream.write_all("|DToGo:"); + hal.stream.write_all(get_axis_values(dist_remaining)); + } + spindle_ptrs_t *spindle_0; spindle_state_t spindle_0_state;