add $J for instant jog of one axis.
[clinton/Smoothieware.git] / src / modules / robot / Conveyor.h
1 /*
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.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
6 */
7
8 #pragma once
9
10 #include "libs/Module.h"
11 #include "BlockQueue.h"
12
13 class Block;
14
15 class Conveyor : public Module
16 {
17 public:
18 Conveyor();
19 void start(uint8_t n_actuators);
20
21 void on_module_loaded(void);
22 void on_idle(void *);
23 void on_halt(void *);
24
25 void wait_for_idle(bool wait_for_motors=true);
26 bool is_queue_empty() { return queue.is_empty(); };
27 bool is_queue_full() { return queue.is_full(); };
28 bool is_idle() const;
29
30 // returns next available block writes it to block and returns true
31 bool get_next_block(Block **block);
32 void block_finished();
33
34 void dump_queue(void);
35 void flush_queue(void);
36 float get_current_feedrate() const { return current_feedrate; }
37 void force_queue() { check_queue(true); }
38
39 friend class Planner; // for queue
40
41 private:
42 void check_queue(bool force= false);
43 void queue_head_block(void);
44
45 using Queue_t= BlockQueue;
46 Queue_t queue; // Queue of Blocks
47
48 uint32_t queue_delay_time_ms;
49 size_t queue_size;
50 float current_feedrate{0}; // actual nominal feedrate that current block is running at in mm/sec
51
52 struct {
53 volatile bool running:1;
54 volatile bool allow_fetch:1;
55 bool flush:1;
56 };
57
58 };