Skip to content

Commit

Permalink
Merge pull request synthetos#254 from synthetos/dev-253-text-mode-com…
Browse files Browse the repository at this point in the history
…pile

Dev-253-text-mode-compile
  • Loading branch information
aldenhart authored Mar 12, 2017
2 parents 8df3aea + 31f617f commit c985060
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 47 deletions.
17 changes: 11 additions & 6 deletions g2core/canonical_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,9 +1320,12 @@ stat_t cm_straight_traverse(const float target[], const bool flags[])
cm_cycle_start(); // required for homing & other cycles
stat_t status = mp_aline(&cm.gm); // send the move to the planner
cm_finalize_move();
if (status == STAT_MINIMUM_LENGTH_MOVE && !mp_has_runnable_buffer()) {
cm_cycle_end();
return (STAT_OK);

if (status == STAT_MINIMUM_LENGTH_MOVE) {
if (!mp_has_runnable_buffer()) { // handle condition where zero-length move is last or only move
cm_cycle_end(); // ...otherwise cycle will not end properly
}
status = STAT_OK;
}
return (status);
}
Expand Down Expand Up @@ -1478,9 +1481,11 @@ stat_t cm_straight_feed(const float target[], const bool flags[])

cm_finalize_move(); // <-- ONLY safe because we don't care about status...

if (status == STAT_MINIMUM_LENGTH_MOVE && !mp_has_runnable_buffer()) {
cm_cycle_end();
return (STAT_OK);
if (status == STAT_MINIMUM_LENGTH_MOVE) {
if (!mp_has_runnable_buffer()) { // handle condition where zero-length move is last or only move
cm_cycle_end(); // ...otherwise cycle will not end properly
}
status = STAT_OK;
}
return (status);
}
Expand Down
2 changes: 2 additions & 0 deletions g2core/canonical_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,8 @@ stat_t cm_get_tram(nvObj_t *nv); // return if the rotation matrix is non-
#define cm_print_mtoe tx_print_stub
#define cm_print_mto tx_print_stub

#define cm_print_tram tx_print_stub

#define cm_print_am tx_print_stub // axis print functions
#define cm_print_fr tx_print_stub
#define cm_print_vm tx_print_stub
Expand Down
10 changes: 9 additions & 1 deletion g2core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ stat_t get_flt(nvObj_t *nv)
}

/* Generic sets()
* set_noop() - set nothing and return OK
* set_nul() - set nothing, return OK
* set_ro() - set nothing, return read-only error
* set_ui8() - set value as 8 bit uint8_t value
Expand All @@ -250,8 +251,15 @@ stat_t get_flt(nvObj_t *nv)
* set_flt() - set value as float
*/

stat_t set_noop(nvObj_t *nv) {
nv->valuetype = TYPE_NULL;
return (STAT_OK); // hack until JSON is refactored
}

stat_t set_nul(nvObj_t *nv) {
return (STAT_OK);
// nv->valuetype = TYPE_NULL;
// return (STAT_PARAMETER_IS_READ_ONLY); // this is what it should be
return (STAT_OK); // hack until JSON is refactored
}

