Commit | Line | Data |
---|---|---|
de91760a | 1 | /* |
4cff3ded AW |
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. | |
de91760a | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
4cff3ded AW |
6 | */ |
7 | ||
23201534 | 8 | #pragma once |
4cff3ded | 9 | |
4cff3ded | 10 | #include "libs/Module.h" |
4cff3ded | 11 | |
23201534 JM |
12 | #include <stdint.h> |
13 | ||
1f19c40d JM |
14 | namespace mbed { |
15 | class PwmOut; | |
16 | } | |
4287ba0c | 17 | class Pin; |
23201534 | 18 | class Block; |
f5598f5b | 19 | |
4cff3ded AW |
20 | class Laser : public Module{ |
21 | public: | |
e605a0d6 | 22 | Laser(); |
eeef2894 | 23 | virtual ~Laser() {}; |
4cff3ded | 24 | void on_module_loaded(); |
f95c9fce | 25 | void on_halt(void* argument); |
04197132 | 26 | void on_gcode_received(void *argument); |
73cc27d2 | 27 | void on_console_line_received(void *argument); |
289380f2 JM |
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); | |
646d62d0 | 33 | float get_current_power() const; |
4cff3ded | 34 | |
1f19c40d | 35 | private: |
23201534 JM |
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; | |
23201534 | 39 | |
4287ba0c FM |
40 | mbed::PwmOut *pwm_pin; // PWM output to regulate the laser power |
41 | Pin *ttl_pin; // TTL output to fire laser | |
04197132 JM |
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; | |
86fa0b93 | 46 | struct { |
23201534 | 47 | bool laser_on:1; // set if the laser is on |
4287ba0c FM |
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 | |
b26de553 | 51 | bool manual_fire:1; // set when manually firing |
86fa0b93 | 52 | }; |
320f41fb DF |
53 | int32_t fire_duration; // manual fire command duration |
54 | uint32_t ms_per_tick; // ms between each ticks, depends on PWM frequency | |
4cff3ded | 55 | }; |