소스 검색

🎨 Fix and enhance FTDI Eve Touch UI (#22189)

Marcio T 4 년 전
부모
커밋
0f5126acb2
No account linked to committer's email address

+ 91
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.cpp 파일 보기

@@ -0,0 +1,91 @@
1
+/*********************************
2
+ * cocoa_press/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
+#include "../screens.h"
25
+
26
+#ifdef COCOA_LEVELING_MENU
27
+
28
+#if BOTH(HAS_BED_PROBE,BLTOUCH)
29
+  #include "../../../../feature/bltouch.h"
30
+#endif
31
+
32
+using namespace FTDI;
33
+using namespace ExtUI;
34
+using namespace Theme;
35
+
36
+#define GRID_ROWS 5
37
+#define GRID_COLS 3
38
+#define BED_MESH_TITLE_POS BTN_POS(1,1), BTN_SIZE(3,1)
39
+#define PROBE_BED_POS      BTN_POS(1,2), BTN_SIZE(1,1)
40
+#define SHOW_MESH_POS      BTN_POS(2,2), BTN_SIZE(1,1)
41
+#define EDIT_MESH_POS      BTN_POS(3,2), BTN_SIZE(1,1)
42
+#define BLTOUCH_TITLE_POS  BTN_POS(1,3), BTN_SIZE(3,1)
43
+#define BLTOUCH_RESET_POS  BTN_POS(1,4), BTN_SIZE(1,1)
44
+#define BLTOUCH_TEST_POS   BTN_POS(2,4), BTN_SIZE(1,1)
45
+#define BACK_POS           BTN_POS(1,5), BTN_SIZE(3,1)
46
+
47
+void LevelingMenu::onRedraw(draw_mode_t what) {
48
+  if (what & BACKGROUND) {
49
+    CommandProcessor cmd;
50
+    cmd.cmd(CLEAR_COLOR_RGB(Theme::bg_color))
51
+       .cmd(CLEAR(true,true,true))
52
+       .tag(0);
53
+  }
54
+
55
+  if (what & FOREGROUND) {
56
+    CommandProcessor cmd;
57
+    cmd.font(font_large)
58
+       .cmd(COLOR_RGB(bg_text_enabled))
59
+       .text(BED_MESH_TITLE_POS, GET_TEXT_F(MSG_BED_LEVELING))
60
+       .text(BLTOUCH_TITLE_POS, GET_TEXT_F(MSG_BLTOUCH))
61
+       .font(font_medium).colors(normal_btn)
62
+       .tag(2).button(PROBE_BED_POS, GET_TEXT_F(MSG_PROBE_BED))
63
+       .enabled(ENABLED(HAS_MESH))
64
+       .tag(3).button(SHOW_MESH_POS, GET_TEXT_F(MSG_SHOW_MESH))
65
+       .enabled(ENABLED(HAS_MESH))
66
+       .tag(4).button(EDIT_MESH_POS, GET_TEXT_F(MSG_EDIT_MESH))
67
+       #undef  GRID_COLS
68
+       #define GRID_COLS 2
69
+       .tag(5).button(BLTOUCH_RESET_POS, GET_TEXT_F(MSG_BLTOUCH_RESET))
70
+       .tag(6).button(BLTOUCH_TEST_POS,  GET_TEXT_F(MSG_BLTOUCH_SELFTEST))
71
+       #undef  GRID_COLS
72
+       #define GRID_COLS 3
73
+       .colors(action_btn)
74
+       .tag(1).button(BACK_POS, GET_TEXT_F(MSG_BACK));
75
+  }
76
+}
77
+
78
+bool LevelingMenu::onTouchEnd(uint8_t tag) {
79
+  switch (tag) {
80
+    case 1: GOTO_PREVIOUS(); break;
81
+    case 2: BedMeshViewScreen::doProbe(); break;
82
+    case 3: BedMeshViewScreen::show(); break;
83
+    case 4: BedMeshEditScreen::show(); break;
84
+    case 5: injectCommands_P(PSTR("M280 P0 S60")); break;
85
+    case 6: SpinnerDialogBox::enqueueAndWait_P(F("M280 P0 S90\nG4 P100\nM280 P0 S120")); break;
86
+    default: return false;
87
+  }
88
+  return true;
89
+}
90
+
91
+#endif // COCOA_LEVELING_MENU

+ 32
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/leveling_menu.h 파일 보기

@@ -0,0 +1,32 @@
1
+/*******************************
2
+ * cocoa_press/leveling_menu.h *
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
+#pragma once
24
+
25
+#define COCOA_LEVELING_MENU
26
+#define COCOA_LEVELING_MENU_CLASS LevelingMenu
27
+
28
+class LevelingMenu : public BaseScreen, public CachedScreen<LEVELING_SCREEN_CACHE> {
29
+  public:
30
+    static void onRedraw(draw_mode_t);
31
+    static bool onTouchEnd(uint8_t tag);
32
+};

+ 1
- 1
Marlin/src/lcd/extui/ftdi_eve_touch_ui/cocoa_press/main_menu.cpp 파일 보기

@@ -88,7 +88,7 @@ bool MainMenu::onTouchEnd(uint8_t tag) {
88 88
     case  8: GOTO_SCREEN(AdvancedSettingsMenu);             break;
89 89
     case  9: injectCommands_P(PSTR("M84"));                 break;
90 90
     #if HAS_LEVELING
91
-    case 10:  GOTO_SCREEN(LevelingMenu);                     break;
91
+    case 10:  GOTO_SCREEN(LevelingMenu);                    break;
92 92
     #endif
93 93
     case 11: GOTO_SCREEN(AboutScreen);                      break;
94 94
     default:

+ 0
- 1
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/leveling_menu.cpp 파일 보기

@@ -132,4 +132,3 @@ bool LevelingMenu::onTouchEnd(uint8_t tag) {
132 132
 }
133 133
 
134 134
 #endif // FTDI_LEVELING_MENU
135
-

+ 29
- 4
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/string_format.cpp 파일 보기

@@ -34,28 +34,53 @@
34 34
  * Formats a temperature string (e.g. "100°C")
35 35
  */
36 36
 void format_temp(char *str, const_celsius_float_t t1) {
37
-  sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
37
+  #ifdef TOUCH_UI_LCD_TEMP_PRECISION
38
+    char num1[7];
39
+    dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
40
+    sprintf_P(str, PSTR("%s" S_FMT), num1, GET_TEXT(MSG_UNITS_C));
41
+  #else
42
+    sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
43
+  #endif
38 44
 }
39 45
 
40 46
 /**
41 47
  * Formats a temperature string for an idle heater (e.g. "100 °C / idle")
42 48
  */
43 49
 void format_temp_and_idle(char *str, const_celsius_float_t t1) {
44
-  sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
50
+  #ifdef TOUCH_UI_LCD_TEMP_PRECISION
51
+    char num1[7];
52
+    dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
53
+    sprintf_P(str, PSTR("%s" S_FMT " / " S_FMT), num1, GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
54
+  #else
55
+    sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
56
+  #endif
45 57
 }
46 58
 
47 59
 /**
48 60
  * Formats a temperature string for an active heater (e.g. "100 / 200°C")
49 61
  */
50 62
 void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2) {
51
-  sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
63
+  #ifdef TOUCH_UI_LCD_TEMP_PRECISION
64
+    char num1[7], num2[7];
65
+    dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
66
+    dtostrf(t2, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num2);
67
+    sprintf_P(str, PSTR("%s / %s" S_FMT), num1, num2, GET_TEXT(MSG_UNITS_C));
68
+  #else
69
+    sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
70
+  #endif
52 71
 }
53 72
 
54 73
 /**
55 74
  * Formats a temperature string for a material (e.g. "100°C (PLA)")
56 75
  */
57 76
 void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material) {
58
-  sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
77
+  #ifdef TOUCH_UI_LCD_TEMP_PRECISION
78
+    char num1[7];
79
+    dtostrf(t1, 4 + TOUCH_UI_LCD_TEMP_PRECISION, TOUCH_UI_LCD_TEMP_PRECISION, num1);
80
+    sprintf_P(str, PSTR("%s" S_FMT " (" S_FMT ")"), num1, GET_TEXT(MSG_UNITS_C), material);
81
+  #else
82
+    sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
83
+  #endif
59 84
 }
