Commit | Line | Data |
---|---|---|
446deda2 | 1 | /* |
35089dc7 JM |
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. | |
446deda2 | 5 | You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>. |
35089dc7 JM |
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" | |
61134a65 JM |
19 | #include "PublicData.h" |
20 | #include "checksumm.h" | |
35089dc7 JM |
21 | |
22 | #include <string> | |
23 | using namespace std; | |
24 | ||
862fc625 JM |
25 | MainMenuScreen::MainMenuScreen() |
26 | { | |
58d6d841 JM |
27 | // Children screens |
28 | this->jog_screen = (new JogScreen() )->set_parent(this); | |
29 | this->watch_screen = (new WatchScreen() )->set_parent(this); | |
30 | this->file_screen = (new FileScreen() )->set_parent(this); | |
31 | this->prepare_screen = (new PrepareScreen() )->set_parent(this); | |
32 | this->set_parent(this->watch_screen); | |
35089dc7 JM |
33 | } |
34 | ||
862fc625 JM |
35 | void MainMenuScreen::on_enter() |
36 | { | |
35089dc7 | 37 | this->panel->enter_menu_mode(); |
ca6effd7 | 38 | this->panel->setup_menu(5); |
862fc625 | 39 | this->refresh_menu(); |
35089dc7 JM |
40 | } |
41 | ||
862fc625 JM |
42 | void MainMenuScreen::on_refresh() |
43 | { | |
44 | if ( this->panel->menu_change() ) { | |
45 | this->refresh_menu(); | |
35089dc7 | 46 | } |
862fc625 | 47 | if ( this->panel->click() ) { |
446deda2 | 48 | this->clicked_menu_entry(this->panel->get_menu_current_line()); |
35089dc7 | 49 | } |
35089dc7 JM |
50 | } |
51 | ||
862fc625 JM |
52 | void MainMenuScreen::display_menu_line(uint16_t line) |
53 | { | |
54 | switch ( line ) { | |
446deda2 JM |
55 | case 0: this->panel->lcd->printf("Watch"); break; |
56 | case 1: this->panel->lcd->printf(panel->is_playing() ? "Abort" : "Play"); break; | |
57 | case 2: this->panel->lcd->printf("Jog"); break; | |
58 | case 3: this->panel->lcd->printf("Prepare"); break; | |
ca6effd7 | 59 | case 4: this->panel->lcd->printf("Custom"); break; |
862fc625 JM |
60 | //case 4: this->panel->lcd->printf("Configure"); break; |
61 | //case 5: this->panel->lcd->printf("Tune"); break; | |
35089dc7 | 62 | } |
35089dc7 JM |
63 | } |
64 | ||
862fc625 JM |
65 | void MainMenuScreen::clicked_menu_entry(uint16_t line) |
66 | { | |
67 | switch ( line ) { | |
35089dc7 | 68 | case 0: this->panel->enter_screen(this->watch_screen ); break; |
ca6effd7 | 69 | case 1: this->panel->is_playing() ? abort_playing() : this->panel->enter_screen(this->file_screen); break; |
35089dc7 JM |
70 | case 2: this->panel->enter_screen(this->jog_screen ); break; |
71 | case 3: this->panel->enter_screen(this->prepare_screen ); break; | |
ca6effd7 | 72 | case 4: this->panel->enter_screen(this->panel->custom_screen ); break; |
35089dc7 JM |
73 | } |
74 | } | |
75 | ||
862fc625 JM |
76 | void MainMenuScreen::abort_playing() |
77 | { | |
58d6d841 JM |
78 | THEKERNEL->public_data->set_value(player_checksum, abort_play_checksum, NULL); |
79 | this->panel->enter_screen(this->watch_screen); | |
35089dc7 JM |
80 | } |
81 |