Commit | Line | Data |
---|---|---|
399cb110 | 1 | /* |
35089dc7 JM |
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. | |
399cb110 | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
35089dc7 JM |
6 | */ |
7 | ||
8 | #ifndef PANEL_H | |
9 | #define PANEL_H | |
10 | ||
89288956 | 11 | #include "Module.h" |
35089dc7 | 12 | #include "Button.h" |
fb877329 | 13 | #include "Pin.h" |
e0d0ea84 | 14 | #include <string> |
f9a0f86d | 15 | #include <functional> |
f19a841a | 16 | |
cee1bb2d JM |
17 | #define THEPANEL Panel::instance |
18 | ||
7af0714f | 19 | class LcdBase; |
ca6effd7 | 20 | class PanelScreen; |
c77d6dae | 21 | class ModifyValuesScreen; |
fb877329 JM |
22 | class SDCard; |
23 | class SDFAT; | |
7af0714f | 24 | |
35089dc7 JM |
25 | class Panel : public Module { |
26 | public: | |
27 | Panel(); | |
28 | virtual ~Panel(); | |
cee1bb2d | 29 | static Panel* instance; |
35089dc7 JM |
30 | |
31 | void on_module_loaded(); | |
32 | uint32_t button_tick(uint32_t dummy); | |
e456d044 | 33 | uint32_t encoder_tick(uint32_t dummy); |
35089dc7 JM |
34 | void on_idle(void* argument); |
35 | void on_main_loop(void* argument); | |
c89338bd | 36 | void on_set_public_data(void* argument); |
fb877329 | 37 | void on_second_tick(void* argument); |
35089dc7 JM |
38 | void enter_screen(PanelScreen* screen); |
39 | void reset_counter(); | |
40 | ||
41 | // Encoder and buttons | |
42 | uint32_t on_up(uint32_t dummy); | |
43 | uint32_t on_down(uint32_t dummy); | |
44 | uint32_t on_back(uint32_t dummy); | |
ab4abea9 | 45 | uint32_t on_select(uint32_t dummy); |
35089dc7 JM |
46 | uint32_t refresh_tick(uint32_t dummy); |
47 | uint32_t encoder_check(uint32_t dummy); | |
48 | bool counter_change(); | |
49 | bool click(); | |
50 | int get_encoder_resolution() const { return encoder_click_resolution; } | |
399cb110 | 51 | |
35089dc7 | 52 | // Menu |
89288956 | 53 | void enter_nop_mode(); |
5971142d | 54 | void enter_menu_mode(bool force= false); |
35089dc7 | 55 | void setup_menu(uint16_t rows, uint16_t lines); |
f65ce58f | 56 | void setup_menu(uint16_t rows); |
35089dc7 JM |
57 | void menu_update(); |
58 | bool menu_change(); | |
f65ce58f | 59 | uint16_t max_screen_lines() { return screen_lines; } |
446deda2 | 60 | uint16_t get_menu_current_line() { return menu_current_line; } |
399cb110 | 61 | |
35089dc7 | 62 | // Control |
1ad23cd3 MM |
63 | bool enter_control_mode(float passed_normal_increment, float passed_pressed_increment); |
64 | void set_control_value(float value); | |
65 | float get_control_value(); | |
35089dc7 JM |
66 | bool control_value_change(); |
67 | void control_value_update(); | |
1ad23cd3 MM |
68 | float get_jogging_speed(char axis) { return jogging_speed_mm_min[axis-'X']; } |
69 | float get_default_hotend_temp() { return default_hotend_temperature; } | |
70 | float get_default_bed_temp() { return default_bed_temperature; } | |
35089dc7 JM |
71 | |
72 | // file playing from sd | |
73 | bool is_playing() const; | |
5f1a896b | 74 | bool is_suspended() const; |
89288956 | 75 | void set_playing_file(std::string f); |
7aa9fef3 | 76 | const char* get_playing_file() { return playing_file; } |
399cb110 | 77 | |
89288956 | 78 | std::string getMessage() { return message; } |
399cb110 JM |
79 | bool hasMessage() { return message.size() > 0; } |
80 | ||
f4780d4e JM |
81 | uint16_t get_screen_lines() const { return screen_lines; } |
82 | ||
98c31f2d JM |
83 | float get_jogging_speed(int i) { return jogging_speed_mm_min[i]; } |
84 | void set_jogging_speed(int i, float v) { jogging_speed_mm_min[i]= v; } | |
85 | ||
35089dc7 JM |
86 | // public as it is directly accessed by screens... not good |
87 | // TODO pass lcd into ctor of each sub screen | |
88 | LcdBase* lcd; | |
ca6effd7 | 89 | PanelScreen* custom_screen; |
35089dc7 | 90 | |
f9a0f86d JM |
91 | using encoder_cb_t= std::function<void(int ticks)>; |
92 | bool enter_direct_encoder_mode(encoder_cb_t fnc); | |
93 | ||
35089dc7 JM |
94 | // as panelscreen accesses private fields in Panel |
95 | friend class PanelScreen; | |
399cb110 | 96 | |
35089dc7 | 97 | private: |
cee1bb2d | 98 | |
fb877329 JM |
99 | // external SD card |
100 | bool mount_external_sd(bool on); | |
101 | Pin sdcd_pin; | |
fb877329 JM |
102 | PinName extsd_spi_cs; |
103 | SDCard *sd; | |
104 | SDFAT *extmounter; | |
105 | ||
35089dc7 | 106 | // Menu |
35089dc7 JM |
107 | int menu_selected_line; |
108 | int menu_start_line; | |
109 | int menu_rows; | |
206167cf | 110 | int panel_lines; |
35089dc7 JM |
111 | |
112 | // Control | |
1ad23cd3 | 113 | float normal_increment; |
35089dc7 | 114 | int control_normal_counter; |
1ad23cd3 | 115 | float control_base_value; |
399cb110 | 116 | |
35089dc7 JM |
117 | Button up_button; |
118 | Button down_button; | |
119 | Button back_button; | |
120 | Button click_button; | |
121 | ||
122 | int* counter; | |
f4780d4e | 123 | |
373d0bf1 JM |
124 | int idle_time; |
125 | ||
126 | PanelScreen* top_screen; | |
127 | PanelScreen* current_screen; | |
128 | ||
129 | float jogging_speed_mm_min[3]; | |
130 | float default_hotend_temperature; | |
131 | float default_bed_temperature; | |
132 | ||
89288956 | 133 | std::string message; |
f9a0f86d | 134 | encoder_cb_t encoder_cb_fnc; |
373d0bf1 JM |
135 | |
136 | uint16_t screen_lines; | |
137 | uint16_t menu_current_line; | |
138 | char playing_file[20]; | |
139 | uint8_t extsd_spi_channel; | |
140 | ||
f4780d4e JM |
141 | volatile struct { |
142 | bool start_up:1; | |
143 | bool menu_changed:1; | |
144 | bool control_value_changed:1; | |
fb877329 | 145 | bool external_sd_enable:1; |
f4780d4e JM |
146 | volatile bool counter_changed:1; |
147 | volatile bool click_changed:1; | |
148 | volatile bool refresh_flag:1; | |
149 | volatile bool do_buttons:1; | |
150 | volatile bool do_encoder:1; | |
373d0bf1 JM |
151 | char mode:2; |
152 | char menu_offset:3; | |
153 | int encoder_click_resolution:3; | |
f4780d4e | 154 | }; |
35089dc7 JM |
155 | }; |
156 | ||
157 | #endif |