static void _clear() {estop_clear();}
static void _pause() {mach_request_feedhold();}
static void _run() {mach_request_cycle_start();}
-static void _flush(uint16_t id) {mach_request_queue_flush(id);}
-static void _step() {}
+static void _step() {} // TODO
static void _report() {report_request_full();}
static void _reboot() {hw_request_hard_reset();}
case I2C_CLEAR: _clear(); break;
case I2C_PAUSE: _pause(); break;
case I2C_RUN: _run(); break;
- case I2C_FLUSH: _flush(*(uint16_t *)data); break;
case I2C_STEP: _step(); break;
case I2C_REPORT: _report(); break;
case I2C_HOME: break;
status_help();
return 0;
}
-
-
-uint8_t command_sync(int argc, char *argv[]) {
- char *end = 0;
- uint32_t x = strtoul(argv[1], &end, 0);
-
- if (end) printf_P(PSTR("\n{\"sync\": %lu}\n"), x);
- return 0;
-}
-
-
-uint8_t command_end_flush(int argc, char *argv[]) {
- uint16_t id = 0;
- char *end = 0;
-
- if (argc == 2) {
- id = strtoul(argv[1], &end, 0);
- if (!end) return STAT_BAD_NUMBER_FORMAT;
- }
-
- mach_end_queue_flush(id);
-
- return 0;
-}
CMD(mreset, 0, 1, "Reset motor")
CMD(calibrate, 0, 0, "Calibrate motors")
CMD(messages, 0, 0, "Dump all possible status messages")
-CMD(sync, 1, 1, "Synchronize with queue processing")
-CMD(end_flush, 0, 1, "End a flush request, with optional ID")
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-\
+
You should have received a copy of the GNU Lesser General Public
License along with the software. If not, see
<http://www.gnu.org/licenses/>.
I2C_PAUSE,
I2C_OPTIONAL_PAUSE,
I2C_RUN,
- I2C_FLUSH,
I2C_STEP,
I2C_REPORT,
I2C_HOME,
*/
-/// Initiate a feedhold right now
void mach_request_feedhold() {mach.feedhold_requested = true;}
-
-
-void mach_request_queue_flush(uint16_t id) {
- if (!id) mach.queue_flush_id = 0;
- mach.queue_flush_request = id;
-}
-
-
-void mach_end_queue_flush(uint16_t id) {
- if (mach.queue_flush_request) mach.queue_flush_id = id;
-}
-
-
-bool mach_queue_flushing() {
- return mach.queue_flush_request &&
- (int16_t)(mach.queue_flush_id - mach.queue_flush_request) < 0;
-}
-
-
+void mach_request_queue_flush() {mach.queue_flush_requested = true;}
void mach_request_cycle_start() {mach.cycle_start_requested = true;}
/// Process feedholds, cycle starts & queue flushes
void mach_feedhold_callback() {
- if (mach.feedhold_requested || mach_queue_flushing()) {
+ if (mach.feedhold_requested) {
if (mach.motion_state == MOTION_RUN && mach.hold_state == FEEDHOLD_OFF) {
mach_set_motion_state(MOTION_HOLD);
mach.hold_state = FEEDHOLD_SYNC; // invokes hold from aline execution
mach.feedhold_requested = false;
}
- if (mach_queue_flushing() &&
+ if (mach.queue_flush_requested &&
(mach.motion_state == MOTION_STOP ||
(mach.motion_state == MOTION_HOLD &&
mach.hold_state == FEEDHOLD_HOLD)) &&
- !mach_get_runtime_busy()) mach_queue_flush();
+ !mach_get_runtime_busy()) {
+ mach_queue_flush();
+ mach.queue_flush_requested = false;
+ }
bool processing =
mach.hold_state == FEEDHOLD_SYNC ||
mach.hold_state == FEEDHOLD_PLAN ||
mach.hold_state == FEEDHOLD_DECEL;
- if (mach.cycle_start_requested && !mach_queue_flushing() && !processing) {
+ if (mach.cycle_start_requested && !processing) {
mach.cycle_start_requested = false;
mach.hold_state = FEEDHOLD_END_HOLD;
mach_cycle_start();
float probe_results[AXES]; // probing results
bool feedhold_requested;
- uint16_t queue_flush_request; // queue flush request id
- uint16_t queue_flush_id; // latest queue flush request id
+ bool queue_flush_requested;
bool cycle_start_requested;
// Model states
// Program Functions (4.3.10)
void mach_request_feedhold();
-void mach_request_queue_flush(uint16_t id);
-void mach_end_queue_flush(uint16_t id);
+void mach_request_queue_flush();
void mach_request_cycle_start();
void mach_feedhold_callback();
// Main loop
while (true) {
hw_reset_handler(); // handle hard reset requests
- mach_feedhold_callback(); // feedhold state machine
- mach_arc_callback(); // arc generation runs
- mach_homing_callback(); // G28.2 continuation
- mach_probe_callback(); // G38.2 continuation
+ if (!estop_triggered()) {
+ mach_feedhold_callback(); // feedhold state machine
+ mach_arc_callback(); // arc generation runs
+ mach_homing_callback(); // G28.2 continuation
+ mach_probe_callback(); // G38.2 continuation
+ }
command_callback(); // process next command
report_callback(); // report changes
wdt_reset();