temperaturecontrol: allow setting background tool without activating
[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
8a9f9313 8#pragma once
61134a65 9
558e170c 10#include <bitset>
807b9b57 11#include "ActuatorCoordinates.h"
3a4fa0c1 12
4cff3ded
AW
13class Block {
14 public:
15 Block();
c0f10f7d
JM
16
17 static void init(uint8_t);
18
a617ac35 19 void calculate_trapezoid( float entry_speed, float exit_speed );
2134bcf2 20
a617ac35
MM
21 float reverse_pass(float exit_speed);
22 float forward_pass(float next_entry_speed);
a617ac35 23 float max_exit_speed();
433d636f 24 void debug() const;
433d636f 25 void ready() { is_ready= true; }
1cf31736 26 void clear();
4245f826
JM
27 float get_trapezoid_rate(int i) const;
28
dc872d90
JM
29 private:
30 float max_allowable_speed( float acceleration, float target_velocity, float distance);
31 void prepare(float acceleration_in_steps, float deceleration_in_steps);
32
c0f10f7d
JM
33 static double fp_scale; // optimize to store this as it does not change
34
dc872d90 35 public:
1b5776bf
JM
36 std::array<uint32_t, k_max_actuators> steps; // Number of steps for each axis for this block
37 uint32_t steps_event_count; // Steps for the longest axis
1598a726 38 float nominal_rate; // Nominal rate in steps per second
1b5776bf
JM
39 float nominal_speed; // Nominal speed in mm per second
40 float millimeters; // Distance for this move
41 float entry_speed;
f6542ad9 42 float exit_speed;
e355738b 43 float acceleration; // the acceleration for this block
1598a726 44 float initial_rate; // Initial rate in steps per second
8b260c2c
JM
45 float maximum_rate;
46
4fdd2470
JM
47 float max_entry_speed;
48
f6542ad9
JM
49 // this is tick info needed for this block. applies to all motors
50 uint32_t accelerate_until;
51 uint32_t decelerate_after;
52 uint32_t total_move_ticks;
807b9b57 53 std::bitset<k_max_actuators> direction_bits; // Direction for each axis in bit form, relative to the direction port's mask
f6542ad9
JM
54
55 // this is the data needed to determine when each motor needs to be issued a step
56 using tickinfo_t= struct {
60e250af
JM
57 int64_t steps_per_tick; // 2.62 fixed point
58 int64_t counter; // 2.62 fixed point
59 int64_t acceleration_change; // 2.62 fixed point signed
60 int64_t deceleration_change; // 2.62 fixed point
61 int64_t plateau_rate; // 2.62 fixed point
f6542ad9
JM
62 uint32_t steps_to_move;
63 uint32_t step_count;
64 uint32_t next_accel_event;
65 };
66
67 // need info for each active motor
9840888d 68 tickinfo_t *tick_info;
c0f10f7d 69
8a9f9313 70 static uint8_t n_actuators;
f6542ad9 71
558e170c
JM
72 struct {
73 bool recalculate_flag:1; // Planner flag to recalculate trapezoids on entry junction
74 bool nominal_length_flag:1; // Planner flag for nominal speed always reached
75 bool is_ready:1;
f41bc212 76 bool primary_axis:1; // set if this move is a primary axis
23201534 77 bool is_g123:1; // set if this is a G1, G2 or G3
f6542ad9
JM
78 volatile bool is_ticking:1; // set when this block is being actively ticked by the stepticker
79 volatile bool locked:1; // set to true when the critical data is being updated, stepticker will have to skip if this is set
5c749b4a 80 uint16_t s_value:12; // for laser 1.11 Fixed point
558e170c 81 };
4cff3ded 82};