Commit | Line | Data |
---|---|---|
446deda2 | 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. | |
446deda2 | 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 | #include "libs/Kernel.h" | |
9 | #include "libs/SerialMessage.h" | |
10 | #include "Panel.h" | |
11 | #include "PanelScreen.h" | |
383c9c1c | 12 | #include "LcdBase.h" |
35089dc7 JM |
13 | #include "MainMenuScreen.h" |
14 | #include "JogScreen.h" | |
f9a0f86d | 15 | #include "DirectJogScreen.h" |
35089dc7 | 16 | #include "ControlScreen.h" |
98c31f2d | 17 | #include "ModifyValuesScreen.h" |
35089dc7 JM |
18 | #include "libs/nuts_bolts.h" |
19 | #include "libs/utils.h" | |
20 | #include <string> | |
21 | ||
22 | using namespace std; | |
23 | ||
24 | ||
862fc625 JM |
25 | JogScreen::JogScreen() |
26 | { | |
58d6d841 JM |
27 | this->control_screen = new ControlScreen(); |
28 | this->control_screen->set_parent(this); | |
35089dc7 JM |
29 | } |
30 | ||
862fc625 JM |
31 | void JogScreen::on_enter() |
32 | { | |
cee1bb2d | 33 | THEPANEL->enter_menu_mode(); |
289380f2 | 34 | THEPANEL->setup_menu(10); |
862fc625 | 35 | this->refresh_menu(); |
35089dc7 JM |
36 | } |
37 | ||
862fc625 JM |
38 | void JogScreen::on_refresh() |
39 | { | |
cee1bb2d | 40 | if ( THEPANEL->menu_change() ) { |
862fc625 | 41 | this->refresh_menu(); |
58d6d841 | 42 | } |
cee1bb2d JM |
43 | if ( THEPANEL->click() ) { |
44 | this->clicked_menu_entry(THEPANEL->get_menu_current_line()); | |
58d6d841 | 45 | } |
35089dc7 JM |
46 | } |
47 | ||
862fc625 JM |
48 | void JogScreen::display_menu_line(uint16_t line) |
49 | { | |
50 | switch ( line ) { | |
cee1bb2d | 51 | case 0: THEPANEL->lcd->printf("Back"); break; |
5c19e191 JM |
52 | case 1: THEPANEL->lcd->printf("Move 10.0 "); break; |
53 | case 2: THEPANEL->lcd->printf("Move 1.0 "); break; | |
54 | case 3: THEPANEL->lcd->printf("Move 0.1 "); break; | |
55 | case 4: THEPANEL->lcd->printf("Move 0.01 "); break; | |
56 | case 5: THEPANEL->lcd->printf("Move 0.001 "); break; | |
57 | case 6: THEPANEL->lcd->printf("MPG mode "); break; | |
58 | case 7: THEPANEL->lcd->printf("Feed Rates "); break; | |
289380f2 JM |
59 | case 8: THEPANEL->lcd->printf("Goto Park Posn "); break; |
60 | case 9: THEPANEL->lcd->printf("Set Park Posn "); break; | |
35089dc7 JM |
61 | } |
62 | } | |
63 | ||
862fc625 JM |
64 | void JogScreen::clicked_menu_entry(uint16_t line) |
65 | { | |
98c31f2d | 66 | bool dojog= true; |
862fc625 | 67 | switch ( line ) { |
cee1bb2d | 68 | case 0: THEPANEL->enter_screen(this->parent); return; |
5c19e191 JM |
69 | case 1: this->control_screen->set_jog_increment(10.0F); break; |
70 | case 2: this->control_screen->set_jog_increment(1.0F); break; | |
71 | case 3: this->control_screen->set_jog_increment(0.1F); break; | |
72 | case 4: this->control_screen->set_jog_increment(0.01F); break; | |
73 | case 5: this->control_screen->set_jog_increment(0.001F); break; | |
74 | case 6: { | |
98c31f2d JM |
75 | auto djs = new DirectJogScreen(); |
76 | djs->set_parent(this); | |
77 | THEPANEL->enter_screen(djs); // self deleting | |
78 | dojog= false; | |
79 | } break; | |
5c19e191 | 80 | case 7: |
98c31f2d JM |
81 | set_feed_rates(); |
82 | dojog= false; | |
289380f2 JM |
83 | case 8: send_command("G28"); dojog= false; break; |
84 | case 9: send_command("G28.1"); dojog= false; break; | |
85 | ||
f9a0f86d JM |
86 | } |
87 | ||
98c31f2d | 88 | if(dojog) { |
f9a0f86d | 89 | THEPANEL->enter_screen(this->control_screen); |
35089dc7 | 90 | } |
35089dc7 | 91 | } |
98c31f2d JM |
92 | |
93 | void JogScreen::set_feed_rates() | |
94 | { | |
95 | auto mvs = new ModifyValuesScreen(true); // self delete on exit | |
96 | mvs->set_parent(this); | |
97 | ||
98 | for (int i = 0; i < 3; ++i) { | |
99 | string label; | |
100 | label.append(1, 'X' + i).append(" mm/min"); | |
101 | mvs->addMenuItem(label.c_str(), | |
102 | [i]() -> float { return THEPANEL->get_jogging_speed(i); }, | |
103 | [i](float v) { THEPANEL->set_jogging_speed(i, v); }, | |
104 | 10.0F, 1.0F); | |
105 | } | |
106 | ||
107 | THEPANEL->enter_screen(mvs); | |
108 | } |