Added new Panel stuff
[clinton/Smoothieware.git] / src / modules / utils / panel / screens / MainMenuScreen.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 "MainMenuScreen.h"
12 #include "WatchScreen.h"
13 #include "FileScreen.h"
14 #include "ControlScreen.h"
15 #include "PrepareScreen.h"
16 #include "libs/nuts_bolts.h"
17 #include "libs/utils.h"
18 #include "modules/utils/player/PlayerPublicAccess.h"
19
20
21 #include <string>
22 using namespace std;
23
24 MainMenuScreen::MainMenuScreen(){
25 // Children screens
26 this->jog_screen = (new JogScreen() )->set_parent(this);
27 this->watch_screen = (new WatchScreen() )->set_parent(this);
28 this->file_screen = (new FileScreen() )->set_parent(this);
29 this->prepare_screen = (new PrepareScreen() )->set_parent(this);
30 this->set_parent(this->watch_screen);
31 }
32
33 void MainMenuScreen::on_enter(){
34 this->panel->enter_menu_mode();
35 this->panel->setup_menu(6, 4); // 6 menu items, 4 lines
36 this->refresh_screen();
37 }
38
39 void MainMenuScreen::on_refresh(){
40 if( this->panel->menu_change() ){
41 this->refresh_screen();
42 }
43 if( this->panel->click() ){
44 this->clicked_menu_entry(this->panel->menu_current_line());
45 }
46
47
48 }
49
50 void MainMenuScreen::refresh_screen(){
51 this->refresh_menu();
52 }
53
54 void MainMenuScreen::display_menu_line(uint16_t line){
55 switch( line ){
56 case 0: this->panel->lcd->printf("Watch"); break;
57 case 1: this->panel->lcd->printf(panel->is_playing() ? "Abort" : "Play"); break;
58 case 2: this->panel->lcd->printf("Jog"); break;
59 case 3: this->panel->lcd->printf("Prepare"); break;
60 case 4: this->panel->lcd->printf("Configure"); break;
61 case 5: this->panel->lcd->printf("Tune"); break;
62 }
63
64 }
65
66 void MainMenuScreen::clicked_menu_entry(uint16_t line){
67 switch( line ){
68 case 0: this->panel->enter_screen(this->watch_screen ); break;
69 case 1: if(this->panel->is_playing())
70 abort_playing();
71 else
72 this->panel->enter_screen(this->file_screen);
73 break;
74 case 2: this->panel->enter_screen(this->jog_screen ); break;
75 case 3: this->panel->enter_screen(this->prepare_screen ); break;
76 }
77 }
78
79
80 void MainMenuScreen::abort_playing() {
81 THEKERNEL->public_data->set_value(player_checksum, abort_play_checksum, NULL);
82 this->panel->enter_screen(this->watch_screen);
83 }
84