fix a re entrancy bug in panel affecting menu
[clinton/Smoothieware.git] / src / modules / utils / panel / PanelScreen.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 "libs/nuts_bolts.h"
12 #include "libs/utils.h"
13 #include <string>
14 using namespace std;
15
16 PanelScreen::PanelScreen(){}
17
18 void PanelScreen::on_refresh(){}
19 void PanelScreen::on_main_loop(){}
20
21 PanelScreen* PanelScreen::set_panel(Panel* parent){
22 this->panel = parent;
23 return this;
24 }
25
26 void PanelScreen::on_enter(){}
27
28 void PanelScreen::refresh_menu(bool clear){
29 if(clear) this->panel->lcd->clear();
30 for(uint16_t i = this->panel->menu_start_line; i < this->panel->menu_start_line + min( this->panel->menu_rows, this->panel->menu_lines ); i++ ){
31 this->panel->lcd->setCursor(2, i - this->panel->menu_start_line );
32 this->display_menu_line(i);
33 }
34 this->panel->lcd->setCursor(0, this->panel->menu_current_line - this->panel->menu_start_line );
35 this->panel->lcd->printf(">");
36 }
37
38 void PanelScreen::refresh_screen(bool clear){
39 if(clear) this->panel->lcd->clear();
40 for(uint16_t i = this->panel->menu_start_line; i < this->panel->menu_start_line + min( this->panel->menu_rows, this->panel->menu_lines ); i++ ){
41 this->panel->lcd->setCursor(0, i - this->panel->menu_start_line );
42 this->display_menu_line(i);
43 }
44 }
45
46 PanelScreen* PanelScreen::set_parent(PanelScreen* passed_parent){
47 this->parent = passed_parent;
48 this->set_panel( passed_parent->panel );
49 return this;
50 }
51
52 // Helper for screens to send a gcode
53 void PanelScreen::send_gcode(std::string g) {
54 Gcode gcode(g, &(StreamOutput::NullStream));
55 THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode );
56 }