Merge pull request #270 from wolfmanjm/upstreamedge
[clinton/Smoothieware.git] / src / modules / utils / panel / screens / ExtruderScreen.cpp
1 /*
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/>.
6 */
7
8 #include "libs/Kernel.h"
9 #include "libs/SerialMessage.h"
10 #include "Panel.h"
11 #include "PanelScreen.h"
12 #include "ExtruderScreen.h"
13 #include "libs/nuts_bolts.h"
14 #include "libs/utils.h"
15 #include <string>
16
17 using namespace std;
18
19
20 ExtruderScreen::ExtruderScreen()
21 {
22 }
23
24 void ExtruderScreen::on_enter()
25 {
26 this->panel->enter_menu_mode();
27 this->panel->setup_menu(3);
28 this->refresh_menu();
29 }
30
31 void ExtruderScreen::on_refresh()
32 {
33 if ( this->panel->menu_change() ) {
34 this->refresh_menu();
35 }
36 if ( this->panel->click() ) {
37 this->clicked_menu_entry(this->panel->get_menu_current_line());
38 }
39 }
40
41 void ExtruderScreen::display_menu_line(uint16_t line)
42 {
43 switch ( line ) {
44 case 0: this->panel->lcd->printf("Back"); break;
45 case 1: this->panel->lcd->printf("Extrude 5mm"); break;
46 case 2: this->panel->lcd->printf("Retract 5mm"); break;
47 }
48 }
49
50 void ExtruderScreen::clicked_menu_entry(uint16_t line)
51 {
52 switch ( line ) {
53 case 0: this->panel->enter_screen(this->parent); return;
54 case 1: command = "G91\nG1 E5\nG90"; break;
55 case 2: command = "G91\nG1 E-5\nG90"; break;
56 }
57 }
58
59 // queuing commands needs to be done from main loop
60 void ExtruderScreen::on_main_loop()
61 {
62 if (this->command.empty()) return;
63 send_command(this->command.c_str());
64 this->command.clear();
65 }