Enumerate hotends for display in panel temperature settings
[clinton/Smoothieware.git] / src / modules / utils / panel / Panel.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 PANEL_H
9 #define PANEL_H
10
11 #include "Button.h"
12
13 #define MENU_MODE 0
14 #define CONTROL_MODE 1
15
16 #define THEPANEL Panel::instance
17
18 class LcdBase;
19 class PanelScreen;
20
21 class Panel : public Module {
22 public:
23 Panel();
24 virtual ~Panel();
25 static Panel* instance;
26
27 void on_module_loaded();
28 uint32_t button_tick(uint32_t dummy);
29 uint32_t encoder_tick(uint32_t dummy);
30 void on_idle(void* argument);
31 void on_main_loop(void* argument);
32 void on_gcode_received(void* argument);
33 void enter_screen(PanelScreen* screen);
34 void reset_counter();
35
36 // Encoder and buttons
37 uint32_t on_up(uint32_t dummy);
38 uint32_t on_down(uint32_t dummy);
39 uint32_t on_back(uint32_t dummy);
40 uint32_t on_select(uint32_t dummy);
41 uint32_t on_pause(uint32_t dummy);
42 uint32_t refresh_tick(uint32_t dummy);
43 uint32_t encoder_check(uint32_t dummy);
44 bool counter_change();
45 bool click();
46 int get_encoder_resolution() const { return encoder_click_resolution; }
47
48 // Menu
49 void enter_menu_mode(bool force= false);
50 void setup_menu(uint16_t rows, uint16_t lines);
51 void setup_menu(uint16_t rows);
52 void menu_update();
53 bool menu_change();
54 uint16_t max_screen_lines() { return screen_lines; }
55 uint16_t get_menu_current_line() { return menu_current_line; }
56
57 // Control
58 bool enter_control_mode(float passed_normal_increment, float passed_pressed_increment);
59 void set_control_value(float value);
60 float get_control_value();
61 bool control_value_change();
62 void control_value_update();
63 float get_jogging_speed(char axis) { return jogging_speed_mm_min[axis-'X']; }
64 float get_default_hotend_temp() { return default_hotend_temperature; }
65 float get_default_bed_temp() { return default_bed_temperature; }
66
67 // file playing from sd
68 bool is_playing() const;
69 void set_playing_file(string f);
70 const char* get_playing_file() { return playing_file; }
71
72 string getMessage() { return message; }
73 bool hasMessage() { return message.size() > 0; }
74
75 // public as it is directly accessed by screens... not good
76 // TODO pass lcd into ctor of each sub screen
77 LcdBase* lcd;
78 PanelScreen* custom_screen;
79 PanelScreen* temperature_screen;
80
81 // as panelscreen accesses private fields in Panel
82 friend class PanelScreen;
83
84 private:
85 void setup_temperature_screen();
86
87 // Menu
88 char menu_offset;
89 int menu_selected_line;
90 int menu_start_line;
91 int menu_rows;
92 int panel_lines;
93 bool menu_changed;
94 bool control_value_changed;
95 uint16_t menu_current_line;
96
97 // Control
98 float normal_increment;
99 int control_normal_counter;
100 float control_base_value;
101
102 Button up_button;
103 Button down_button;
104 Button back_button;
105 Button click_button;
106 Button pause_button;
107
108 int* counter;
109 volatile bool counter_changed;
110 volatile bool click_changed;
111 volatile bool refresh_flag;
112 volatile bool do_buttons;
113 volatile bool do_encoder;
114 bool paused;
115 int idle_time;
116 bool start_up;
117 int encoder_click_resolution;
118 char mode;
119 uint16_t screen_lines;
120
121 PanelScreen* top_screen;
122 PanelScreen* current_screen;
123
124 float jogging_speed_mm_min[3];
125 float default_hotend_temperature;
126 float default_bed_temperature;
127
128 char playing_file[20];
129 string message;
130 };
131
132 #endif