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 | 12 | #include "PrepareScreen.h" |
27102c66 | 13 | #include "ExtruderScreen.h" |
35089dc7 JM |
14 | #include "libs/nuts_bolts.h" |
15 | #include "libs/utils.h" | |
61134a65 | 16 | #include "checksumm.h" |
cee1bb2d JM |
17 | #include "PublicDataRequest.h" |
18 | #include "PublicData.h" | |
19 | #include "TemperatureControlPublicAccess.h" | |
c77d6dae | 20 | #include "ModifyValuesScreen.h" |
f19a841a | 21 | #include <string> |
35089dc7 JM |
22 | using namespace std; |
23 | ||
862fc625 JM |
24 | PrepareScreen::PrepareScreen() |
25 | { | |
acec7d1f | 26 | this->command = nullptr; |
27 | ||
58d6d841 | 28 | // Children screens |
91bce49a JM |
29 | if(THEPANEL->temperature_screen != nullptr) { |
30 | this->extruder_screen = (new ExtruderScreen())->set_parent(this); | |
31 | THEPANEL->temperature_screen->set_parent(this); | |
32 | }else{ | |
33 | this->extruder_screen= nullptr; | |
34 | } | |
35089dc7 JM |
35 | } |
36 | ||
862fc625 JM |
37 | void PrepareScreen::on_enter() |
38 | { | |
cee1bb2d | 39 | THEPANEL->enter_menu_mode(); |
91bce49a JM |
40 | // if no heaters or extruder then don't show related menu items |
41 | THEPANEL->setup_menu((THEPANEL->temperature_screen != nullptr) ? 9 : 5); | |
862fc625 | 42 | this->refresh_menu(); |
35089dc7 JM |
43 | } |
44 | ||
862fc625 JM |
45 | void PrepareScreen::on_refresh() |
46 | { | |
cee1bb2d | 47 | if ( THEPANEL->menu_change() ) { |
862fc625 | 48 | this->refresh_menu(); |
35089dc7 | 49 | } |
cee1bb2d JM |
50 | if ( THEPANEL->click() ) { |
51 | this->clicked_menu_entry(THEPANEL->get_menu_current_line()); | |
35089dc7 JM |
52 | } |
53 | } | |
54 | ||
862fc625 JM |
55 | void PrepareScreen::display_menu_line(uint16_t line) |
56 | { | |
57 | switch ( line ) { | |
cee1bb2d JM |
58 | case 0: THEPANEL->lcd->printf("Back" ); break; |
59 | case 1: THEPANEL->lcd->printf("Home All Axis" ); break; | |
60 | case 2: THEPANEL->lcd->printf("Set Home" ); break; | |
61 | case 3: THEPANEL->lcd->printf("Set Z0" ); break; | |
91bce49a JM |
62 | case 4: THEPANEL->lcd->printf("Motors off" ); break; |
63 | // these won't be accessed if no heaters or extruders | |
64 | case 5: THEPANEL->lcd->printf("Pre Heat" ); break; | |
65 | case 6: THEPANEL->lcd->printf("Cool Down" ); break; | |
66 | case 7: THEPANEL->lcd->printf("Extruder..." ); break; | |
cee1bb2d | 67 | case 8: THEPANEL->lcd->printf("Set Temperature"); break; |
35089dc7 JM |
68 | } |
69 | } | |
70 | ||
862fc625 JM |
71 | void PrepareScreen::clicked_menu_entry(uint16_t line) |
72 | { | |
73 | switch ( line ) { | |
cee1bb2d | 74 | case 0: THEPANEL->enter_screen(this->parent); break; |
862fc625 JM |
75 | case 1: command = "G28"; break; |
76 | case 2: command = "G92 X0 Y0 Z0"; break; | |
77 | case 3: command = "G92 Z0"; break; | |
91bce49a JM |
78 | case 4: command = "M84"; break; |
79 | case 5: this->preheat(); break; | |
80 | case 6: this->cooldown(); break; | |
81 | case 7: THEPANEL->enter_screen(this->extruder_screen); break; | |
cee1bb2d | 82 | case 8: THEPANEL->enter_screen(THEPANEL->temperature_screen); break; |
35089dc7 | 83 | } |
35089dc7 JM |
84 | } |
85 | ||
862fc625 JM |
86 | void PrepareScreen::preheat() |
87 | { | |
cee1bb2d | 88 | float t = THEPANEL->get_default_hotend_temp(); |
75e6428d | 89 | PublicData::set_value( temperature_control_checksum, hotend_checksum, &t ); |
cee1bb2d | 90 | t = THEPANEL->get_default_bed_temp(); |
75e6428d | 91 | PublicData::set_value( temperature_control_checksum, bed_checksum, &t ); |
35089dc7 JM |
92 | } |
93 | ||
862fc625 JM |
94 | void PrepareScreen::cooldown() |
95 | { | |
1ad23cd3 | 96 | float t = 0; |
75e6428d JM |
97 | PublicData::set_value( temperature_control_checksum, hotend_checksum, &t ); |
98 | PublicData::set_value( temperature_control_checksum, bed_checksum, &t ); | |
35089dc7 JM |
99 | } |
100 | ||
82d1ceb3 | 101 | // queuing commands needs to be done from main loop |
862fc625 JM |
102 | void PrepareScreen::on_main_loop() |
103 | { | |
82d1ceb3 | 104 | // change actual axis value |
acec7d1f | 105 | if (this->command == nullptr) return; |
106 | send_command(this->command); | |
107 | this->command = nullptr; | |
35089dc7 | 108 | } |