mb.tail->ts = rtc_get_time();
mb.tail->cb = cb;
mb.tail->line = line;
- mb.tail->run_state = MOVE_NEW;
+ mb.tail->state = BUFFER_NEW;
_push();
}
typedef enum {
- MOVE_OFF, // move inactive
- MOVE_NEW, // initial value
- MOVE_INIT, // first run
- MOVE_RUN, // subsequent runs
- MOVE_RESTART, // restart buffer when done
-} run_state_t;
+ BUFFER_OFF, // move inactive
+ BUFFER_NEW, // initial value
+ BUFFER_INIT, // first run
+ BUFFER_ACTIVE, // subsequent runs
+ BUFFER_RESTART, // restart buffer when done
+} buffer_state_t;
// Callbacks
int32_t line; // gcode block line number
buffer_cb_t cb; // callback to buffer exec function
- run_state_t run_state; // run state machine sequence
+ buffer_state_t state; // buffer state
bool replannable; // true if move can be re-planned
float value; // used in dwell and other callbacks
bf->length = available_length - braking_length;
bf->delta_vmax = mp_get_target_velocity(0, bf->length, bf);
bf->entry_vmax = 0;
- bf->run_state = MOVE_RESTART; // Restart the buffer when done
+ bf->state = BUFFER_RESTART; // Restart the buffer when done
} else {
// Case 2: deceleration exceeds length remaining in buffer
stat_t status = STAT_OK;
// Start a new move
- if (bf->run_state == MOVE_INIT) {
- bf->run_state = MOVE_RUN;
+ if (bf->state == BUFFER_INIT) {
+ bf->state = BUFFER_ACTIVE;
status = _exec_aline_init(bf);
if (status != STAT_OK) return status;
}
return STAT_NOOP; // Nothing running
}
- if (bf->run_state == MOVE_NEW) {
+ if (bf->state == BUFFER_NEW) {
// On restart wait a bit to give planner queue a chance to fill
if (!mp_runtime_is_busy() && mp_queue_get_fill() < 4 &&
!rtc_expired(bf->ts + 250)) return STAT_NOOP;
// Take control of buffer
- bf->run_state = MOVE_INIT;
+ bf->state = BUFFER_INIT;
bf->replannable = false;
// Update runtime
}
// Handle buffer run state
- if (bf->run_state == MOVE_RESTART) bf->run_state = MOVE_NEW;
+ if (bf->state == BUFFER_RESTART) bf->state = BUFFER_NEW;
else {
// Solves a potential race condition where the current move ends but
// the new move has not started because the current move is still
bp->entry_vmax, bp->cruise_vmax, bp->exit_vmax);
bp = mp_buffer_prev(bp);
- if (bp == bf || bp->run_state == MOVE_OFF) break;
+ if (bp == bf || bp->state == BUFFER_OFF) break;
}
while (!usart_tx_empty()) continue;
*
* Variables that are ignored but here's what you would expect them to be:
*
- * bf->run_state - NEW for all blocks but the earliest
+ * bf->state - BUFFER_NEW for all blocks but the earliest
* bf->target[] - block target position
* bf->unit[] - block unit vector
* bf->jerk - source of the other jerk variables.
while (true) {
bp->replannable = true;
mp_buffer_t *next = mp_buffer_next(bp);
- if (next->run_state == MOVE_OFF || next == bf) break;
+ if (next->state == BUFFER_OFF || next == bf) break;
bp = next;
}