fa7ad4bc8eca104169785976ba765cd1604a1bf1
[clinton/Smoothieware.git] / src / modules / tools / laser / Laser.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
12 #include <stdint.h>
13
14 namespace mbed {
15 class PwmOut;
16 }
17 class Pin;
18 class Block;
19
20 class Laser : public Module{
21 public:
22 Laser();
23 virtual ~Laser() {};
24 void on_module_loaded();
25 void on_halt(void* argument);
26 void on_gcode_received(void *argument);
27 void on_console_line_received(void *argument);
28
29 private:
30 uint32_t set_proportional_power(uint32_t dummy);
31 bool get_laser_power(float& power) const;
32 float current_speed_ratio(const Block *block) const;
33 bool set_laser_power(float p);
34
35 mbed::PwmOut *pwm_pin; // PWM output to regulate the laser power
36 Pin *ttl_pin; // TTL output to fire laser
37 float laser_maximum_power; // maximum allowed laser power to be output on the pwm pin
38 float laser_minimum_power; // value used to tickle the laser on moves. Also minimum value for auto-scaling
39 float laser_maximum_s_value; // Value of S code that will represent max power
40 float scale;
41 struct {
42 bool laser_on:1; // set if the laser is on
43 bool pwm_inverting:1; // stores whether the PWM period should be inverted
44 bool ttl_used:1; // stores whether we have a TTL output
45 bool ttl_inverting:1; // stores whether the TTL output should be inverted
46 bool manual_fire:1; // set when manually firing
47 };
48 };