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 "Panel.h" | |
10 | #include "PanelScreen.h" | |
383c9c1c | 11 | #include "LcdBase.h" |
35089dc7 JM |
12 | #include "MainMenuScreen.h" |
13 | #include "WatchScreen.h" | |
14 | #include "FileScreen.h" | |
383c9c1c | 15 | #include "JogScreen.h" |
35089dc7 JM |
16 | #include "ControlScreen.h" |
17 | #include "PrepareScreen.h" | |
c51bd067 | 18 | #include "ProbeScreen.h" |
35089dc7 JM |
19 | #include "libs/nuts_bolts.h" |
20 | #include "libs/utils.h" | |
21 | #include "modules/utils/player/PlayerPublicAccess.h" | |
61134a65 JM |
22 | #include "PublicData.h" |
23 | #include "checksumm.h" | |
2fa50ca0 JM |
24 | #include "ModifyValuesScreen.h" |
25 | #include "Robot.h" | |
26 | #include "Planner.h" | |
27 | #include "StepperMotor.h" | |
ea5c6d92 | 28 | #include "EndstopsPublicAccess.h" |
80d884ec | 29 | #include "LaserScreen.h" |
35089dc7 JM |
30 | |
31 | #include <string> | |
32 | using namespace std; | |
33 | ||
d87968be JM |
34 | #define extruder_checksum CHECKSUM("extruder") |
35 | ||
862fc625 JM |
36 | MainMenuScreen::MainMenuScreen() |
37 | { | |
58d6d841 JM |
38 | // Children screens |
39 | this->jog_screen = (new JogScreen() )->set_parent(this); | |
40 | this->watch_screen = (new WatchScreen() )->set_parent(this); | |
41 | this->file_screen = (new FileScreen() )->set_parent(this); | |
42 | this->prepare_screen = (new PrepareScreen() )->set_parent(this); | |
43 | this->set_parent(this->watch_screen); | |
35089dc7 JM |
44 | } |
45 | ||
383c9c1c JM |
46 | // setup and enter the configure screen |
47 | void MainMenuScreen::setupConfigureScreen() | |
2fa50ca0 | 48 | { |
383c9c1c | 49 | auto mvs= new ModifyValuesScreen(true); // delete itself on exit |
2fa50ca0 JM |
50 | mvs->set_parent(this); |
51 | ||
29e809e0 JM |
52 | // acceleration |
53 | mvs->addMenuItem("def Acceleration", // menu name | |
54 | []() -> float { return THEROBOT->get_default_acceleration(); }, // getter | |
2fa50ca0 JM |
55 | [this](float acc) { send_gcode("M204", 'S', acc); }, // setter |
56 | 10.0F, // increment | |
57 | 1.0F, // Min | |
58 | 10000.0F // Max | |
59 | ); | |
60 | ||
61 | // steps/mm | |
62 | mvs->addMenuItem("X steps/mm", | |
c8bac202 JM |
63 | []() -> float { return THEROBOT->actuators[0]->get_steps_per_mm(); }, |
64 | [](float v) { THEROBOT->actuators[0]->change_steps_per_mm(v); }, | |
2fa50ca0 JM |
65 | 0.1F, |
66 | 1.0F | |
67 | ); | |
68 | ||
69 | mvs->addMenuItem("Y steps/mm", | |
c8bac202 JM |
70 | []() -> float { return THEROBOT->actuators[1]->get_steps_per_mm(); }, |
71 | [](float v) { THEROBOT->actuators[1]->change_steps_per_mm(v); }, | |
2fa50ca0 JM |
72 | 0.1F, |
73 | 1.0F | |
74 | ); | |
75 | ||
76 | mvs->addMenuItem("Z steps/mm", | |
c8bac202 JM |
77 | []() -> float { return THEROBOT->actuators[2]->get_steps_per_mm(); }, |
78 | [](float v) { THEROBOT->actuators[2]->change_steps_per_mm(v); }, | |
2fa50ca0 JM |
79 | 0.1F, |
80 | 1.0F | |
81 | ); | |
82 | ||
8b6bc932 JM |
83 | mvs->addMenuItem("Contrast", |
84 | []() -> float { return THEPANEL->lcd->getContrast(); }, | |
85 | [this](float v) { THEPANEL->lcd->setContrast(v); }, | |
86 | 1, | |
87 | 0, | |
88 | 255, | |
89 | true // instant update | |
90 | ); | |
91 | ||
383c9c1c | 92 | THEPANEL->enter_screen(mvs); |
2fa50ca0 JM |
93 | } |
94 | ||
862fc625 JM |
95 | void MainMenuScreen::on_enter() |
96 | { | |
cee1bb2d | 97 | THEPANEL->enter_menu_mode(); |
80d884ec | 98 | THEPANEL->setup_menu(THEPANEL->has_laser()?8:7); |
862fc625 | 99 | this->refresh_menu(); |
35089dc7 JM |
100 | } |
101 | ||
862fc625 JM |
102 | void MainMenuScreen::on_refresh() |
103 | { | |
cee1bb2d | 104 | if ( THEPANEL->menu_change() ) { |
862fc625 | 105 | this->refresh_menu(); |
35089dc7 | 106 | } |
cee1bb2d JM |
107 | if ( THEPANEL->click() ) { |
108 | this->clicked_menu_entry(THEPANEL->get_menu_current_line()); | |
35089dc7 | 109 | } |
35089dc7 JM |
110 | } |
111 | ||
862fc625 JM |
112 | void MainMenuScreen::display_menu_line(uint16_t line) |
113 | { | |
114 | switch ( line ) { | |
c5f6bd90 | 115 | case 0: THEPANEL->lcd->printf("DRO"); break; |
73706276 | 116 | case 1: if(THEKERNEL->is_halted()) THEPANEL->lcd->printf("Clear HALT"); else THEPANEL->lcd->printf(THEPANEL->is_playing() ? "Abort" : "Play"); break; |
cee1bb2d JM |
117 | case 2: THEPANEL->lcd->printf("Jog"); break; |
118 | case 3: THEPANEL->lcd->printf("Prepare"); break; | |
119 | case 4: THEPANEL->lcd->printf("Custom"); break; | |
120 | case 5: THEPANEL->lcd->printf("Configure"); break; | |
c51bd067 | 121 | case 6: THEPANEL->lcd->printf("Probe"); break; |
289380f2 | 122 | case 7: THEPANEL->lcd->printf("Laser"); break; // only used if THEPANEL->has_laser() |
35089dc7 | 123 | } |
35089dc7 JM |
124 | } |
125 | ||
862fc625 JM |
126 | void MainMenuScreen::clicked_menu_entry(uint16_t line) |
127 | { | |
128 | switch ( line ) { | |
728477c4 JM |
129 | case 0: THEPANEL->enter_screen(this->watch_screen); break; |
130 | case 1: | |
73706276 | 131 | if(THEKERNEL->is_halted()){ |
728477c4 JM |
132 | send_command("M999"); |
133 | THEPANEL->enter_screen(this->watch_screen); | |
134 | }else if(THEPANEL->is_playing()) abort_playing(); | |
135 | else THEPANEL->enter_screen(this->file_screen); break; | |
cee1bb2d JM |
136 | case 2: THEPANEL->enter_screen(this->jog_screen ); break; |
137 | case 3: THEPANEL->enter_screen(this->prepare_screen ); break; | |
138 | case 4: THEPANEL->enter_screen(THEPANEL->custom_screen ); break; | |
383c9c1c | 139 | case 5: setupConfigureScreen(); break; |
c51bd067 | 140 | case 6: THEPANEL->enter_screen((new ProbeScreen())->set_parent(this)); break; |
289380f2 | 141 | case 7: THEPANEL->enter_screen((new LaserScreen())->set_parent(this)); break; // self deleting, only used if THEPANEL->has_laser() |
35089dc7 JM |
142 | } |
143 | } | |
144 | ||
862fc625 JM |
145 | void MainMenuScreen::abort_playing() |
146 | { | |
11c5e41e JM |
147 | //PublicData::set_value(player_checksum, abort_play_checksum, NULL); |
148 | send_command("abort"); | |
cee1bb2d | 149 | THEPANEL->enter_screen(this->watch_screen); |
35089dc7 JM |
150 | } |
151 |