stat_t set_ro(nvObj_t *nv) {
Expand Down
3 changes: 2 additions & 1 deletion g2core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* config.h - configuration sub-system generic part (see config_app for application part)
* This file is part of the g2core project
*
* Copyright (c) 2010 - 2016 Alden S. Hart, Jr.
* Copyright (c) 2010 - 2017 Alden S. Hart, Jr.
*
* This file ("the software") is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 as published by the
Expand Down Expand Up @@ -317,6 +317,7 @@ bool nv_index_lt_groups(index_t index); // (see config_app.c)
bool nv_group_is_prefixed(char *group);

// generic internal functions and accessors
stat_t set_noop(nvObj_t *nv); // set nothing and return OK
stat_t set_nul(nvObj_t *nv); // set nothing, return OK
stat_t set_ro(nvObj_t *nv); // set nothing, return read-only error
stat_t set_ui8(nvObj_t *nv); // set uint8_t value
Expand Down
8 changes: 3 additions & 5 deletions g2core/config_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* config_app.cpp - application-specific part of configuration data
* This file is part of the g2core project
*
* Copyright (c) 2013 - 2016 Alden S. Hart, Jr.
* Copyright (c) 2016 Robert Giseburt
* Copyright (c) 2013 - 2017 Alden S. Hart, Jr.
* Copyright (c) 2016 - 2017 Robert Giseburt
*
* This file ("the software") is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 as published by the
Expand Down Expand Up @@ -113,9 +113,7 @@ const cfgItem_t cfgArray[] = {

// dynamic model attributes for reporting purposes (up front for speed)
{ "", "stat",_f0, 0, cm_print_stat, cm_get_stat, set_ro, (float *)&cs.null, 0 }, // combined machine state
// { "", "n", _fi, 0, cm_print_line, cm_get_mline,set_ro, (float *)&cm.gm.linenum,0 }, // Model line number
// { "", "line",_fi, 0, cm_print_line, cm_get_line, set_ro, (float *)&cm.gm.linenum,0 }, // Active line number - model or runtime line number
{ "", "n", _fi, 0, cm_print_line, cm_get_mline,set_ro, (float *)&cs.null, 0 }, // Model line number
{ "", "n", _fi, 0, cm_print_line, cm_get_mline,set_noop,(float *)&cs.null, 0 }, // Model line number
{ "", "line",_fi, 0, cm_print_line, cm_get_line, set_ro, (float *)&cs.null, 0 }, // Active line number - model or runtime line number
{ "", "vel", _f0, 2, cm_print_vel, cm_get_vel, set_ro, (float *)&cs.null, 0 }, // current velocity
{ "", "feed",_f0, 2, cm_print_feed, cm_get_feed, set_ro, (float *)&cs.null, 0 }, // feed rate
Expand Down
5 changes: 3 additions & 2 deletions g2core/gpio.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* gpio.h - Digital IO handling functions
* This file is part of the g2core project
*
* Copyright (c) 2015 - 2016 Alden S. Hart, Jr.
* Copyright (c) 2015 - 2016 Robert Giseburt
* Copyright (c) 2015 - 2017 Alden S. Hart, Jr.
* Copyright (c) 2015 - 2017 Robert Giseburt
*
* This file ("the software") is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 as published by the
Expand Down Expand Up @@ -155,6 +155,7 @@ stat_t io_set_output(nvObj_t *nv);
#define io_print_fn tx_print_stub
#define io_print_in tx_print_stub
#define io_print_st tx_print_stub
#define io_print_domode tx_print_stub
#define io_print_out tx_print_stub
#endif // __TEXT_MODE

Expand Down
32 changes: 17 additions & 15 deletions g2core/plan_arc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* plan_arc.c - arc planning and motion execution
* This file is part of the g2core project
*
* Copyright (c) 2010 - 2016 Alden S. Hart, Jr.
* Copyright (c) 2010 - 2017 Alden S. Hart, Jr.
*
* This file ("the software") is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 as published by the
Expand Down Expand Up @@ -182,7 +182,7 @@ stat_t cm_arc_feed(const float target[], const bool target_f[], // target en
if (fabs(arc.radius) < MIN_ARC_RADIUS) { // radius value must be > minimum radius
return (STAT_ARC_RADIUS_OUT_OF_TOLERANCE);
}
}
}
else { // test that center format absolute distance mode arcs have both offsets specified
if (cm.gm.arc_distance_mode == ABSOLUTE_DISTANCE_MODE) {
if (!(offset_f[arc.plane_axis_0] && offset_f[arc.plane_axis_1])) { // if one or both offsets are missing
Expand Down Expand Up @@ -226,21 +226,23 @@ stat_t cm_arc_feed(const float target[], const bool target_f[], // target en
memcpy(&arc.gm, &cm.gm, sizeof(GCodeState_t)); // copy GCode context to arc singleton - some will be overwritten to run segments
copy_vector(arc.position, cm.gmx.position); // set initial arc position from gcode model

// setup offsets
arc.offset[OFS_I] = _to_millimeters(offset[OFS_I]); // copy offsets with conversion to canonical form (mm)
arc.offset[OFS_J] = _to_millimeters(offset[OFS_J]);
arc.offset[OFS_K] = _to_millimeters(offset[OFS_K]);
// setup offsets if in center format mode
if (!radius_f) {
arc.offset[OFS_I] = _to_millimeters(offset[OFS_I]); // copy offsets with conversion to canonical form (mm)
arc.offset[OFS_J] = _to_millimeters(offset[OFS_J]);
arc.offset[OFS_K] = _to_millimeters(offset[OFS_K]);

if (arc.gm.arc_distance_mode == ABSOLUTE_DISTANCE_MODE) { // adjust offsets if in absolute mode
arc.offset[OFS_I] -= arc.position[AXIS_X];
arc.offset[OFS_J] -= arc.position[AXIS_Y];
arc.offset[OFS_K] -= arc.position[AXIS_Z];
}
if (arc.gm.arc_distance_mode == ABSOLUTE_DISTANCE_MODE) { // adjust offsets if in absolute mode
arc.offset[OFS_I] -= arc.position[AXIS_X];
arc.offset[OFS_J] -= arc.position[AXIS_Y];
arc.offset[OFS_K] -= arc.position[AXIS_Z];
}

if ((fp_ZERO(arc.offset[OFS_I])) && // it's an error if no offsets are provided
(fp_ZERO(arc.offset[OFS_J])) &&
(fp_ZERO(arc.offset[OFS_K]))) {
return (cm_alarm(STAT_ARC_OFFSETS_MISSING_FOR_SELECTED_PLANE, "arc offsets missing or zero"));
if ((fp_ZERO(arc.offset[OFS_I])) && // error if no offsets provided in center format mode
(fp_ZERO(arc.offset[OFS_J])) &&
(fp_ZERO(arc.offset[OFS_K]))) {
return (cm_alarm(STAT_ARC_OFFSETS_MISSING_FOR_SELECTED_PLANE, "arc offsets missing or zero"));
}
}

// compute arc runtime values
Expand Down
4 changes: 2 additions & 2 deletions g2core/plan_exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* plan_exec.cpp - execution function for acceleration managed lines
* This file is part of the g2core project
*
* Copyright (c) 2010 - 2016 Alden S. Hart, Jr.
* Copyright (c) 2012 - 2016 Rob Giseburt
* Copyright (c) 2010 - 2017 Alden S. Hart, Jr.
* Copyright (c) 2012 - 2017 Rob Giseburt
*
* This file ("the software") is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 as published by the
Expand Down
20 changes: 10 additions & 10 deletions g2core/plan_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* plan_line.c - acceleration managed line planning and motion execution
* This file is part of the g2core project
*
* Copyright (c) 2010 - 2016 Alden S. Hart, Jr.
* Copyright (c) 2012 - 2016 Rob Giseburt
* Copyright (c) 2010 - 2017 Alden S. Hart, Jr.
* Copyright (c) 2012 - 2017 Rob Giseburt
*
* This file ("the software") is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 as published by the
Expand Down Expand Up @@ -197,24 +197,24 @@ stat_t mp_aline(GCodeState_t* gm_in)

// exit if the move has zero movement. At all.
if (fp_ZERO(length)) {
sr_request_status_report(SR_REQUEST_TIMED_FULL); // Was SR_REQUEST_IMMEDIATE_FULL
return (STAT_OK); // preferred over STAT_MINIMUM_LENGTH_MOVE
sr_request_status_report(SR_REQUEST_TIMED_FULL);// Was SR_REQUEST_IMMEDIATE_FULL
return (STAT_MINIMUM_LENGTH_MOVE); // STAT_MINIMUM_LENGTH_MOVE needed to end cycle
}

// get a cleared buffer and copy in the Gcode model state
if ((bf = mp_get_write_buffer()) == NULL) { // never supposed to fail
if ((bf = mp_get_write_buffer()) == NULL) { // never supposed to fail
return (cm_panic(STAT_FAILED_GET_PLANNER_BUFFER, "aline()"));
}
memcpy(&bf->gm, gm_in, sizeof(GCodeState_t));
// Since bf->gm.target is being used all over the place, we'll make it the rotated target
copy_vector(bf->gm.target, target_rotated); // copy the rotated taget in place

// setup the buffer
bf->bf_func = mp_exec_aline; // register the callback to the exec function
bf->length = length; // record the length
for (uint8_t axis = 0; axis < AXES; axis++) { // compute the unit vector and set flags
if ((bf->axis_flags[axis] = flags[axis])) { // yes, this is supposed to be = and not ==
bf->unit[axis] = axis_length[axis] / length; // nb: bf-> unit was cleared by mp_get_write_buffer()
bf->bf_func = mp_exec_aline; // register the callback to the exec function
bf->length = length; // record the length
for (uint8_t axis = 0; axis < AXES; axis++) { // compute the unit vector and set flags
if ((bf->axis_flags[axis] = flags[axis])) { // yes, this is supposed to be = and not ==
bf->unit[axis] = axis_length[axis] / length;// nb: bf-> unit was cleared by mp_get_write_buffer()
}
}
_calculate_jerk(bf); // compute bf->jerk values
Expand Down
2 changes: 1 addition & 1 deletion g2core/settings/settings_makeblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
#define STATUS_REPORT_INTERVAL_MS 250 // milliseconds - set $SV=0 to disable
//#define STATUS_REPORT_DEFAULTS
//"line","posx","posy","posz","posa","bcr","feed","vel","unit","coor","dist","admo","frmo","momo","stat"
//"line","posx","posy","posz","posa","feed","vel","unit","coor","dist","admo","frmo","momo","stat"
#define STATUS_REPORT_DEFAULTS "line", "posx", "posy", "posz", "feed", "vel", "momo", "stat"
// Alternate SRs that report in drawable units
Expand Down
4 changes: 2 additions & 2 deletions g2core/settings/settings_shapeoko2.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
#define STATUS_REPORT_MIN_MS 100 // milliseconds - enforces a viable minimum
#define STATUS_REPORT_INTERVAL_MS 250 // milliseconds - set $SV=0 to disable

//#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","posa","bcr","feed","vel","unit","coor","dist","admo","frmo","momo","stat"
#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","bcr","feed","vel","momo","stat"
//#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","posa","feed","vel","unit","coor","dist","admo","frmo","momo","stat"
#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","feed","vel","momo","stat"

// Alternate SRs that report in drawable units
//#define STATUS_REPORT_DEFAULTS "line","vel","mpox","mpoy","mpoz","mpoa","coor","ofsa","ofsx","ofsy","ofsz","dist","unit","stat","homz","homy","homx","momo"
Expand Down
4 changes: 2 additions & 2 deletions g2core/settings/settings_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
#define STATUS_REPORT_MIN_MS 100 // milliseconds - enforces a viable minimum
#define STATUS_REPORT_INTERVAL_MS 250 // milliseconds - set $SV=0 to disable

//#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","posa","bcr","feed","vel","unit","coor","dist","admo","frmo","momo","stat"
#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","bcr","feed","vel","momo","stat"
//#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","posa","feed","vel","unit","coor","dist","admo","frmo","momo","stat"
#define STATUS_REPORT_DEFAULTS "line","posx","posy","posz","feed","vel","momo","stat"

// Alternate SRs
//#define STATUS_REPORT_DEFAULTS "line","vel","mpox","mpoy","mpoz","mpoa","coor","ofsa","ofsx","ofsy","ofsz","dist","unit","stat","homz","homy","homx","momo"
Expand Down

0 comments on commit c985060

Please sign in to comment.