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/>.
11 #include "libs/Kernel.h"
12 #include "libs/nuts_bolts.h"
13 #include "libs/utils.h"
15 #include "panels/LcdBase.h"
17 #include "PanelScreen.h"
18 #include "screens/MainMenuScreen.h"
20 #define panel_checksum CHECKSUM("panel")
21 #define enable_checksum CHECKSUM("enable")
22 #define lcd_checksum CHECKSUM("lcd")
23 #define i2c_lcd_checksum CHECKSUM("i2c_lcd")
24 #define viki_lcd_checksum CHECKSUM("viki_lcd")
26 #define jog_x_feedrate_checksum CHECKSUM("alpha_jog_feedrate")
27 #define jog_y_feedrate_checksum CHECKSUM("beta_jog_feedrate")
28 #define jog_z_feedrate_checksum CHECKSUM("gamma_jog_feedrate")
31 #define CONTROL_MODE 1
34 class Panel
: public Module
{
39 void on_module_loaded();
40 uint32_t button_tick(uint32_t dummy
);
41 void on_idle(void* argument
);
42 void on_main_loop(void* argument
);
43 void enter_screen(PanelScreen
* screen
);
46 // Encoder and buttons
47 uint32_t on_up(uint32_t dummy
);
48 uint32_t on_down(uint32_t dummy
);
49 uint32_t on_back(uint32_t dummy
);
50 uint32_t on_click_release(uint32_t dummy
);
51 uint32_t refresh_tick(uint32_t dummy
);
52 uint32_t encoder_check(uint32_t dummy
);
53 bool counter_change();
55 int get_encoder_resolution() const { return encoder_click_resolution
; }
58 void enter_menu_mode();
59 void setup_menu(uint16_t rows
, uint16_t lines
);
62 uint16_t menu_current_line();
65 bool enter_control_mode(double passed_normal_increment
, double passed_pressed_increment
);
66 void set_control_value(double value
);
67 double get_control_value();
68 bool control_value_change();
69 void control_value_update();
70 double get_jogging_speed(char axis
) { return jogging_speed_mm_min
[axis
-'X']; }
72 // file playing from sd
73 bool is_playing() const;
74 void set_playing_file(string f
) { playing_file
= f
; }
75 string
get_playing_file() { return playing_file
; }
77 // public as it is directly accessed by screens... not good
78 // TODO pass lcd into ctor of each sub screen
81 // as panelscreen accesses private fields in Panel
82 friend class PanelScreen
;
87 int menu_selected_line
;
92 bool control_value_changed
;
95 double normal_increment
;
96 double pressed_increment
;
97 int control_normal_counter
;
98 int control_pressed_counter
;
99 double control_base_value
;
107 volatile bool counter_changed
;
108 volatile bool click_changed
;
109 volatile bool refresh_flag
;
110 volatile bool do_buttons
;
112 int encoder_click_resolution
;
115 MainMenuScreen
* top_screen
;
116 PanelScreen
* current_screen
;
118 double jogging_speed_mm_min
[3];