get direct step running from encoder
[clinton/Smoothieware.git] / src / modules / utils / panel / screens / cnc / JogScreen.cpp
CommitLineData
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 "libs/SerialMessage.h"
10#include "Panel.h"
11#include "PanelScreen.h"
383c9c1c 12#include "LcdBase.h"
35089dc7
JM
13#include "MainMenuScreen.h"
14#include "JogScreen.h"
f9a0f86d 15#include "DirectJogScreen.h"
35089dc7
JM
16#include "ControlScreen.h"
17#include "libs/nuts_bolts.h"
18#include "libs/utils.h"
19#include <string>
20
21using namespace std;
22
23
862fc625
JM
24JogScreen::JogScreen()
25{
58d6d841
JM
26 this->control_screen = new ControlScreen();
27 this->control_screen->set_parent(this);
35089dc7
JM
28}
29
862fc625
JM
30void JogScreen::on_enter()
31{
cee1bb2d 32 THEPANEL->enter_menu_mode();
f9a0f86d 33 THEPANEL->setup_menu(6);
862fc625 34 this->refresh_menu();
35089dc7
JM
35}
36
862fc625
JM
37void JogScreen::on_refresh()
38{
cee1bb2d 39 if ( THEPANEL->menu_change() ) {
862fc625 40 this->refresh_menu();
58d6d841 41 }
cee1bb2d
JM
42 if ( THEPANEL->click() ) {
43 this->clicked_menu_entry(THEPANEL->get_menu_current_line());
58d6d841 44 }
35089dc7
JM
45}
46
862fc625
JM
47void JogScreen::display_menu_line(uint16_t line)
48{
49 switch ( line ) {
cee1bb2d
JM
50 case 0: THEPANEL->lcd->printf("Back"); break;
51 case 1: THEPANEL->lcd->printf("Move 10.0mm \x7E"); break;
f9a0f86d
JM
52 case 2: THEPANEL->lcd->printf("Move 1.0mm \x7E"); break;
53 case 3: THEPANEL->lcd->printf("Move 0.1mm \x7E"); break;
cb0b1658 54 case 4: THEPANEL->lcd->printf("Move 0.01mm \x7E"); break;
f9a0f86d 55 case 5: THEPANEL->lcd->printf("Direct Control \x7E"); break;
35089dc7
JM
56 }
57}
58
862fc625
JM
59void JogScreen::clicked_menu_entry(uint16_t line)
60{
f9a0f86d 61 bool direct= false;
862fc625 62 switch ( line ) {
cee1bb2d 63 case 0: THEPANEL->enter_screen(this->parent); return;
58d6d841
JM
64 case 1: this->control_screen->set_jog_increment(10.0); break;
65 case 2: this->control_screen->set_jog_increment(1.0); break;
66 case 3: this->control_screen->set_jog_increment(0.1); break;
cb0b1658 67 case 4: this->control_screen->set_jog_increment(0.01); break;
f9a0f86d
JM
68 case 5: direct= true; break;
69 }
70
71 if(direct) {
72 auto djs= new DirectJogScreen();
73 djs->set_parent(this);
74 THEPANEL->enter_screen(djs); // self deleting
75
76 }else{
77 THEPANEL->enter_screen(this->control_screen);
35089dc7 78 }
35089dc7 79}