Add laser menu
[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 void on_get_public_data(void* argument);
29
30 void set_scale(float s) { scale= s/100; }
31 float get_scale() const { return scale*100; }
32 bool set_laser_power(float p);
33
34 private:
35 uint32_t set_proportional_power(uint32_t dummy);
36 bool get_laser_power(float& power) const;
37 float current_speed_ratio(const Block *block) const;
38
39 mbed::PwmOut *pwm_pin; // PWM output to regulate the laser power
40 Pin *ttl_pin; // TTL output to fire laser
41 float laser_maximum_power; // maximum allowed laser power to be output on the pwm pin
42 float laser_minimum_power; // value used to tickle the laser on moves. Also minimum value for auto-scaling
43 float laser_maximum_s_value; // Value of S code that will represent max power
44 float scale;
45 struct {
46 bool laser_on:1; // set if the laser is on
47 bool pwm_inverting:1; // stores whether the PWM period should be inverted
48 bool ttl_used:1; // stores whether we have a TTL output
49 bool ttl_inverting:1; // stores whether the TTL output should be inverted
50 bool manual_fire:1; // set when manually firing
51 };
52 };