Added new Panel stuff
[clinton/Smoothieware.git] / src / modules / utils / panel / screens / PrepareScreen.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 "Panel.h"
10 #include "PanelScreen.h"
11 #include "PrepareScreen.h"
12 #include "libs/nuts_bolts.h"
13 #include "libs/utils.h"
14 #include <string>
15 #include "libs/SerialMessage.h"
16 using namespace std;
17
18 PrepareScreen::PrepareScreen(){
19 // Children screens
20 // this->extruder_screen = (new ExtruderScreen() )->set_parent(this);
21 // this->temp_screen = (new TempScreen() )->set_parent(this);
22 }
23
24 void PrepareScreen::on_enter(){
25 this->panel->enter_menu_mode();
26 this->panel->setup_menu(7, 4); // 7 menu items, 4 lines
27 this->refresh_screen();
28 }
29
30 void PrepareScreen::on_refresh(){
31 if( this->panel->menu_change() ){
32 this->refresh_screen();
33 }
34 if( this->panel->click() ){
35 this->clicked_menu_entry(this->panel->menu_current_line());
36 }
37 }
38
39 void PrepareScreen::refresh_screen(){
40 this->refresh_menu();
41 }
42
43 void PrepareScreen::display_menu_line(uint16_t line){
44 switch( line ){
45 case 0: this->panel->lcd->printf("Back" ); break;
46 case 1: this->panel->lcd->printf("Home All Axis" ); break;
47 case 2: this->panel->lcd->printf("Set Home" ); break;
48 case 3: this->panel->lcd->printf("Pre Heat" ); break;
49 case 4: this->panel->lcd->printf("Cool Down" ); break;
50 case 5: this->panel->lcd->printf("Extrude" ); break;
51 case 6: this->panel->lcd->printf("Set Temperature"); break;
52 }
53 }
54
55 void PrepareScreen::clicked_menu_entry(uint16_t line){
56 switch( line ){
57 case 0: this->panel->enter_screen(this->parent ); break;
58 case 1: send_gcode("G28"); break;
59 case 2: send_gcode("G92 X0 Y0 Z0"); break;
60 case 3: this->preheat(); break;
61 case 4: this->cooldown(); break;
62 case 5: this->panel->enter_screen(this->extruder_screen ); break;
63 case 6: this->panel->enter_screen(this->temp_screen ); break;
64 }
65
66
67 }
68
69
70 void PrepareScreen::preheat() {
71 }
72
73 void PrepareScreen::cooldown() {
74 }
75
76 void PrepareScreen::send_gcode(const char* gcstr) {
77 string gcode(gcstr);
78 struct SerialMessage message;
79 message.message = gcode;
80 message.stream = &(StreamOutput::NullStream);
81 THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
82 }