mirror of
https://github.com/synthetos/g2.git
synced 2026-09-26 09:03:37 +08:00
Checkpoint. Passes G28 and G53 tests
This commit is contained in:
@@ -367,7 +367,7 @@ void cm_set_tool_number(GCodeState_t *gcode_state, const uint8_t tool)
|
||||
void cm_set_absolute_override(GCodeState_t *gcode_state, const uint8_t absolute_override)
|
||||
{
|
||||
gcode_state->absolute_override = (cmAbsoluteOverride)absolute_override;
|
||||
// cm_set_work_offsets(MODEL); // must reset offsets if you change absolute override
|
||||
cm_set_work_offsets(MODEL); // must reset offsets if you change absolute override
|
||||
}
|
||||
|
||||
void cm_set_model_linenum(const uint32_t linenum)
|
||||
@@ -410,16 +410,22 @@ void cm_set_model_linenum(const uint32_t linenum)
|
||||
* which merely returns what's in the work_offset[] array.
|
||||
*
|
||||
* Takes G5x, G92 into account to return the active offset for this move.
|
||||
* If absolute_override is provided and is ON it will zero offsets for an absolute override move.
|
||||
* If you don;t want that, just set absolute_override false in the function call.
|
||||
*
|
||||
* Absolute Override is the Gcode G53 convention to allow one and only one Gcode block
|
||||
* to be run in absolute coordinates, regardless of coordinate offsets, G92 offsets, and
|
||||
* tool offsets. If absolute_override is set to ABSOLUTE_OVERRIDE_ON_AND_DISPLAY this
|
||||
* function will return 0.0 for the offset value. This bit is here to support G28 and G30
|
||||
* return moves and other moves that run in absolute override mode but may want position
|
||||
* to be reported using all current offsets (work offsets), versus an explicit G53 move that
|
||||
* should be displayed in absolute coordinates.
|
||||
*/
|
||||
|
||||
float cm_get_active_coord_offset(const uint8_t axis, const bool use_absolute_override)
|
||||
float cm_get_active_coord_offset(const uint8_t axis, const bool absolute)
|
||||
{
|
||||
if (use_absolute_override) {
|
||||
if (cm->gm.absolute_override == use_absolute_override) { // no offset if in absolute override mode
|
||||
return (0.0);
|
||||
}
|
||||
// if absolute override is on and is to be displayed with no offsets:
|
||||
// if (cm->gm.absolute_override == ABSOLUTE_OVERRIDE_ON_AND_DISPLAY) {
|
||||
if (absolute & (cm->gm.absolute_override == ABSOLUTE_OVERRIDE_ON)) {
|
||||
return (0.0);
|
||||
}
|
||||
float offset = cm->offset[cm->gm.coord_system][axis] + cm->tl_offset[axis];
|
||||
if (cm->gmx.origin_offset_enable == true) {
|
||||
@@ -823,7 +829,7 @@ stat_t cm_set_arc_distance_mode(const uint8_t mode)
|
||||
* during the Gcode cycle. The persist flag is used to persist offsets once the cycle
|
||||
* has ended. You can also use $g54x - $g59c config functions to change offsets.
|
||||
*
|
||||
* It also does not reset the work_offsets which may be accomplished by calling
|
||||
* It also does not reset the work offsets which may be accomplished by calling
|
||||
* cm_set_work_offsets() immediately afterwards.
|
||||
*/
|
||||
|
||||
@@ -934,6 +940,7 @@ stat_t cm_cancel_tl_offset()
|
||||
stat_t cm_set_coord_system(const uint8_t coord_system) // set coordinate system sync'd with planner
|
||||
{
|
||||
cm->gm.coord_system = (cmCoordSystem)coord_system;
|
||||
cm_set_work_offsets(MODEL); // must reset offsets if you change coordinate system //++++++
|
||||
|
||||
float value[] = { (float)coord_system };
|
||||
mp_queue_command(_exec_offset, value, nullptr);
|
||||
@@ -949,7 +956,6 @@ static void _exec_offset(float *value, bool *flag)
|
||||
(cm->gmx.origin_offset[axis] * cm->gmx.origin_offset_enable);
|
||||
}
|
||||
mp_set_runtime_work_offset(offsets);
|
||||
cm_set_work_offsets(MODEL); // set work offsets in the Gcode model
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1138,7 +1144,7 @@ stat_t _goto_stored_position(const float stored_position[], // always in mm
|
||||
// If G20 adjust stored position (always in mm) to inches so traverse will be correct
|
||||
float target[AXES]; // make a local stored position as it may be modified
|
||||
copy_vector(target, stored_position);
|
||||
if (cm->gm.units_mode == INCHES) {
|
||||
if (cm->gm.units_mode == INCHES) {
|
||||
for (uint8_t i=0; i<AXES; i++) {
|
||||
target[i] *= INCHES_PER_MM;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ void cm_set_absolute_override(GCodeState_t *gcode_state, const uint8_t absolute_
|
||||
void cm_set_model_linenum(const uint32_t linenum);
|
||||
|
||||
// Coordinate systems and offsets
|
||||
float cm_get_active_coord_offset(const uint8_t axis, const bool use_absolute_override);
|
||||
float cm_get_active_coord_offset(const uint8_t axis, const bool absolute);
|
||||
float cm_get_work_offset(const GCodeState_t *gcode_state, const uint8_t axis);
|
||||
void cm_set_work_offsets(GCodeState_t *gcode_state);
|
||||
float cm_get_absolute_position(const GCodeState_t *gcode_state, const uint8_t axis);
|
||||
|
||||
@@ -324,6 +324,7 @@ static stat_t _probe_axis_move(const float target[], bool exact_position) {
|
||||
if (exact_position) {
|
||||
cm->gm.units_mode = stored_units_mode;
|
||||
cm->gm.distance_mode = stored_distance_mode;
|
||||
cm_set_absolute_override(MODEL, ABSOLUTE_OVERRIDE_OFF); // ++++
|
||||
}
|
||||
|
||||
// the last two arguments are ignored anyway
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<InterfaceName>SWD</InterfaceName>
|
||||
</ToolOptions>
|
||||
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
|
||||
<ToolNumber>J41800036434</ToolNumber>
|
||||
<ToolNumber>J41800030015</ToolNumber>
|
||||
<ToolName>Atmel-ICE</ToolName>
|
||||
</com_atmel_avrdbg_tool_atmelice>
|
||||
<UseGdb>True</UseGdb>
|
||||
@@ -100,7 +100,7 @@
|
||||
<HWProgramCounterSampling>True</HWProgramCounterSampling>
|
||||
</PercepioTrace>
|
||||
<preserveEEPROM>true</preserveEEPROM>
|
||||
<avrtoolserialnumber>J41800036434</avrtoolserialnumber>
|
||||
<avrtoolserialnumber>J41800030015</avrtoolserialnumber>
|
||||
<avrdeviceexpectedsignature>0x284E0A60</avrdeviceexpectedsignature>
|
||||
<avrtoolinterfaceclock>10000000</avrtoolinterfaceclock>
|
||||
<custom>
|
||||
|
||||
+4
-3
@@ -119,8 +119,9 @@ typedef enum {
|
||||
#define COORD_SYSTEM_MAX G59 // set this manually to the last one
|
||||
|
||||
typedef enum {
|
||||
ABSOLUTE_OVERRIDE_OFF = 0,// G53 enabled
|
||||
ABSOLUTE_OVERRIDE_ON
|
||||
ABSOLUTE_OVERRIDE_OFF = 0, // G53 disabled
|
||||
ABSOLUTE_OVERRIDE_ON, // G53 enabled for movement
|
||||
ABSOLUTE_OVERRIDE_ON_AND_DISPLAY // G53 enabled for movement and display
|
||||
} cmAbsoluteOverride;
|
||||
|
||||
typedef enum { // G Modal Group 13
|
||||
@@ -215,7 +216,7 @@ typedef struct GCodeState { // Gcode model state - used by model, pl
|
||||
|
||||
float target[AXES]; // XYZABC where the move should go
|
||||
float target_comp[AXES]; // summation compensation (Kahan) overflow value
|
||||
float work_offset[AXES]; // offset from the work coordinate system (for reporting only)
|
||||
float work_offset[AXES]; // work offsets from the machine coordinate system (for reporting only)
|
||||
|
||||
float feed_rate; // F - normalized to millimeters/minute or in inverse time mode
|
||||
float P_word; // P - parameter used for dwell time in seconds, G10 coord select...
|
||||
|
||||
@@ -580,7 +580,7 @@ static stat_t _parse_gcode_block(char *buf, char *active_comment)
|
||||
break;
|
||||
}
|
||||
case 49: SET_NON_MODAL (next_action, NEXT_ACTION_CANCEL_TL_OFFSET);
|
||||
case 53: SET_NON_MODAL (absolute_override, true);
|
||||
case 53: SET_NON_MODAL (absolute_override, ABSOLUTE_OVERRIDE_ON_AND_DISPLAY);
|
||||
case 54: SET_MODAL (MODAL_GROUP_G12, coord_system, G54);
|
||||
case 55: SET_MODAL (MODAL_GROUP_G12, coord_system, G55);
|
||||
case 56: SET_MODAL (MODAL_GROUP_G12, coord_system, G56);
|
||||
@@ -826,7 +826,7 @@ static stat_t _execute_gcode_block(char *active_comment)
|
||||
// case NEXT_ACTION_JSON_COMMAND_IMMEDIATE: { status = mp_json_command_immediate(active_comment); break;} // M102
|
||||
|
||||
case NEXT_ACTION_DEFAULT: {
|
||||
cm_set_absolute_override(MODEL, gv.absolute_override); // apply absolute override
|
||||
cm_set_absolute_override(MODEL, gv.absolute_override); // apply absolute override & display as absolute
|
||||
switch (gv.motion_mode) {
|
||||
case MOTION_MODE_CANCEL_MOTION_MODE: { cm->gm.motion_mode = gv.motion_mode; break;} // G80
|
||||
case MOTION_MODE_STRAIGHT_TRAVERSE: { status = cm_straight_traverse(gv.target, gf.target); break;} // G0
|
||||
@@ -842,7 +842,7 @@ static stat_t _execute_gcode_block(char *active_comment)
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
cm_set_absolute_override(MODEL, ABSOLUTE_OVERRIDE_OFF); // un-set absolute override once the move is planned
|
||||
cm_set_absolute_override(MODEL, ABSOLUTE_OVERRIDE_OFF); // un-set absolute override once the move is planned
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user