Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
PrepareScreen.cpp
00001 /* 00002 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl). 00003 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. 00004 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. 00005 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. 00006 */ 00007 00008 #include "libs/Kernel.h" 00009 #include "Panel.h" 00010 #include "PanelScreen.h" 00011 #include "PrepareScreen.h" 00012 #include "ExtruderScreen.h" 00013 #include "libs/nuts_bolts.h" 00014 #include "libs/utils.h" 00015 #include "PublicDataRequest.h" 00016 #include "modules/tools/temperaturecontrol/TemperatureControlPublicAccess.h" 00017 00018 #include <string> 00019 using namespace std; 00020 00021 PrepareScreen::PrepareScreen() 00022 { 00023 // Children screens 00024 this->extruder_screen = (new ExtruderScreen() )->set_parent(this); 00025 // this->temp_screen = (new TempScreen() )->set_parent(this); 00026 } 00027 00028 void PrepareScreen::on_enter() 00029 { 00030 this->panel->enter_menu_mode(); 00031 this->panel->setup_menu(8); 00032 this->refresh_menu(); 00033 } 00034 00035 void PrepareScreen::on_refresh() 00036 { 00037 if ( this->panel->menu_change() ) { 00038 this->refresh_menu(); 00039 } 00040 if ( this->panel->click() ) { 00041 this->clicked_menu_entry(this->panel->get_menu_current_line()); 00042 } 00043 } 00044 00045 void PrepareScreen::display_menu_line(uint16_t line) 00046 { 00047 switch ( line ) { 00048 case 0: this->panel->lcd->printf("Back" ); break; 00049 case 1: this->panel->lcd->printf("Home All Axis" ); break; 00050 case 2: this->panel->lcd->printf("Set Home" ); break; 00051 case 3: this->panel->lcd->printf("Set Z0" ); break; 00052 case 4: this->panel->lcd->printf("Pre Heat" ); break; 00053 case 5: this->panel->lcd->printf("Cool Down" ); break; 00054 case 6: this->panel->lcd->printf("Extrude" ); break; 00055 case 7: this->panel->lcd->printf("Motors off" ); break; 00056 //case 8: this->panel->lcd->printf("Set Temperature"); break; 00057 } 00058 } 00059 00060 void PrepareScreen::clicked_menu_entry(uint16_t line) 00061 { 00062 switch ( line ) { 00063 case 0: this->panel->enter_screen(this->parent); break; 00064 case 1: command = "G28"; break; 00065 case 2: command = "G92 X0 Y0 Z0"; break; 00066 case 3: command = "G92 Z0"; break; 00067 case 4: this->preheat(); break; 00068 case 5: this->cooldown(); break; 00069 case 6: this->panel->enter_screen(this->extruder_screen); break; 00070 case 7: command = "M84"; break; 00071 //case 8: this->panel->enter_screen(this->temp_screen ); break; 00072 } 00073 } 00074 00075 void PrepareScreen::preheat() 00076 { 00077 float t = panel->get_default_hotend_temp(); 00078 THEKERNEL->public_data->set_value( temperature_control_checksum, hotend_checksum, &t ); 00079 t = panel->get_default_bed_temp(); 00080 THEKERNEL->public_data->set_value( temperature_control_checksum, bed_checksum, &t ); 00081 } 00082 00083 void PrepareScreen::cooldown() 00084 { 00085 float t = 0; 00086 THEKERNEL->public_data->set_value( temperature_control_checksum, hotend_checksum, &t ); 00087 THEKERNEL->public_data->set_value( temperature_control_checksum, bed_checksum, &t ); 00088 } 00089 00090 // queuing commands needs to be done from main loop 00091 void PrepareScreen::on_main_loop() 00092 { 00093 // change actual axis value 00094 if (this->command.empty()) return; 00095 send_command(this->command.c_str()); 00096 this->command.clear(); 00097 }
Generated on Tue Jul 12 2022 20:09:02 by 1.7.2