fix bad formattingfrom PR
[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 float get_current_power() const;
34
35 private:
36 uint32_t set_proportional_power(uint32_t dummy);
37 bool get_laser_power(float& power) const;
38 float current_speed_ratio(const Block *block) const;
39
40 mbed::PwmOut *pwm_pin; // PWM output to regulate the laser power
41 Pin *ttl_pin; // TTL output to fire laser
42 float laser_maximum_power; // maximum allowed laser power to be output on the pwm pin
43 float laser_minimum_power; // value used to tickle the laser on moves. Also minimum value for auto-scaling
44 float laser_maximum_s_value; // Value of S code that will represent max power
45 float scale;
46 struct {
47 bool laser_on:1; // set if the laser is on
48 bool pwm_inverting:1; // stores whether the PWM period should be inverted
49 bool ttl_used:1; // stores whether we have a TTL output
50 bool ttl_inverting:1; // stores whether the TTL output should be inverted
51 bool manual_fire:1; // set when manually firing
52 };
53 int32_t fire_duration; // manual fire command duration
54 int32_t ms_per_tick; // ms between each ticks, depends on PWM frequency
55 };