add get state command to return current modal states (ala GRBL)
[clinton/Smoothieware.git] / src / modules / robot / Block.h
CommitLineData
df27a6a3 1/*
4cff3ded
AW
2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
df27a6a3 5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
4cff3ded
AW
6*/
7
8#ifndef BLOCK_H
9#define BLOCK_H
61134a65 10
4cff3ded 11#include <vector>
558e170c 12#include <bitset>
807b9b57 13#include "ActuatorCoordinates.h"
3a4fa0c1 14
66383b80 15class Gcode;
aab6cbba 16
4cff3ded
AW
17class Block {
18 public:
19 Block();
a617ac35 20 void calculate_trapezoid( float entry_speed, float exit_speed );
1ad23cd3
MM
21 float estimate_acceleration_distance( float initial_rate, float target_rate, float acceleration );
22 float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance);
558e170c 23 float max_allowable_speed( float acceleration, float target_velocity, float distance);
2134bcf2 24
a617ac35
MM
25 float reverse_pass(float exit_speed);
26 float forward_pass(float next_entry_speed);
27
28 float max_exit_speed();
2134bcf2 29
347854ff 30 void debug();
2134bcf2 31
4cff3ded 32 void append_gcode(Gcode* gcode);
2134bcf2 33
3a4fa0c1
AW
34 void take();
35 void release();
2134bcf2 36
3a4fa0c1 37 void ready();
2134bcf2 38
1cf31736 39 void clear();
4cff3ded 40
2134bcf2
MM
41 void begin();
42
558e170c 43 std::vector<Gcode> gcodes;
702023f3 44
1b5776bf
JM
45 std::array<uint32_t, k_max_actuators> steps; // Number of steps for each axis for this block
46 uint32_t steps_event_count; // Steps for the longest axis
47 uint32_t nominal_rate; // Nominal rate in steps per second
48 float nominal_speed; // Nominal speed in mm per second
49 float millimeters; // Distance for this move
50 float entry_speed;
51 float exit_speed;
52 float rate_delta; // Number of steps to add to the speed for each acceleration tick
53 float acceleration; // the acceleratoin for this block
54 uint32_t initial_rate; // Initial speed in steps per second
55 uint32_t final_rate; // Final speed in steps per second
56 uint32_t accelerate_until; // Stop accelerating after this number of steps
57 uint32_t decelerate_after; // Start decelerating after this number of steps
aab6cbba 58
4fdd2470
JM
59 float max_entry_speed;
60
1b5776bf 61 int16_t times_taken; // A block can be "taken" by any number of modules, and the next block is not moved to until all the modules have "released" it. This value serves as a tracker.
4fdd2470 62
807b9b57 63 std::bitset<k_max_actuators> direction_bits; // Direction for each axis in bit form, relative to the direction port's mask
558e170c
JM
64 struct {
65 bool recalculate_flag:1; // Planner flag to recalculate trapezoids on entry junction
66 bool nominal_length_flag:1; // Planner flag for nominal speed always reached
67 bool is_ready:1;
68 };
4cff3ded
AW
69};
70
71
4cff3ded 72#endif