60 85
 
61 86
 /**

+ 18
- 8
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.cpp 파일 보기

@@ -36,7 +36,14 @@ constexpr static ZOffsetScreenData &mydata = screen_data.ZOffsetScreen;
36 36
 
37 37
 void ZOffsetScreen::onEntry() {
38 38
   mydata.z = SHEET_THICKNESS;
39
+  mydata.softEndstopState = getSoftEndstopState();
39 40
   BaseNumericAdjustmentScreen::onEntry();
41
+  if (wizardRunning())
42
+    setSoftEndstopState(false);
43
+}
44
+
45
+void ZOffsetScreen::onExit() {
46
+  setSoftEndstopState(mydata.softEndstopState);
40 47
 }
41 48
 
42 49
 void ZOffsetScreen::onRedraw(draw_mode_t what) {
@@ -50,17 +57,13 @@ void ZOffsetScreen::onRedraw(draw_mode_t what) {
50 57
 }
51 58
 
52 59
 void ZOffsetScreen::move(float mm, int16_t steps) {
53
-  // We can't store state after the call to the AlertBox, so
54
-  // check whether the current position equal mydata.z in order
55
-  // to know whether the user started the wizard.
56
-  if (getAxisPosition_mm(Z) == mydata.z) {
57
-    // In the wizard
60
+  if (wizardRunning()) {
58 61
     mydata.z += mm;
59 62
     setAxisPosition_mm(mydata.z, Z);
60 63
   }
61 64
   else {
62 65
     // Otherwise doing a manual adjustment, possibly during a print.
63
-    babystepAxis_steps(steps, Z);
66
+    TERN(BABYSTEPPING, babystepAxis_steps(steps, Z), UNUSED(steps));
64 67
   }
65 68
 }
66 69
 
@@ -84,9 +87,16 @@ void ZOffsetScreen::runWizard() {
84 87
   AlertDialogBox::show(PSTR("After the printer finishes homing, adjust the Z Offset so that a sheet of paper can pass between the nozzle and bed with slight resistance."));
85 88
 }
86 89
 
90
+bool ZOffsetScreen::wizardRunning() {
91
+  // We can't store state after the call to the AlertBox, so
92
+  // check whether the current Z position equals mydata.z in order
93
+  // to know whether the user started the wizard.
94
+  return getAxisPosition_mm(Z) == mydata.z;
95
+}
96
+
87 97
 bool ZOffsetScreen::onTouchHeld(uint8_t tag) {
88
-  const int16_t steps = mmToWholeSteps(getIncrement(), Z);
89
-  const float increment = mmFromWholeSteps(steps, Z);
98
+  const int16_t steps =   TERN(BABYSTEPPING, mmToWholeSteps(getIncrement(), Z), 0);
99
+  const float increment = TERN(BABYSTEPPING, mmFromWholeSteps(steps, Z), getIncrement());
90 100
   switch (tag) {
91 101
     case 2: runWizard(); break;
92 102
     case 4: UI_DECREMENT(ZOffset_mm); move(-increment, -steps); break;

+ 3
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/z_offset_screen.h 파일 보기

@@ -27,14 +27,17 @@
27 27
 
28 28
 struct ZOffsetScreenData : public BaseNumericAdjustmentScreenData {
29 29
   float z;
30
+  bool softEndstopState;
30 31
 };
31 32
 
32 33
 class ZOffsetScreen : public BaseNumericAdjustmentScreen, public CachedScreen<ZOFFSET_SCREEN_CACHE> {
33 34
   private:
34 35
     static void move(float mm, int16_t steps);
35 36
     static void runWizard();
37
+    static bool wizardRunning();
36 38
   public:
37 39
     static void onEntry();
40
+    static void onExit();
38 41
     static void onRedraw(draw_mode_t);
39 42
     static bool onTouchHeld(uint8_t tag);
40 43
 };

+ 1
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.cpp 파일 보기

@@ -113,6 +113,7 @@ SCREEN_TABLE {
113 113
   DECL_SCREEN_IF_INCLUDED(COCOA_PREHEAT_MENU)
114 114
   DECL_SCREEN_IF_INCLUDED(COCOA_PREHEAT_SCREEN)
115 115
   DECL_SCREEN_IF_INCLUDED(COCOA_LOAD_CHOCOLATE_SCREEN)
116
+  DECL_SCREEN_IF_INCLUDED(COCOA_LEVELING_MENU)
116 117
   DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_XYZ_SCREEN)
117 118
   DECL_SCREEN_IF_INCLUDED(COCOA_MOVE_E_SCREEN)
118 119
 };

+ 4
- 1
Marlin/src/lcd/extui/ftdi_eve_touch_ui/screens.h 파일 보기

@@ -157,6 +157,7 @@ enum {
157 157
   #include "cocoa_press/load_chocolate.h"
158 158
   #include "cocoa_press/move_xyz_screen.h"
159 159
   #include "cocoa_press/move_e_screen.h"
160
+  #include "cocoa_press/leveling_menu.h"
160 161
 
161 162
 #else
162 163
   #include "generic/status_screen.h"
@@ -206,7 +207,9 @@ enum {
206 207
 #endif
207 208
 
208 209
 #if HAS_LEVELING
209
-  #include "generic/leveling_menu.h"
210
+  #if DISABLED(TOUCH_UI_COCOA_PRESS)
211
+    #include "generic/leveling_menu.h"
212
+  #endif
210 213
   #if HAS_BED_PROBE
211 214
     #include "generic/z_offset_screen.h"
212 215
   #endif

+ 1
- 0
Marlin/src/lcd/extui/ftdi_eve_touch_ui/theme/colors.h 파일 보기

@@ -108,6 +108,7 @@ namespace Theme {
108 108
 
109 109
     constexpr uint32_t bed_mesh_lines_rgb   = accent_color_6;
110 110
     constexpr uint32_t bed_mesh_shadow_rgb  = 0x444444;
111
+    #define BED_MESH_POINTS_GRAY
111 112
   #else
112 113
     constexpr uint32_t theme_darkest        = gray_color_1;
113 114
     constexpr uint32_t theme_dark           = gray_color_2;

+ 2
- 2
Marlin/src/lcd/extui/ui_api.cpp 파일 보기

@@ -1033,10 +1033,10 @@ namespace ExtUI {
1033 1033
   }
1034 1034
 
1035 1035
   bool isPrintingFromMediaPaused() {
1036
-    return TERN0(SDSUPPORT, isPrintingFromMedia() && printingIsPaused());
1036
+    return TERN0(SDSUPPORT, IS_SD_PAUSED());
1037 1037
   }
1038 1038
 
1039
-  bool isPrintingFromMedia() { return IS_SD_PRINTING(); }
1039
+  bool isPrintingFromMedia() { return TERN0(SDSUPPORT, IS_SD_PRINTING() || IS_SD_PAUSED()); }
1040 1040
 
1041 1041
   bool isPrinting() {
1042 1042
     return commandsInQueue() || isPrintingFromMedia() || printJobOngoing() || printingIsPaused();

Loading…
취소
저장