Commit | Line | Data |
---|---|---|
df27a6a3 | 1 | /* |
cc1d3b1f 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. | |
df27a6a3 | 5 | you should have received a copy of the gnu general public license along with smoothie. if not, see <http://www.gnu.org/licenses/>. |
cc1d3b1f AW |
6 | */ |
7 | ||
8 | #ifndef SWITCH_H | |
9 | #define SWITCH_H | |
10 | ||
bf9e8a8f | 11 | #include "Pin.h" |
61134a65 | 12 | #include "Pwm.h" |
bf9e8a8f | 13 | #include <math.h> |
61134a65 | 14 | |
e0d0ea84 JM |
15 | #include <string> |
16 | using std::string; | |
17 | ||
61134a65 JM |
18 | class Gcode; |
19 | class StreamOutput; | |
cc1d3b1f | 20 | |
def93cb3 JM |
21 | namespace mbed { |
22 | class PwmOut; | |
23 | } | |
24 | ||
cc1d3b1f AW |
25 | class Switch : public Module { |
26 | public: | |
27 | Switch(); | |
28 | Switch(uint16_t name); | |
11f8ba4e | 29 | |
cc1d3b1f | 30 | void on_module_loaded(); |
bfca9c55 | 31 | void on_main_loop(void *argument); |
cc1d3b1f | 32 | void on_config_reload(void* argument); |
3c4f2dd8 | 33 | void on_gcode_received(void* argument); |
2f5d0afa L |
34 | void on_get_public_data(void* argument); |
35 | void on_set_public_data(void* argument); | |
44ad0689 JM |
36 | void on_halt(void *arg); |
37 | ||
26ef0ec6 | 38 | uint32_t pinpoll_tick(uint32_t dummy); |
def93cb3 JM |
39 | enum OUTPUT_TYPE {NONE, SIGMADELTA, DIGITAL, HWPWM}; |
40 | ||
fe04e329 | 41 | private: |
26ef0ec6 L |
42 | void flip(); |
43 | void send_gcode(string msg, StreamOutput* stream); | |
bf9e8a8f JM |
44 | bool match_input_on_gcode(const Gcode* gcode) const; |
45 | bool match_input_off_gcode(const Gcode* gcode) const; | |
cc1d3b1f | 46 | |
4e3d75dd | 47 | Pin input_pin; |
4e3d75dd | 48 | float switch_value; |
e9f88113 | 49 | OUTPUT_TYPE output_type; |
def93cb3 JM |
50 | union { |
51 | Pin *digital_pin; | |
52 | Pwm *sigmadelta_pin; | |
53 | mbed::PwmOut *pwm_pin; | |
54 | }; | |
4e3d75dd AW |
55 | string output_on_command; |
56 | string output_off_command; | |
bfca9c55 JM |
57 | uint16_t name_checksum; |
58 | uint16_t input_pin_behavior; | |
59 | uint16_t input_on_command_code; | |
60 | uint16_t input_off_command_code; | |
61 | char input_on_command_letter; | |
62 | char input_off_command_letter; | |
63 | struct { | |
64 | bool switch_changed:1; | |
65 | bool input_pin_state:1; | |
44ad0689 JM |
66 | bool switch_state:1; |
67 | bool ignore_on_halt:1; | |
68 | uint8_t failsafe:1; | |
bfca9c55 | 69 | }; |
cc1d3b1f AW |
70 | }; |
71 | ||
26ef0ec6 | 72 | #endif // SWITCH_H |