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/>.
8 #include "libs/Kernel.h"
10 #include "PanelScreen.h"
12 #include "MainMenuScreen.h"
13 #include "WatchScreen.h"
14 #include "FileScreen.h"
15 #include "JogScreen.h"
16 #include "ControlScreen.h"
17 #include "PrepareScreen.h"
18 #include "ProbeScreen.h"
19 #include "libs/nuts_bolts.h"
20 #include "libs/utils.h"
21 #include "modules/utils/player/PlayerPublicAccess.h"
22 #include "PublicData.h"
23 #include "checksumm.h"
24 #include "ModifyValuesScreen.h"
27 #include "StepperMotor.h"
28 #include "EndstopsPublicAccess.h"
33 #define extruder_checksum CHECKSUM("extruder")
35 MainMenuScreen::MainMenuScreen()
38 this->jog_screen
= (new JogScreen() )->set_parent(this);
39 this->watch_screen
= (new WatchScreen() )->set_parent(this);
40 this->file_screen
= (new FileScreen() )->set_parent(this);
41 this->prepare_screen
= (new PrepareScreen() )->set_parent(this);
42 this->set_parent(this->watch_screen
);
45 // setup and enter the configure screen
46 void MainMenuScreen::setupConfigureScreen()
48 auto mvs
= new ModifyValuesScreen(true); // delete itself on exit
49 mvs
->set_parent(this);
52 mvs
->addMenuItem("def Acceleration", // menu name
53 []() -> float { return THEROBOT
->get_default_acceleration(); }, // getter
54 [this](float acc
) { send_gcode("M204", 'S', acc
); }, // setter
61 mvs
->addMenuItem("X steps/mm",
62 []() -> float { return THEROBOT
->actuators
[0]->get_steps_per_mm(); },
63 [](float v
) { THEROBOT
->actuators
[0]->change_steps_per_mm(v
); },
68 mvs
->addMenuItem("Y steps/mm",
69 []() -> float { return THEROBOT
->actuators
[1]->get_steps_per_mm(); },
70 [](float v
) { THEROBOT
->actuators
[1]->change_steps_per_mm(v
); },
75 mvs
->addMenuItem("Z steps/mm",
76 []() -> float { return THEROBOT
->actuators
[2]->get_steps_per_mm(); },
77 [](float v
) { THEROBOT
->actuators
[2]->change_steps_per_mm(v
); },
82 mvs
->addMenuItem("Z Home Ofs",
83 []() -> float { void *rd
; PublicData::get_value( endstops_checksum
, home_offset_checksum
, &rd
); return rd
==nullptr ? 0.0F
: ((float*)rd
)[2]; },
84 [this](float v
) { send_gcode("M206", 'Z', v
); },
88 mvs
->addMenuItem("Contrast",
89 []() -> float { return THEPANEL
->lcd
->getContrast(); },
90 [this](float v
) { THEPANEL
->lcd
->setContrast(v
); },
94 true // instant update
97 THEPANEL
->enter_screen(mvs
);
100 void MainMenuScreen::on_enter()
102 THEPANEL
->enter_menu_mode();
103 THEPANEL
->setup_menu(7);
104 this->refresh_menu();
107 void MainMenuScreen::on_refresh()
109 if ( THEPANEL
->menu_change() ) {
110 this->refresh_menu();
112 if ( THEPANEL
->click() ) {
113 this->clicked_menu_entry(THEPANEL
->get_menu_current_line());
117 void MainMenuScreen::display_menu_line(uint16_t line
)
120 case 0: THEPANEL
->lcd
->printf("Watch"); break;
121 case 1: if(THEKERNEL
->is_halted()) THEPANEL
->lcd
->printf("Clear HALT"); else THEPANEL
->lcd
->printf(THEPANEL
->is_playing() ? "Abort" : "Play"); break;
122 case 2: THEPANEL
->lcd
->printf("Jog"); break;
123 case 3: THEPANEL
->lcd
->printf("Prepare"); break;
124 case 4: THEPANEL
->lcd
->printf("Custom"); break;
125 case 5: THEPANEL
->lcd
->printf("Configure"); break;
126 case 6: THEPANEL
->lcd
->printf("Probe"); break;
130 void MainMenuScreen::clicked_menu_entry(uint16_t line
)
133 case 0: THEPANEL
->enter_screen(this->watch_screen
); break;
135 if(THEKERNEL
->is_halted()){
136 send_command("M999");
137 THEPANEL
->enter_screen(this->watch_screen
);
138 }else if(THEPANEL
->is_playing()) abort_playing();
139 else THEPANEL
->enter_screen(this->file_screen
); break;
140 case 2: THEPANEL
->enter_screen(this->jog_screen
); break;
141 case 3: THEPANEL
->enter_screen(this->prepare_screen
); break;
142 case 4: THEPANEL
->enter_screen(THEPANEL
->custom_screen
); break;
143 case 5: setupConfigureScreen(); break;
144 case 6: THEPANEL
->enter_screen((new ProbeScreen())->set_parent(this)); break;
148 void MainMenuScreen::abort_playing()
150 //PublicData::set_value(player_checksum, abort_play_checksum, NULL);
151 send_command("abort");
152 THEPANEL
->enter_screen(this->watch_screen
);