Skip to content

Commit

Permalink
🔀 add FormerLurker's and eyal0's g2/g3 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vdidon committed Nov 27, 2021
2 parents 5be77ca + df0ab12 commit 869222e
Show file tree
Hide file tree
Showing 16 changed files with 441 additions and 249 deletions.
262 changes: 151 additions & 111 deletions Firmware/ConfigurationStore.cpp

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Firmware/ConfigurationStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ typedef struct
float max_feedrate_silent[4]; //!< max speeds for silent mode
unsigned long max_acceleration_units_per_sq_second_silent[4];
unsigned char axis_ustep_resolution[4];
// Arc Interpolation Settings, configurable via M214
float mm_per_arc_segment;
float min_mm_per_arc_segment;
uint8_t n_arc_correction; // If equal to zero, this is disabled
uint16_t min_arc_segments; // If equal to zero, this is disabled
uint16_t arc_segments_per_sec; // If equal to zero, this is disabled
} M500_conf;

extern M500_conf cs;
Expand All @@ -62,4 +68,7 @@ inline uint8_t calibration_status() { return eeprom_read_byte((uint8_t*)EEPROM_C
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); }

bool is_setting_initialized(float setting_value);
bool is_setting_initialized(uint8_t setting_value);
bool is_setting_initialized(uint16_t setting_value);
#endif//CONFIG_STORE_H
4 changes: 1 addition & 3 deletions Firmware/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@
//#define LA_DEBUG_LOGIC // @wavexx: setup logic channels for isr debugging
#endif

// Arc interpretation settings:
#define MM_PER_ARC_SEGMENT 1
#define N_ARC_CORRECTION 25
// Arc interpretation settings : Moded to printer default settings (Configuration_prusa.h)

const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement

Expand Down
2 changes: 1 addition & 1 deletion Firmware/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ void repeatcommand_front();
// Remove all lines from the command queue.
void cmdqueue_reset();

void prepare_arc_move(bool isclockwise);
void prepare_arc_move(char isclockwise);
void clamp_to_software_endstops(float target[3]);
void refresh_cmd_timeout(void);

Expand Down
72 changes: 53 additions & 19 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3494,6 +3494,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<MM_PER_ARC_SEGMENT> S<MIN_MM_PER_ARC_SEGMENT> R<MIN_ARC_SEGMENTS> F<ARC_SEGMENTS_PER_SEC>
//!@n M218 - set hotend offset (in mm): T<extruder_number> X<offset_on_X> Y<offset_on_Y>
//!@n M220 S<factor in percent>- set speed factor override percentage
//!@n M221 S<factor in percent>- set extrude factor override percentage
Expand Down Expand Up @@ -4158,6 +4159,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
#### Parameters
- `X` - The position to move to on the X axis
- `Y` - The position to move to on the Y axis
- 'Z' - The position to move to on the Z axis
- `I` - The point in X space from the current X position to maintain a constant distance from
- `J` - The point in Y space from the current Y position to maintain a constant distance from
- `E` - The amount to extrude between the starting point and ending point
Expand Down Expand Up @@ -7163,12 +7165,50 @@ SERIAL_PROTOCOLPGM("\n\n");
}
}


}break;
#endif // FWRETRACT
/*!
### M214 - Set Arc configuration values (Use M500 to store in eeprom)

#### Usage

M214 [P] [S] [N] [R] [F]

#### Parameters
- `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
- `N` - An int representing the number of arcs to draw before correcting the small angle approximation. 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
and maximum segment length. Set to 0 to disable.
- '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) P<MM_PER_ARC_SEGMENT> S<MIN_MM_PER_ARC_SEGMENT> R<MIN_ARC_SEGMENTS> F<ARC_SEGMENTS_PER_SEC>
{
// Extract all possible parameters if they appear
float p = code_seen('P') ? code_value_float() : cs.mm_per_arc_segment;
float s = code_seen('S') ? code_value_float() : cs.min_mm_per_arc_segment;
uint8_t n = code_seen('N') ? code_value() : cs.n_arc_correction;
uint16_t r = code_seen('R') ? code_value() : cs.min_arc_segments;
uint16_t f = code_seen('F') ? code_value() : cs.arc_segments_per_sec;

// Ensure mm_per_arc_segment is greater than 0, and that min_mm_per_arc_segment is sero or greater than or equal to mm_per_arc_segment
if (p <=0 || s < 0 || p < s)
{
break;
}
break;
#endif // FWRETRACT
#if EXTRUDERS > 1

/*!
cs.mm_per_arc_segment = p;
cs.min_mm_per_arc_segment = s;
cs.n_arc_correction = n;
cs.min_arc_segments = r;
cs.arc_segments_per_sec = f;
}break;
#if EXTRUDERS > 1

/*!
### M218 - Set hotend offset <a href="https://reprap.org/wiki/G-code#M218:_Set_Hotend_Offset">M218: Set Hotend Offset</a>
In Prusa Firmware this G-code is only active if `EXTRUDERS` is higher then 1 in the source code. On Original i3 Prusa MK2/s MK2.5/s MK3/s it is not active.
#### Usage
Expand Down Expand Up @@ -9177,21 +9217,15 @@ void prepare_move() {
set_current_to_destination();
}

void prepare_arc_move(bool isclockwise) {
float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc

// Trace the arc
mc_arc(current_position, destination, offset, X_AXIS, Y_AXIS, Z_AXIS, feedrate * feedmultiply / 60 / 100.0, r,
isclockwise, active_extruder);

// As far as the parser is concerned, the position is now == target. In reality the
// motion control system might still be processing the action and the real tool position
// in any intermediate location.
/*for (int8_t i = 0; i < NUM_AXIS; i++) {
current_position[i] = destination[i];
}*/
set_current_to_destination();
previous_millis_cmd = _millis();
void prepare_arc_move(char isclockwise) {
float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc
// Trace the arc
mc_arc(current_position, destination, offset, feedrate * feedmultiply * (1. / (60.f * 100.f)), r, isclockwise, active_extruder);
// As far as the parser is concerned, the position is now == target. In reality the
// motion control system might still be processing the action and the real tool position
// in any intermediate location.
set_current_to_destination();
previous_millis_cmd = _millis();
}

#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
Expand Down
Loading

0 comments on commit 869222e

Please sign in to comment.