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