update firmware.bin
[clinton/Smoothieware.git] / src / modules / tools / switch / Switch.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 #ifndef SWITCH_H
9 #define SWITCH_H
10
11 #include "Pin.h"
12 #include "Pwm.h"
13 #include <math.h>
14
15 #include <string>
16 using std::string;
17
18 class Gcode;
19 class StreamOutput;
20
21 class Switch : public Module {
22 public:
23 Switch();
24 Switch(uint16_t name);
25
26 void on_module_loaded();
27 void on_config_reload(void* argument);
28 void on_gcode_received(void* argument);
29 void on_gcode_execute(void* argument);
30 void on_main_loop(void* argument);
31 void on_get_public_data(void* argument);
32 void on_set_public_data(void* argument);
33 uint32_t pinpoll_tick(uint32_t dummy);
34 enum OUTPUT_TYPE {PWM, DIGITAL};
35 private:
36 void flip();
37 void send_gcode(string msg, StreamOutput* stream);
38 bool match_input_on_gcode(const Gcode* gcode) const;
39 bool match_input_off_gcode(const Gcode* gcode) const;
40
41 uint16_t name_checksum;
42 Pin input_pin;
43 uint16_t input_pin_behavior;
44 bool input_pin_state;
45 char input_on_command_letter;
46 char input_off_command_letter;
47 uint16_t input_on_command_code;
48 uint16_t input_off_command_code;
49 bool switch_state;
50 float switch_value;
51 bool switch_changed;
52 OUTPUT_TYPE output_type;
53 Pwm output_pin;
54 string output_on_command;
55 string output_off_command;
56 };
57
58 #endif // SWITCH_H