mirror of
https://github.com/synthetos/g2.git
synced 2026-09-21 10:35:38 +08:00
Changed axis mode get/set functions to work with multiple machine models; Simplified some of the Gcode status code defines (internal only); Added system state model Graffle to Resources/Documentation
This commit is contained in:
Binary file not shown.
@@ -1323,7 +1323,7 @@ stat_t cm_set_feed_rate(const float feed_rate)
|
||||
{
|
||||
if (cm->gm.feed_rate_mode == INVERSE_TIME_MODE) {
|
||||
if (fp_ZERO(feed_rate)) {
|
||||
return (STAT_GCODE_FEEDRATE_NOT_SPECIFIED);
|
||||
return (STAT_FEEDRATE_NOT_SPECIFIED);
|
||||
}
|
||||
cm->gm.feed_rate = 1/feed_rate; // normalize to minutes (NB: active for this gcode block only)
|
||||
} else {
|
||||
@@ -1382,7 +1382,7 @@ stat_t cm_straight_feed(const float target[], const bool flags[])
|
||||
{
|
||||
// trap zero feed rate condition
|
||||
if (fp_ZERO(cm->gm.feed_rate)) {
|
||||
return (STAT_GCODE_FEEDRATE_NOT_SPECIFIED);
|
||||
return (STAT_FEEDRATE_NOT_SPECIFIED);
|
||||
}
|
||||
cm->gm.motion_mode = MOTION_MODE_STRAIGHT_FEED;
|
||||
|
||||
@@ -2251,35 +2251,26 @@ stat_t cm_get_ofs(nvObj_t *nv)
|
||||
* cm_set_hi() - set homing input
|
||||
*/
|
||||
|
||||
stat_t cm_get_am(nvObj_t *nv)
|
||||
{
|
||||
get_ui8(nv);
|
||||
return(_get_msg_helper(nv, msg_am, nv->value));
|
||||
}
|
||||
|
||||
#pragma GCC push_options
|
||||
#pragma GCC optimize ("O0")
|
||||
|
||||
stat_t cm_get_am(nvObj_t *nv)
|
||||
{
|
||||
int8_t axis = _get_axis(nv->index);
|
||||
nv->value = (float)cm->a[axis].axis_mode;
|
||||
return(_get_msg_helper(nv, msg_am, nv->value));
|
||||
}
|
||||
|
||||
stat_t cm_set_am(nvObj_t *nv) // axis mode
|
||||
{
|
||||
|
||||
nv->valuetype = TYPE_INT;
|
||||
if (_get_axis_type(nv->index) == AXIS_TYPE_LINEAR) {
|
||||
if (nv->value > AXIS_MODE_LINEAR_MAX) { return (STAT_INPUT_VALUE_RANGE_ERROR);}
|
||||
} else {
|
||||
if (nv->value > AXIS_MODE_ROTARY_MAX) { return (STAT_INPUT_VALUE_RANGE_ERROR);}
|
||||
}
|
||||
cmAxisMode *am = (cmAxisMode *)cfgArray[nv->index].target;
|
||||
void *p = (cfgArray[nv->index].target);
|
||||
cmAxisMode a = *((cmAxisMode *)cfgArray[nv->index].target);
|
||||
// *((uint8_t *)cfgArray[nv->index].target) = nv->value;
|
||||
// cmAxisMode a = (cmAxisMode)nv->value;
|
||||
// *am = (cmAxisMode)nv->value;
|
||||
*am = a;
|
||||
return(STAT_OK);
|
||||
|
||||
// set_ui8(nv);
|
||||
// return(STAT_OK);
|
||||
cm->a[_get_axis(nv->index)].axis_mode = (cmAxisMode)nv->value;
|
||||
return(STAT_OK);
|
||||
}
|
||||
|
||||
#pragma GCC reset_options
|
||||
|
||||
@@ -515,7 +515,7 @@ typedef struct cmAxis {
|
||||
float zero_backoff; // backoff from switches for machine zero
|
||||
} cfgAxis_t;
|
||||
|
||||
typedef struct cmSingleton { // struct to manage cm globals and cycles
|
||||
typedef struct cmMachine { // struct to manage canonical machine globals and state
|
||||
magic_t magic_start; // magic number to test memory integrity
|
||||
|
||||
/**** Config variables (PUBLIC) ****/
|
||||
|
||||
@@ -268,7 +268,6 @@ const cfgItem_t cfgArray[] = {
|
||||
#endif
|
||||
// Axis parameters
|
||||
{ "x","xam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cs.null, X_AXIS_MODE },
|
||||
// { "x","xam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_X].axis_mode, X_AXIS_MODE },
|
||||
{ "x","xvm",_fipc, 0, cm_print_vm, get_flt, cm_set_vm, (float *)&cm->a[AXIS_X].velocity_max, X_VELOCITY_MAX },
|
||||
{ "x","xfr",_fipc, 0, cm_print_fr, get_flt, cm_set_fr, (float *)&cm->a[AXIS_X].feedrate_max, X_FEEDRATE_MAX },
|
||||
{ "x","xtn",_fipc, 3, cm_print_tn, get_flt, set_flu, (float *)&cm->a[AXIS_X].travel_min, X_TRAVEL_MIN },
|
||||
@@ -282,7 +281,7 @@ const cfgItem_t cfgArray[] = {
|
||||
{ "x","xlb",_fipc, 3, cm_print_lb, get_flt, set_flu, (float *)&cm->a[AXIS_X].latch_backoff, X_LATCH_BACKOFF },
|
||||
{ "x","xzb",_fipc, 3, cm_print_zb, get_flt, set_flu, (float *)&cm->a[AXIS_X].zero_backoff, X_ZERO_BACKOFF },
|
||||
|
||||
{ "y","yam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_Y].axis_mode, Y_AXIS_MODE },
|
||||
{ "y","yam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cs.null, Y_AXIS_MODE },
|
||||
{ "y","yvm",_fipc, 0, cm_print_vm, get_flt, cm_set_vm, (float *)&cm->a[AXIS_Y].velocity_max, Y_VELOCITY_MAX },
|
||||
{ "y","yfr",_fipc, 0, cm_print_fr, get_flt, cm_set_fr, (float *)&cm->a[AXIS_Y].feedrate_max, Y_FEEDRATE_MAX },
|
||||
{ "y","ytn",_fipc, 3, cm_print_tn, get_flt, set_flu, (float *)&cm->a[AXIS_Y].travel_min, Y_TRAVEL_MIN },
|
||||
@@ -296,7 +295,7 @@ const cfgItem_t cfgArray[] = {
|
||||
{ "y","ylb",_fipc, 3, cm_print_lb, get_flt, set_flu, (float *)&cm->a[AXIS_Y].latch_backoff, Y_LATCH_BACKOFF },
|
||||
{ "y","yzb",_fipc, 3, cm_print_zb, get_flt, set_flu, (float *)&cm->a[AXIS_Y].zero_backoff, Y_ZERO_BACKOFF },
|
||||
|
||||
{ "z","zam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_Z].axis_mode, Z_AXIS_MODE },
|
||||
{ "z","zam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cs.null, Z_AXIS_MODE },
|
||||
{ "z","zvm",_fipc, 0, cm_print_vm, get_flt, cm_set_vm, (float *)&cm->a[AXIS_Z].velocity_max, Z_VELOCITY_MAX },
|
||||
{ "z","zfr",_fipc, 0, cm_print_fr, get_flt, cm_set_fr, (float *)&cm->a[AXIS_Z].feedrate_max, Z_FEEDRATE_MAX },
|
||||
{ "z","ztn",_fipc, 3, cm_print_tn, get_flt, set_flu, (float *)&cm->a[AXIS_Z].travel_min, Z_TRAVEL_MIN },
|
||||
@@ -310,7 +309,7 @@ const cfgItem_t cfgArray[] = {
|
||||
{ "z","zlb",_fipc, 3, cm_print_lb, get_flt, set_flu, (float *)&cm->a[AXIS_Z].latch_backoff, Z_LATCH_BACKOFF },
|
||||
{ "z","zzb",_fipc, 3, cm_print_zb, get_flt, set_flu, (float *)&cm->a[AXIS_Z].zero_backoff, Z_ZERO_BACKOFF },
|
||||
|
||||
{ "a","aam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_A].axis_mode, A_AXIS_MODE },
|
||||
{ "a","aam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cs.null, A_AXIS_MODE },
|
||||
{ "a","avm",_fip, 0, cm_print_vm, get_flt, cm_set_vm, (float *)&cm->a[AXIS_A].velocity_max, A_VELOCITY_MAX },
|
||||
{ "a","afr",_fip, 0, cm_print_fr, get_flt, cm_set_fr, (float *)&cm->a[AXIS_A].feedrate_max, A_FEEDRATE_MAX },
|
||||
{ "a","atn",_fip, 3, cm_print_tn, get_flt, set_flt, (float *)&cm->a[AXIS_A].travel_min, A_TRAVEL_MIN },
|
||||
@@ -325,7 +324,7 @@ const cfgItem_t cfgArray[] = {
|
||||
{ "a","alb",_fip, 3, cm_print_lb, get_flt, set_flt, (float *)&cm->a[AXIS_A].latch_backoff, A_LATCH_BACKOFF },
|
||||
{ "a","azb",_fip, 3, cm_print_zb, get_flt, set_flt, (float *)&cm->a[AXIS_A].zero_backoff, A_ZERO_BACKOFF },
|
||||
|
||||
{ "b","bam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_B].axis_mode, B_AXIS_MODE },
|
||||
{ "b","bam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cs.null, B_AXIS_MODE },
|
||||
{ "b","bvm",_fip, 0, cm_print_vm, get_flt, cm_set_vm, (float *)&cm->a[AXIS_B].velocity_max, B_VELOCITY_MAX },
|
||||
{ "b","bfr",_fip, 0, cm_print_fr, get_flt, cm_set_fr, (float *)&cm->a[AXIS_B].feedrate_max, B_FEEDRATE_MAX },
|
||||
{ "b","btn",_fip, 3, cm_print_tn, get_flt, set_flt, (float *)&cm->a[AXIS_B].travel_min, B_TRAVEL_MIN },
|
||||
@@ -340,7 +339,7 @@ const cfgItem_t cfgArray[] = {
|
||||
{ "b","blb",_fip, 3, cm_print_lb, get_flt, set_flt, (float *)&cm->a[AXIS_B].latch_backoff, B_LATCH_BACKOFF },
|
||||
{ "b","bzb",_fip, 3, cm_print_zb, get_flt, set_flt, (float *)&cm->a[AXIS_B].zero_backoff, B_ZERO_BACKOFF },
|
||||
|
||||
{ "c","cam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cm->a[AXIS_C].axis_mode, C_AXIS_MODE },
|
||||
{ "c","cam",_fip, 0, cm_print_am, cm_get_am, cm_set_am, (float *)&cs.null, C_AXIS_MODE },
|
||||
{ "c","cvm",_fip, 0, cm_print_vm, get_flt, cm_set_vm, (float *)&cm->a[AXIS_C].velocity_max, C_VELOCITY_MAX },
|
||||
{ "c","cfr",_fip, 0, cm_print_fr, get_flt, cm_set_fr, (float *)&cm->a[AXIS_C].feedrate_max, C_FEEDRATE_MAX },
|
||||
{ "c","ctn",_fip, 3, cm_print_tn, get_flt, set_flt, (float *)&cm->a[AXIS_C].travel_min, C_TRAVEL_MIN },
|
||||
|
||||
@@ -140,12 +140,12 @@ static stat_t _set_pb_func(uint8_t (*func)()) {
|
||||
uint8_t cm_straight_probe(float target[], bool flags[], bool failure_is_fatal, bool moving_toward_switch) {
|
||||
// trap zero feed rate condition
|
||||
if (fp_ZERO(cm->gm.feed_rate)) {
|
||||
return (STAT_GCODE_FEEDRATE_NOT_SPECIFIED);
|
||||
return (STAT_FEEDRATE_NOT_SPECIFIED);
|
||||
}
|
||||
|
||||
// error if no axes specified
|
||||
if (!flags[AXIS_X] && !flags[AXIS_Y] && !flags[AXIS_Z]) {
|
||||
return (STAT_GCODE_AXIS_IS_MISSING);
|
||||
return (STAT_AXIS_IS_MISSING);
|
||||
}
|
||||
|
||||
pb.failure_is_fatal = failure_is_fatal;
|
||||
|
||||
+12
-12
@@ -226,19 +226,19 @@ char *get_status_message(stat_t status);
|
||||
#define STAT_GCODE_COMMAND_UNSUPPORTED 131 // G command is not supported
|
||||
#define STAT_MCODE_COMMAND_UNSUPPORTED 132 // M command is not supported
|
||||
#define STAT_GCODE_MODAL_GROUP_VIOLATION 133 // gcode modal group error
|
||||
#define STAT_GCODE_AXIS_IS_MISSING 134 // command requires at least one axis present
|
||||
#define STAT_GCODE_AXIS_CANNOT_BE_PRESENT 135 // error if G80 has axis words
|
||||
#define STAT_GCODE_AXIS_IS_INVALID 136 // an axis is specified that is illegal for the command
|
||||
#define STAT_GCODE_AXIS_IS_NOT_CONFIGURED 137 // WARNING: attempt to program an axis that is disabled
|
||||
#define STAT_GCODE_AXIS_NUMBER_IS_MISSING 138 // axis word is missing its value
|
||||
#define STAT_GCODE_AXIS_NUMBER_IS_INVALID 139 // axis word value is illegal
|
||||
#define STAT_AXIS_IS_MISSING 134 // command requires at least one axis present
|
||||
#define STAT_AXIS_CANNOT_BE_PRESENT 135 // error if G80 has axis words
|
||||
#define STAT_AXIS_IS_INVALID 136 // an axis is specified that is illegal for the command
|
||||
#define STAT_AXIS_IS_NOT_CONFIGURED 137 // WARNING: attempt to program an axis that is disabled
|
||||
#define STAT_AXIS_NUMBER_IS_MISSING 138 // axis word is missing its value
|
||||
#define STAT_AXIS_NUMBER_IS_INVALID 139 // axis word value is illegal
|
||||
|
||||
#define STAT_GCODE_ACTIVE_PLANE_IS_MISSING 140 // active plane is not programmed
|
||||
#define STAT_GCODE_ACTIVE_PLANE_IS_INVALID 141 // active plane selected is not valid for this command
|
||||
#define STAT_GCODE_FEEDRATE_NOT_SPECIFIED 142 // move has no feedrate
|
||||
#define STAT_GCODE_INVERSE_TIME_MODE_CANNOT_BE_USED 143 // G38.2 and some canned cycles cannot accept inverse time mode
|
||||
#define STAT_GCODE_ROTARY_AXIS_CANNOT_BE_USED 144 // G38.2 and some other commands cannot have rotary axes
|
||||
#define STAT_GCODE_G53_WITHOUT_G0_OR_G1 145 // G0 or G1 must be active for G53
|
||||
#define STAT_ACTIVE_PLANE_IS_MISSING 140 // active plane is not programmed
|
||||
#define STAT_ACTIVE_PLANE_IS_INVALID 141 // active plane selected is not valid for this command
|
||||
#define STAT_FEEDRATE_NOT_SPECIFIED 142 // move has no feedrate
|
||||
#define STAT_INVERSE_TIME_MODE_CANNOT_BE_USED 143 // G38.2 and some canned cycles cannot accept inverse time mode
|
||||
#define STAT_ROTARY_AXIS_CANNOT_BE_USED 144 // G38.2 and some other commands cannot have rotary axes
|
||||
#define STAT_GCODE_G53_WITHOUT_G0_OR_G1 145 // G0 or G1 must be active for G53
|
||||
#define STAT_REQUESTED_VELOCITY_EXCEEDS_LIMITS 146
|
||||
#define STAT_CUTTER_COMPENSATION_CANNOT_BE_ENABLED 147
|
||||
#define STAT_PROGRAMMED_POINT_SAME_AS_CURRENT_POINT 148
|
||||
|
||||
Reference in New Issue
Block a user