diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index ea2dcc47..1ad9d1e0 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -171,7 +171,7 @@ void Config_PrintSettings(uint8_t level) } // Arc Interpolation Settings printf_P(PSTR( - "%SArc Settings: N=Arc segment length max (mm) S=Arc segment length Min (mm), R=Min arc segments, F=Arc segments per second.\n%S M214 N%.2f S%.2f R%d F%d\n"), + "%SArc Settings: P=Arc segment length max (mm) S=Arc segment length Min (mm), R=Min arc segments, F=Arc segments per second.\n%S M214 P%.2f S%.2f R%d F%d\n"), echomagic, echomagic, cs.mm_per_arc_segment, cs.min_mm_per_arc_segment, cs.min_arc_segments, cs.arc_segments_per_sec); } #endif @@ -282,10 +282,11 @@ bool Config_RetrieveSettings() } } // Initialize arc interpolation settings if they are not already (Not sure about this bit, please review) - if (0xff == cs.mm_per_arc_segment) cs.mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT; - if (0xff == cs.min_mm_per_arc_segment) cs.min_mm_per_arc_segment = DEFAULT_MIN_MM_PER_ARC_SEGMENT; - if (0xff == cs.min_arc_segments) cs.min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS; - if (0xff == cs.arc_segments_per_sec) cs.arc_segments_per_sec = DEFAULT_ARC_SEGMENTS_PER_SEC; + if (is_uninitialized(cs.mm_per_arc_segment, sizeof(float))) cs.mm_per_arc_segment = DEFAULT_MM_PER_ARC_SEGMENT; + if (is_uninitialized(cs.min_mm_per_arc_segment, sizeof(float))) cs.min_mm_per_arc_segment = DEFAULT_MIN_MM_PER_ARC_SEGMENT; + if (is_uninitialized(cs.min_arc_segments, sizeof(uint16_t))) cs.min_arc_segments = DEFAULT_MIN_ARC_SEGMENTS; + if (is_uninitialized(cs.arc_segments_per_sec, sizeof(uint16_t))) cs.arc_segments_per_sec = DEFAULT_ARC_SEGMENTS_PER_SEC; + #ifdef TMC2130 for (uint8_t j = X_AXIS; j <= Y_AXIS; j++) @@ -357,3 +358,4 @@ SERIAL_ECHO_START; SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded"); } + diff --git a/Firmware/ConfigurationStore.h b/Firmware/ConfigurationStore.h index 26a835a2..bf768db3 100644 --- a/Firmware/ConfigurationStore.h +++ b/Firmware/ConfigurationStore.h @@ -42,8 +42,8 @@ typedef struct // Arc Interpolation Settings, configurable via M214 float mm_per_arc_segment; float min_mm_per_arc_segment; - int min_arc_segments; // If less than or equal to zero, this is disabled - int arc_segments_per_sec; // If less than or equal to zero, this is disabled + uint16_t min_arc_segments; // If less than or equal to zero, this is disabled + uint16_t arc_segments_per_sec; // If less than or equal to zero, this is disabled } M500_conf; extern M500_conf cs; @@ -67,5 +67,4 @@ FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_Prin inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS); } inline void calibration_status_store(uint8_t status) { eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS, status); } inline bool calibration_status_pinda() { return eeprom_read_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA); } - #endif//CONFIG_STORE_H diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index eedcf3fa..7de7fe61 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4162,6 +4162,7 @@ extern uint8_t st_backlash_y; //!@n M207 - set retract length S[positive mm] F[feedrate mm/min] Z[additional zlift/hop], stays in mm regardless of M200 setting //!@n M208 - set recover=unretract length S[positive mm surplus to the M207 S*] F[feedrate mm/sec] //!@n M209 - S<1=true/0=false> enable automatic retract detect if the slicer did not support G10/11: every normal extrude-only move will be classified as retract depending on the direction. +//!@n M214 - Set Arc Parameters (Use M500 to store in eeprom) P S R F //!@n M218 - set hotend offset (in mm): T X Y //!@n M220 S- set speed factor override percentage //!@n M221 S- set extrude factor override percentage @@ -7508,10 +7509,10 @@ Sigma_Exit: #### Usage - M214 [N] [S] [R] [F] + M214 [P] [S] [R] [F] #### Parameters - - `N` - A float representing the max and default millimeters per arc segment. Must be greater than 0. + - `P` - A float representing the max and default millimeters per arc segment. Must be greater than 0. - `S` - A float representing the minimum allowable millimeters per arc segment. Set to 0 to disable - `R` - An int representing the minimum number of segments per arcs of any radius, except when the results in segment lengths greater than or less than the minimum @@ -7519,36 +7520,29 @@ Sigma_Exit: - 'F' - An int representing the number of segments per second, unless this results in segment lengths greater than or less than the minimum and maximum segment length. Set to 0 to disable. */ - case 214: //!@n M214 - Set Arc Parameters (Use M500 to store in eeprom) N S R F + case 214: //!@n M214 - Set Arc Parameters (Use M500 to store in eeprom) P S R F { // Extract N - float n = cs.mm_per_arc_segment; + float p = cs.mm_per_arc_segment; float s = cs.min_mm_per_arc_segment; - int r = cs.min_arc_segments; - int f = cs.arc_segments_per_sec; + uint16_t r = cs.min_arc_segments; + uint16_t f = cs.arc_segments_per_sec; + // Extract N - if (code_seen('N')) + if (code_seen('P')) { - n = code_value(); - if (n <= 0 || (s != 0 && n <= s)) + p = code_value_float(); + if (p <= 0 || (s != 0 && p <= s)) { - SERIAL_ECHO_START; - SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND); - SERIAL_ECHO(CMDBUFFER_CURRENT_STRING); - SERIAL_ECHOLNPGM("\"(1)"); break; } } // Extract S if (code_seen('S')) { - s = code_value(); - if (s < 0 || s >= n) + s = code_value_float(); + if (s < 0 || s >= p) { - SERIAL_ECHO_START; - SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND); - SERIAL_ECHO(CMDBUFFER_CURRENT_STRING); - SERIAL_ECHOLNPGM("\"(1)"); break; } } @@ -7559,10 +7553,6 @@ Sigma_Exit: r = code_value(); if (r < 0) { - SERIAL_ECHO_START; - SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND); - SERIAL_ECHO(CMDBUFFER_CURRENT_STRING); - SERIAL_ECHOLNPGM("\"(1)"); break; } } @@ -7572,14 +7562,10 @@ Sigma_Exit: f = code_value(); if (f < 0) { - SERIAL_ECHO_START; - SERIAL_ECHORPGM(MSG_UNKNOWN_COMMAND); - SERIAL_ECHO(CMDBUFFER_CURRENT_STRING); - SERIAL_ECHOLNPGM("\"(1)"); break; } } - cs.mm_per_arc_segment = n; + cs.mm_per_arc_segment = p; cs.min_mm_per_arc_segment = s; cs.min_arc_segments = r; cs.arc_segments_per_sec = f; diff --git a/Firmware/motion_control.cpp b/Firmware/motion_control.cpp index 3b52b4d5..8524e2fc 100644 --- a/Firmware/motion_control.cpp +++ b/Firmware/motion_control.cpp @@ -28,26 +28,15 @@ // segment is configured in settings.mm_per_arc_segment. void mc_arc(float* position, float* target, float* offset, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder) { - // Extract the position to reduce indexing at the cost of a few bytes of mem - float p_x = position[X_AXIS]; - float p_y = position[Y_AXIS]; - float p_z = position[Z_AXIS]; - float p_e = position[E_AXIS]; - - float t_x = target[X_AXIS]; - float t_y = target[Y_AXIS]; - float t_z = target[Z_AXIS]; - float t_e = target[E_AXIS]; - float r_axis_x = -offset[X_AXIS]; // Radius vector from center to current location float r_axis_y = -offset[Y_AXIS]; - float center_axis_x = p_x - r_axis_x; - float center_axis_y = p_y - r_axis_y; - float travel_z = t_z - p_z; - float extruder_travel_total = t_e - p_e; + float center_axis_x = position[X_AXIS] - r_axis_x; + float center_axis_y = position[Y_AXIS] - r_axis_y; + float travel_z = target[Z_AXIS] - position[Z_AXIS]; + float extruder_travel_total = target[E_AXIS] - position[E_AXIS]; - float rt_x = t_x - center_axis_x; - float rt_y = t_y - center_axis_y; + float rt_x = target[X_AXIS] - center_axis_x; + float rt_y = target[Y_AXIS] - center_axis_y; // 20200419 - Add a variable that will be used to hold the arc segment length float mm_per_arc_segment = cs.mm_per_arc_segment; @@ -90,7 +79,7 @@ void mc_arc(float* position, float* target, float* offset, float feed_rate, floa //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving //to compensate when start pos = target pos && angle is zero -> angle = 2Pi - if (p_x == t_x && p_y == t_y && angular_travel_total == 0) + if (position[X_AXIS] == target[X_AXIS] && position[Y_AXIS] == target[Y_AXIS] && angular_travel_total == 0) { angular_travel_total += 2 * M_PI; } @@ -148,18 +137,18 @@ void mc_arc(float* position, float* target, float* offset, float feed_rate, floa r_axis_y = r_axisi; // Update arc_target location - p_x = center_axis_x + r_axis_x; - p_y = center_axis_y + r_axis_y; - p_z += linear_per_segment; - p_e += segment_extruder_travel; + position[X_AXIS] = center_axis_x + r_axis_x; + position[Y_AXIS] = center_axis_y + r_axis_y; + position[Z_AXIS] += linear_per_segment; + position[E_AXIS] += segment_extruder_travel; // We can't clamp to the target because we are interpolating! We would need to update a position, clamp to it // after updating from calculated values. - //clamp_to_software_endstops(position); - plan_buffer_line(p_x, p_y, p_z, p_e, feed_rate, extruder); + clamp_to_software_endstops(position); + plan_buffer_line(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS], feed_rate, extruder); } } // Ensure last segment arrives at target location. // Here we could clamp, but why bother. We would need to update our current position, clamp to it - //clamp_to_software_endstops(target); - plan_buffer_line(t_x, t_y, t_z, t_e, feed_rate, extruder); + clamp_to_software_endstops(target); + plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, extruder); }