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/>.
8 #include "libs/Kernel.h"
10 #include "PanelScreen.h"
11 #include "libs/nuts_bolts.h"
12 #include "libs/utils.h"
13 #include "libs/SerialMessage.h"
22 PanelScreen::PanelScreen() {}
24 void PanelScreen::on_refresh() {}
25 void PanelScreen::on_main_loop() {}
27 PanelScreen
*PanelScreen::set_panel(Panel
*parent
)
33 void PanelScreen::on_enter() {}
35 void PanelScreen::refresh_menu(bool clear
)
37 if (clear
) this->panel
->lcd
->clear();
38 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
++ ) {
39 this->panel
->lcd
->setCursor(2, i
- this->panel
->menu_start_line
);
40 this->display_menu_line(i
);
42 this->panel
->lcd
->setCursor(0, this->panel
->menu_current_line
- this->panel
->menu_start_line
);
43 this->panel
->lcd
->printf(">");
46 void PanelScreen::refresh_screen(bool clear
)
48 if (clear
) this->panel
->lcd
->clear();
49 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
++ ) {
50 this->panel
->lcd
->setCursor(0, i
- this->panel
->menu_start_line
);
51 this->display_menu_line(i
);
55 PanelScreen
*PanelScreen::set_parent(PanelScreen
*passed_parent
)
57 this->parent
= passed_parent
;
58 this->set_panel( passed_parent
->panel
);
62 // Helper for screens to send a gcode, must be called from main loop
63 void PanelScreen::send_gcode(std::string g
)
65 Gcode
gcode(g
, &(StreamOutput::NullStream
));
66 THEKERNEL
->call_event(ON_GCODE_RECEIVED
, &gcode
);
69 // Helper to send commands, must be called from mainloop
70 // may contain multipe commands separated by \n
71 void PanelScreen::send_command(const char *gcstr
)
75 while (cmd
.size() > 0) {
76 size_t b
= cmd
.find_first_of("\n");
77 if ( b
== string::npos
) {
81 q
.push_back(cmd
.substr( 0, b
));
82 cmd
= cmd
.substr(b
+ 1);
85 // for each command send it
86 for (std::vector
<string
>::iterator i
= q
.begin(); i
!= q
.end(); ++i
) {
87 struct SerialMessage message
;
89 message
.stream
= &(StreamOutput::NullStream
);
90 THEKERNEL
->call_event(ON_CONSOLE_LINE_RECEIVED
, &message
);