|
@@ -0,0 +1,121 @@
|
|
1
|
+/*********************
|
|
2
|
+ * leveling_menu.cpp *
|
|
3
|
+ *********************/
|
|
4
|
+
|
|
5
|
+/****************************************************************************
|
|
6
|
+ * Written By Mark Pelletier 2017 - Aleph Objects, Inc. *
|
|
7
|
+ * Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
|
|
8
|
+ * *
|
|
9
|
+ * This program is free software: you can redistribute it and/or modify *
|
|
10
|
+ * it under the terms of the GNU General Public License as published by *
|
|
11
|
+ * the Free Software Foundation, either version 3 of the License, or *
|
|
12
|
+ * (at your option) any later version. *
|
|
13
|
+ * *
|
|
14
|
+ * This program is distributed in the hope that it will be useful, *
|
|
15
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
16
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
17
|
+ * GNU General Public License for more details. *
|
|
18
|
+ * *
|
|
19
|
+ * To view a copy of the GNU General Public License, go to the following *
|
|
20
|
+ * location: <https://www.gnu.org/licenses/>. *
|
|
21
|
+ ****************************************************************************/
|
|
22
|
+
|
|
23
|
+#include "../config.h"
|
|
24
|
+
|
|
25
|
+#if BOTH(TOUCH_UI_FTDI_EVE,HAS_LEVELING)
|
|
26
|
+
|
|
27
|
+#include "screens.h"
|
|
28
|
+
|
|
29
|
+#if BOTH(HAS_BED_PROBE,BLTOUCH)
|
|
30
|
+ #include "../../../../../feature/bltouch.h"
|
|
31
|
+#endif
|
|
32
|
+
|
|
33
|
+using namespace FTDI;
|
|
34
|
+using namespace ExtUI;
|
|
35
|
+using namespace Theme;
|
|
36
|
+
|
|
37
|
+#ifdef TOUCH_UI_PORTRAIT
|
|
38
|
+ #define GRID_ROWS 9
|
|
39
|
+ #define GRID_COLS 2
|
|
40
|
+ #define TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1)
|
|
41
|
+ #define LEVEL_BED_POS BTN_POS(1,2), BTN_SIZE(2,1)
|
|
42
|
+ #define LEVEL_AXIS_POS BTN_POS(1,3), BTN_SIZE(2,1)
|
|
43
|
+ #define SHOW_MESH_POS BTN_POS(1,4), BTN_SIZE(2,1)
|
|
44
|
+ #define BLTOUCH_TITLE_POS BTN_POS(1,6), BTN_SIZE(2,1)
|
|
45
|
+ #define BLTOUCH_RESET_POS BTN_POS(1,7), BTN_SIZE(1,1)
|
|
46
|
+ #define BLTOUCH_TEST_POS BTN_POS(2,7), BTN_SIZE(1,1)
|
|
47
|
+ #define BACK_POS BTN_POS(1,9), BTN_SIZE(2,1)
|
|
48
|
+#else
|
|
49
|
+ #define GRID_ROWS 7
|
|
50
|
+ #define GRID_COLS 2
|
|
51
|
+ #define TITLE_POS BTN_POS(1,1), BTN_SIZE(2,1)
|
|
52
|
+ #define LEVEL_BED_POS BTN_POS(1,2), BTN_SIZE(2,1)
|
|
53
|
+ #define LEVEL_AXIS_POS BTN_POS(1,3), BTN_SIZE(2,1)
|
|
54
|
+ #define SHOW_MESH_POS BTN_POS(1,4), BTN_SIZE(2,1)
|
|
55
|
+ #define BLTOUCH_TITLE_POS BTN_POS(1,5), BTN_SIZE(2,1)
|
|
56
|
+ #define BLTOUCH_RESET_POS BTN_POS(1,6), BTN_SIZE(1,1)
|
|
57
|
+ #define BLTOUCH_TEST_POS BTN_POS(2,6), BTN_SIZE(1,1)
|
|
58
|
+ #define BACK_POS BTN_POS(1,7), BTN_SIZE(2,1)
|
|
59
|
+#endif
|
|
60
|
+
|
|
61
|
+void LevelingMenu::onRedraw(draw_mode_t what) {
|
|
62
|
+ if (what & BACKGROUND) {
|
|
63
|
+ CommandProcessor cmd;
|
|
64
|
+ cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
|
|
65
|
+ .cmd(CLEAR(true,true,true))
|
|
66
|
+ .tag(0);
|
|
67
|
+ }
|
|
68
|
+
|
|
69
|
+ if (what & FOREGROUND) {
|
|
70
|
+ CommandProcessor cmd;
|
|
71
|
+ cmd.font(font_large)
|
|
72
|
+ .text(TITLE_POS, GET_TEXT_F(MSG_LEVELING))
|
|
73
|
+ .font(font_medium).colors(normal_btn)
|
|
74
|
+ .tag(2).button(LEVEL_BED_POS, GET_TEXT_F(MSG_LEVEL_BED))
|
|
75
|
+ .enabled(
|
|
76
|
+ #ifdef AXIS_LEVELING_COMMANDS
|
|
77
|
+ 1
|
|
78
|
+ #endif
|
|
79
|
+ )
|
|
80
|
+ .tag(3).button(LEVEL_AXIS_POS, GET_TEXT_F(MSG_AUTOLEVEL_X_AXIS))
|
|
81
|
+ .enabled(ENABLED(HAS_MESH))
|
|
82
|
+ .tag(4).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH));
|
|
83
|
+ #if ENABLED(BLTOUCH)
|
|
84
|
+ cmd.text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH))
|
|
85
|
+ .tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET))
|
|
86
|
+ .tag(6).button(BLTOUCH_TEST_POS, GET_TEXT_F(MSG_BLTOUCH_SELFTEST));
|
|
87
|
+ #endif
|
|
88
|
+ cmd.colors(action_btn)
|
|
89
|
+ .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
|
|
90
|
+ }
|
|
91
|
+}
|
|
92
|
+
|
|
93
|
+bool LevelingMenu::onTouchEnd(uint8_t tag) {
|
|
94
|
+ switch (tag) {
|
|
95
|
+ case 1: GOTO_PREVIOUS(); break;
|
|
96
|
+ case 2:
|
|
97
|
+ #ifndef BED_LEVELING_COMMANDS
|
|
98
|
+ #define BED_LEVELING_COMMANDS "G29"
|
|
99
|
+ #endif
|
|
100
|
+ #if HAS_MESH
|
|
101
|
+ BedMeshScreen::startMeshProbe();
|
|
102
|
+ #else
|
|
103
|
+ SpinnerDialogBox::enqueueAndWait_P(F(BED_LEVELING_COMMANDS));
|
|
104
|
+ #endif
|
|
105
|
+ break;
|
|
106
|
+ #ifdef AXIS_LEVELING_COMMANDS
|
|
107
|
+ case 3: SpinnerDialogBox::enqueueAndWait_P(F(AXIS_LEVELING_COMMANDS)); break;
|
|
108
|
+ #endif
|
|
109
|
+ #if HAS_MESH
|
|
110
|
+ case 4: GOTO_SCREEN(BedMeshScreen); break;
|
|
111
|
+ #endif
|
|
112
|
+ #if ENABLED(BLTOUCH)
|
|
113
|
+ case 5: injectCommands_P(PSTR("M280 P0 S60")); break;
|
|
114
|
+ case 6: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
|
|
115
|
+ #endif
|
|
116
|
+ default: return false;
|
|
117
|
+ }
|
|
118
|
+ return true;
|
|
119
|
+}
|
|
120
|
+
|
|
121
|
+#endif // BOTH(TOUCH_UI_FTDI_EVE,HAS_LEVELING)
|