| 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 | |
| 9 | |
| 10 | #ifndef EXTURDER_MODULE_H |
| 11 | #define EXTRUDER_MODULE_H |
| 12 | |
| 13 | #include "libs/Module.h" |
| 14 | #include "libs/Kernel.h" |
| 15 | #include "modules/robot/Block.h" |
| 16 | #include "modules/tools/toolsmanager/Tool.h" |
| 17 | |
| 18 | #define OFF 0 |
| 19 | #define SOLO 1 |
| 20 | #define FOLLOW 2 |
| 21 | |
| 22 | class Extruder : public Module, public Tool { |
| 23 | public: |
| 24 | Extruder(uint16_t config_identifier); |
| 25 | void on_module_loaded(); |
| 26 | void on_config_reload(void* argument); |
| 27 | void on_gcode_received(void*); |
| 28 | void on_gcode_execute(void* argument); |
| 29 | void on_block_begin(void* argument); |
| 30 | void on_block_end(void* argument); |
| 31 | void on_play(void* argument); |
| 32 | void on_pause(void* argument); |
| 33 | void on_speed_change(void* argument); |
| 34 | uint32_t acceleration_tick(uint32_t dummy); |
| 35 | uint32_t stepper_motor_finished_move(uint32_t dummy); |
| 36 | Block* append_empty_block(); |
| 37 | |
| 38 | Pin step_pin; // Step pin for the stepper driver |
| 39 | Pin dir_pin; // Dir pin for the stepper driver |
| 40 | Pin en_pin; |
| 41 | |
| 42 | float target_position; // End point ( in mm ) for the current move |
| 43 | float current_position; // Current point ( in mm ) for the current move, incremented every time a move is executed |
| 44 | float unstepped_distance; // overflow buffer for requested moves that are less than 1 step |
| 45 | Block* current_block; // Current block we are stepping, same as Stepper's one |
| 46 | float steps_per_millimeter; // Steps to travel one millimeter |
| 47 | float feed_rate; // |
| 48 | float acceleration; // |
| 49 | float max_speed; |
| 50 | |
| 51 | float travel_ratio; |
| 52 | float travel_distance; |
| 53 | bool absolute_mode; // absolute/relative coordinate mode switch |
| 54 | |
| 55 | char mode; // extruder motion mode, OFF, SOLO, or FOLLOW |
| 56 | |
| 57 | bool paused; |
| 58 | bool single_config; |
| 59 | |
| 60 | uint16_t identifier; |
| 61 | |
| 62 | StepperMotor* stepper_motor; |
| 63 | |
| 64 | }; |
| 65 | |
| 66 | #endif |