Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
PanelScreen.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 "libs/nuts_bolts.h" 00012 #include "libs/utils.h" 00013 #include "libs/SerialMessage.h" 00014 #include <string> 00015 #include <vector> 00016 00017 using namespace std; 00018 00019 PanelScreen::PanelScreen() {} 00020 00021 void PanelScreen::on_refresh() {} 00022 void PanelScreen::on_main_loop() {} 00023 00024 PanelScreen *PanelScreen::set_panel(Panel *parent) 00025 { 00026 this->panel = parent; 00027 return this; 00028 } 00029 00030 void PanelScreen::on_enter() {} 00031 00032 void PanelScreen::refresh_menu(bool clear) 00033 { 00034 if (clear) this->panel->lcd->clear(); 00035 for (uint16_t i = this->panel->menu_start_line; i < this->panel->menu_start_line + min( this->panel->menu_rows, this->panel->panel_lines ); i++ ) { 00036 this->panel->lcd->setCursor(2, i - this->panel->menu_start_line ); 00037 this->display_menu_line(i); 00038 } 00039 this->panel->lcd->setCursor(0, this->panel->menu_current_line - this->panel->menu_start_line ); 00040 this->panel->lcd->printf(">"); 00041 } 00042 00043 void PanelScreen::refresh_screen(bool clear) 00044 { 00045 if (clear) this->panel->lcd->clear(); 00046 for (uint16_t i = this->panel->menu_start_line; i < this->panel->menu_start_line + min( this->panel->menu_rows, this->panel->panel_lines ); i++ ) { 00047 this->panel->lcd->setCursor(0, i - this->panel->menu_start_line ); 00048 this->display_menu_line(i); 00049 } 00050 } 00051 00052 PanelScreen *PanelScreen::set_parent(PanelScreen *passed_parent) 00053 { 00054 this->parent = passed_parent; 00055 this->set_panel( passed_parent->panel ); 00056 return this; 00057 } 00058 00059 // Helper for screens to send a gcode, must be called from main loop 00060 void PanelScreen::send_gcode(std::string g) 00061 { 00062 Gcode gcode(g, &(StreamOutput::NullStream)); 00063 THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode ); 00064 } 00065 00066 // Helper to send commands, must be called from mainloop 00067 // may contain multipe commands separated by \n 00068 void PanelScreen::send_command(const char *gcstr) 00069 { 00070 string cmd(gcstr); 00071 vector<string> q; 00072 while (cmd.size() > 0) { 00073 size_t b = cmd.find_first_of("\n"); 00074 if ( b == string::npos ) { 00075 q.push_back(cmd); 00076 break; 00077 } 00078 q.push_back(cmd.substr( 0, b )); 00079 cmd = cmd.substr(b + 1); 00080 } 00081 00082 // for each command send it 00083 for (std::vector<string>::iterator i = q.begin(); i != q.end(); ++i) { 00084 struct SerialMessage message; 00085 message.message = *i; 00086 message.stream = &(StreamOutput::NullStream); 00087 THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message ); 00088 } 00089 }
Generated on Tue Jul 12 2022 20:09:02 by 1.7.2