Added conditionals

This commit is contained in:
Alden Hart
2016-10-29 11:08:06 -04:00
parent 073a08b4b7
commit a0c01463dc
5 changed files with 47 additions and 32 deletions
+33 -28
View File
@@ -1042,33 +1042,8 @@ stat_t cm_set_arc_distance_mode(const uint8_t mode)
* It also does not reset the work_offsets which may be accomplished by calling
* cm_set_work_offsets() immediately afterwards.
*/
/*
stat_t cm_set_coord_offsets(const uint8_t coord_system,
const uint8_t L_word,
const float offset[], const bool flag[])
{
if ((coord_system < G54) || (coord_system > COORD_SYSTEM_MAX)) { // you can't set G53
return (STAT_P_WORD_IS_INVALID);
}
if (!cm.gf.L_word) {
return (STAT_L_WORD_IS_MISSING);
}
if ((L_word != 2) && (L_word != 20)) {
return (STAT_L_WORD_IS_INVALID);
}
for (uint8_t axis = AXIS_X; axis < AXES; axis++) {
if (flag[axis]) {
if (L_word == 2) {
cm.offset[coord_system][axis] = _to_millimeters(offset[axis]);
} else {
cm.offset[coord_system][axis] = cm.gmx.position[axis] - _to_millimeters(offset[axis]);
}
cm.deferred_write_flag = true; // persist offsets once machining cycle is over
}
}
return (STAT_OK);
}
*/
#ifdef __TOOL_LENGTH_OFFSET
stat_t cm_set_coord_offsets(const uint8_t coord_system,
const uint8_t L_word,
const float offset[], const bool flag[])
@@ -1124,7 +1099,33 @@ stat_t cm_set_coord_offsets(const uint8_t coord_system,
}
return (STAT_OK);
}
#else // Not __TOOL_LENGTH_OFFSET
stat_t cm_set_coord_offsets(const uint8_t coord_system,
const uint8_t L_word,
const float offset[], const bool flag[])
{
if ((coord_system < G54) || (coord_system > COORD_SYSTEM_MAX)) { // you can't set G53
return (STAT_P_WORD_IS_INVALID);
}
if (!cm.gf.L_word) {
return (STAT_L_WORD_IS_MISSING);
}
if ((L_word != 2) && (L_word != 20)) {
return (STAT_L_WORD_IS_INVALID);
}
for (uint8_t axis = AXIS_X; axis < AXES; axis++) {
if (flag[axis]) {
if (L_word == 2) {
cm.offset[coord_system][axis] = _to_millimeters(offset[axis]);
} else {
cm.offset[coord_system][axis] = cm.gmx.position[axis] - _to_millimeters(offset[axis]);
}
cm.deferred_write_flag = true; // persist offsets once machining cycle is over
}
}
return (STAT_OK);
}
#endif
/******************************************************************************************
* Representation functions that affect gcode model and are queued to planner (synchronous)
@@ -1137,6 +1138,7 @@ stat_t cm_set_coord_offsets(const uint8_t coord_system,
*/
stat_t cm_set_tl_offset(const uint8_t H_word, bool apply_additional)
{
#ifdef __TOOL_LENGTH_OFFSET
uint8_t tool;
if (cm.gf.H_word)
{
@@ -1175,11 +1177,13 @@ stat_t cm_set_tl_offset(const uint8_t H_word, bool apply_additional)
float value[] = { (float)cm.gm.coord_system,0,0,0,0,0 };// pass coordinate system in value[0] element
bool flags[] = { 1,0,0,0,0,0 };
mp_queue_command(_exec_offset, value, flags); // second vector (flags) is not used, so fake it
#endif
return (STAT_OK);
}
stat_t cm_cancel_tl_offset()
{
#ifdef __TOOL_LENGTH_OFFSET
for (uint8_t axis = AXIS_X; axis < AXES; axis++) {
cm.tl_offset[axis] = 0;
}
@@ -1187,6 +1191,7 @@ stat_t cm_cancel_tl_offset()
float value[] = { (float)cm.gm.coord_system,0,0,0,0,0 };// pass coordinate system in value[0] element
bool flags[] = { 1,0,0,0,0,0 };
mp_queue_command(_exec_offset, value, flags); // second vector (flags) is not used, so fake it
#endif
return (STAT_OK);
}
+4 -3
View File
@@ -35,7 +35,7 @@
#include "config.h"
#include "hardware.h" // Note: hardware.h is specific to the hardware target selected
/* Defines, Macros, and Assorted Parameters */
/* Defines, Macros, and Assorted Parameters */
#define MODEL (GCodeState_t *)&cm.gm // absolute pointer from canonical machine gm model
#define PLANNER (GCodeState_t *)&bf->gm // relative to buffer *bf is currently pointing to
@@ -413,11 +413,10 @@ typedef struct GCodeInput { // Gcode model inputs - meaning depends
uint8_t spindle_control; // 0=OFF (M5), 1=CW (M3), 2=CCW (M4)
float spindle_speed; // in RPM
float spindle_override_factor; // 1.0000 x S spindle speed. Go up or down from there
uint8_t spindle_override_enable; // TRUE = override enabled
uint8_t spindle_override_enable; // TRUE = override enabled
// unimplemented gcode parameters
// float cutter_radius; // D - cutter radius compensation (0 is off)
// float cutter_length; // H - cutter length compensation (0 is off)
} GCodeInput_t;
@@ -512,7 +511,9 @@ typedef struct cmSingleton { // struct to manage cm globals and c
// coordinate systems and offsets
float offset[COORDS+1][AXES]; // persistent coordinate offsets: absolute (G53) + G54,G55,G56,G57,G58,G59
float tl_offset[AXES]; // current tool length offset
#ifdef __TOOL_LENGTH_OFFSET
float tt_offset[TOOLS+1][AXES]; // persistent tool table offsets
#endif
// settings for axes X,Y,Z,A B,C
cfgAxis_t a[AXES];
+9
View File
@@ -603,6 +603,7 @@ const cfgItem_t cfgArray[] = {
{ "g30","g30b",_fi, 3, cm_print_cpos, get_flt, set_nul,(float *)&cm.gmx.g30_position[AXIS_B], 0 },
{ "g30","g30c",_fi, 3, cm_print_cpos, get_flt, set_nul,(float *)&cm.gmx.g30_position[AXIS_C], 0 },
#ifdef __TOOL_LENGTH_OFFSET
// Default values for current tool length offsets (not configurable, set to zero)
{ "tl","tlx",_fipc, 3, cm_print_cofs, get_flt, set_flu,(float *)&cm.tl_offset[AXIS_X], 0 },
{ "tl","tly",_fipc, 3, cm_print_cofs, get_flt, set_flu,(float *)&cm.tl_offset[AXIS_Y], 0 },
@@ -653,6 +654,7 @@ const cfgItem_t cfgArray[] = {
{ "tt6","tt6a",_fip, 3, cm_print_cofs, get_flt, set_flt,(float *)&cm.tt_offset[6][AXIS_A], TT6_A_OFFSET },
{ "tt6","tt6b",_fip, 3, cm_print_cofs, get_flt, set_flt,(float *)&cm.tt_offset[6][AXIS_B], TT6_B_OFFSET },
{ "tt6","tt6c",_fip, 3, cm_print_cofs, get_flt, set_flt,(float *)&cm.tt_offset[6][AXIS_C], TT6_C_OFFSET },
#endif
// this is a 128bit UUID for identifying a previously committed job state
{ "jid","jida",_f0, 0, tx_print_nul, get_data, set_data, (float *)&cfg.job_id[0], 0},
@@ -938,6 +940,7 @@ const cfgItem_t cfgArray[] = {
{ "","g28",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // g28 home position
{ "","g30",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // g30 home position
// +9 = 45
#ifdef __TOOL_LENGTH_OFFSET
{ "","tl",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // tl offsets
{ "","tt1",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // tt offsets
{ "","tt2",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // tt offsets
@@ -945,6 +948,7 @@ const cfgItem_t cfgArray[] = {
{ "","tt4",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // tt offsets
{ "","tt5",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // tt offsets
{ "","tt6",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // tt offsets
#endif
// +7 = 52
{ "","mpo",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // machine position group
{ "","pos",_f0, 0, tx_print_nul, get_grp, set_grp,(float *)&cs.null,0 }, // work position group
@@ -993,7 +997,12 @@ const cfgItem_t cfgArray[] = {
/***** Make sure these defines line up with any changes in the above table *****/
#define NV_COUNT_UBER_GROUPS 6 // count of uber-groups, above
#ifdef __TOOL_LENGTH_OFFSET
#define FIXED_GROUPS 66 // count of fixed groups, excluding optional groups
#else
#define FIXED_GROUPS 59 // count of fixed groups, excluding optional groups
#endif
#if (MOTORS >= 5)
#define MOTOR_GROUP_5 1
+1
View File
@@ -44,6 +44,7 @@
#define __HELP_SCREENS // enable help screens (~3.5Kb)
#define __USER_DATA // enable user defined data groups
#define __STEP_CORRECTION // enable virtual encoder step correction
//#define __TOOL_LENGTH_OFFSET
/****** DEVELOPMENT SETTINGS ******/
-1
View File
@@ -551,7 +551,6 @@ static stat_t _parse_gcode_block(char *buf, char *active_comment)
case 51: SET_MODAL (MODAL_GROUP_M9, sso_enable, true);
case 100: SET_NON_MODAL (next_action, NEXT_ACTION_JSON_COMMAND_SYNC);
case 101: SET_NON_MODAL (next_action, NEXT_ACTION_JSON_WAIT);
// case 102: SET_NON_MODAL (next_action, NEXT_ACTION_JSON_COMMAND_IMMEDIATE);
default: status = STAT_MCODE_COMMAND_UNSUPPORTED;
}
break;