소스 검색

Add "more" menu in LVGL interface (#20940)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Malderin 3 년 전
부모
커밋
9025c63c43
No account linked to committer's email address
3개의 변경된 파일73개의 추가작업 그리고 32개의 파일을 삭제
  1. 2
    1
      Marlin/Configuration_adv.h
  2. 68
    30
      Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp
  3. 3
    1
      Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp

+ 2
- 1
Marlin/Configuration_adv.h 파일 보기

@@ -3342,7 +3342,8 @@
3342 3342
 #endif
3343 3343
 
3344 3344
 /**
3345
- * User-defined menu items that execute custom GCode
3345
+ * User-defined menu items to run custom G-code.
3346
+ * Up to 25 may be defined, but the actual number is LCD-dependent.
3346 3347
  */
3347 3348
 //#define CUSTOM_USER_MENUS
3348 3349
 #if ENABLED(CUSTOM_USER_MENUS)

+ 68
- 30
Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp 파일 보기

@@ -33,14 +33,28 @@
33 33
 extern lv_group_t * g;
34 34
 static lv_obj_t * scr;
35 35
 
36
+#define HAS_USER_ITEM(N) (ENABLED(CUSTOM_USER_MENUS) && defined(USER_DESC_##N) && defined(USER_GCODE_##N))
37
+
36 38
 enum {
37 39
   ID_GCODE = 1,
38
-  ID_CUSTOM_1,
39
-  ID_CUSTOM_2,
40
-  ID_CUSTOM_3,
41
-  ID_CUSTOM_4,
42
-  ID_CUSTOM_5,
43
-  ID_CUSTOM_6,
40
+  #if HAS_USER_ITEM(1)
41
+    ID_CUSTOM_1,
42
+  #endif
43
+  #if HAS_USER_ITEM(2)
44
+    ID_CUSTOM_2,
45
+  #endif
46
+  #if HAS_USER_ITEM(3)
47
+    ID_CUSTOM_3,
48
+  #endif
49
+  #if HAS_USER_ITEM(4)
50
+    ID_CUSTOM_4,
51
+  #endif
52
+  #if HAS_USER_ITEM(5)
53
+    ID_CUSTOM_5,
54
+  #endif
55
+  #if HAS_USER_ITEM(6)
56
+    ID_CUSTOM_6,
57
+  #endif
44 58
   ID_M_RETURN,
45 59
 };
46 60
 
@@ -48,12 +62,24 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
48 62
   if (event != LV_EVENT_RELEASED) return;
49 63
   switch (obj->mks_obj_id) {
50 64
     case ID_GCODE: lv_clear_more(); lv_draw_gcode(true); break;
51
-    case ID_CUSTOM_1: TERN_(USER_CMD_1_ENABLE, queue.inject_P(PSTR(USER_GCODE_1))); break;
52
-    case ID_CUSTOM_2: TERN_(USER_CMD_2_ENABLE, queue.inject_P(PSTR(USER_GCODE_2))); break;
53
-    case ID_CUSTOM_3: TERN_(USER_CMD_3_ENABLE, queue.inject_P(PSTR(USER_GCODE_3))); break;
54
-    case ID_CUSTOM_4: TERN_(USER_CMD_4_ENABLE, queue.inject_P(PSTR(USER_GCODE_4))); break;
55
-    case ID_CUSTOM_5: TERN_(USER_CMD_5_ENABLE, queue.inject_P(PSTR(USER_GCODE_5))); break;
56
-    case ID_CUSTOM_6: TERN_(USER_CMD_6_ENABLE, queue.inject_P(PSTR(USER_GCODE_6))); break;
65
+    #if HAS_USER_ITEM(1)
66
+      case ID_CUSTOM_1: queue.inject_P(PSTR(USER_GCODE_1)); break;
67
+    #endif
68
+    #if HAS_USER_ITEM(2)
69
+      case ID_CUSTOM_2: queue.inject_P(PSTR(USER_GCODE_2)); break;
70
+    #endif
71
+    #if HAS_USER_ITEM(3)
72
+      case ID_CUSTOM_3: queue.inject_P(PSTR(USER_GCODE_3)); break;
73
+    #endif
74
+    #if HAS_USER_ITEM(4)
75
+      case ID_CUSTOM_4: queue.inject_P(PSTR(USER_GCODE_4)); break;
76
+    #endif
77
+    #if HAS_USER_ITEM(5)
78
+      case ID_CUSTOM_5: queue.inject_P(PSTR(USER_GCODE_5)); break;
79
+    #endif
80
+    #if HAS_USER_ITEM(6)
81
+      case ID_CUSTOM_6: queue.inject_P(PSTR(USER_GCODE_6)); break;
82
+    #endif
57 83
     case ID_M_RETURN:
58 84
       lv_clear_more();
59 85
       lv_draw_tool();
@@ -70,37 +96,37 @@ void lv_draw_more() {
70 96
   if (enc_ena) lv_group_add_obj(g, buttonGCode);
71 97
   lv_obj_t *labelGCode = lv_label_create_empty(buttonGCode);
72 98
 
73
-  #if ENABLED(USER_CMD_1_ENABLE)
99
+  #if HAS_USER_ITEM(1)
74 100
     lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_1);
75 101
     if (enc_ena) lv_group_add_obj(g, buttonCustom1);
76 102
     lv_obj_t *labelCustom1 = lv_label_create_empty(buttonCustom1);
77 103
   #endif
78 104
 
79
-  #if ENABLED(USER_CMD_2_ENABLE)
105
+  #if HAS_USER_ITEM(2)
80 106
     lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_2);
81 107
     if (enc_ena) lv_group_add_obj(g, buttonCustom2);
82 108
     lv_obj_t *labelCustom2 = lv_label_create_empty(buttonCustom2);
83 109
   #endif
84 110
 
85
-  #if ENABLED(USER_CMD_3_ENABLE)
111
+  #if HAS_USER_ITEM(3)
86 112
     lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_3);
87 113
     if (enc_ena) lv_group_add_obj(g, buttonCustom3);
88 114
     lv_obj_t *labelCustom3 = lv_label_create_empty(buttonCustom3);
89 115
   #endif
90 116
 
91
-  #if ENABLED(USER_CMD_4_ENABLE)
117
+  #if HAS_USER_ITEM(4)
92 118
     lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_4);
93 119
     if (enc_ena) lv_group_add_obj(g, buttonCustom4);
94 120
     lv_obj_t *labelCustom4 = lv_label_create_empty(buttonCustom4);
95 121
   #endif
96 122
 
97
-  #if ENABLED(USER_CMD_5_ENABLE)
123
+  #if HAS_USER_ITEM(5)
98 124
     lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5);
99 125
     if (enc_ena) lv_group_add_obj(g, buttonCustom5);
100 126
     lv_obj_t *labelCustom5 = lv_label_create_empty(buttonCustom5);
101 127
   #endif
102 128
 
103
-  #if ENABLED(USER_CMD_6_ENABLE)
129
+  #if HAS_USER_ITEM(6)
104 130
     lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6);
105 131
     if (enc_ena) lv_group_add_obj(g, buttonCustom6);
106 132
     lv_obj_t *labelCustom6 = lv_label_create_empty(buttonCustom6);
@@ -114,27 +140,27 @@ void lv_draw_more() {
114 140
     lv_label_set_text(labelGCode, more_menu.gcode);
115 141
     lv_obj_align(labelGCode, buttonGCode, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
116 142
 
117
-    #if ENABLED(USER_CMD_1_ENABLE)
143
+    #if HAS_USER_ITEM(1)
118 144
       lv_label_set_text(labelCustom1, more_menu.custom1);
119 145
       lv_obj_align(labelCustom1, buttonCustom1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
120 146
     #endif
121
-    #if ENABLED(USER_CMD_2_ENABLE)
147
+    #if HAS_USER_ITEM(2)
122 148
       lv_label_set_text(labelCustom2, more_menu.custom2);
123 149
       lv_obj_align(labelCustom2, buttonCustom2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
124 150
     #endif
125
-    #if ENABLED(USER_CMD_3_ENABLE)
151
+    #if HAS_USER_ITEM(3)
126 152
       lv_label_set_text(labelCustom3, more_menu.custom3);
127 153
       lv_obj_align(labelCustom3, buttonCustom3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
128 154
     #endif
129
-    #if ENABLED(USER_CMD_4_ENABLE)
155
+    #if HAS_USER_ITEM(4)
130 156
       lv_label_set_text(labelCustom4, more_menu.custom4);
131 157
       lv_obj_align(labelCustom4, buttonCustom4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
132 158
     #endif
133
-    #if ENABLED(USER_CMD_5_ENABLE)
159
+    #if HAS_USER_ITEM(5)
134 160
       lv_label_set_text(labelCustom5, more_menu.custom5);
135 161
       lv_obj_align(labelCustom5, buttonCustom5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
136 162
     #endif
137
-    #if ENABLED(USER_CMD_6_ENABLE)
163
+    #if HAS_USER_ITEM(6)
138 164
       lv_label_set_text(labelCustom6, more_menu.custom6);
139 165
       lv_obj_align(labelCustom6, buttonCustom6, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
140 166
     #endif
@@ -145,12 +171,24 @@ void lv_draw_more() {
145 171
   #if BUTTONS_EXIST(EN1, EN2, ENC)
146 172
     if (enc_ena) {
147 173
       lv_group_add_obj(g, buttonGCode);
148
-      TERN_(USER_CMD_1_ENABLE, lv_group_add_obj(g, buttonCustom1));
149
-      TERN_(USER_CMD_2_ENABLE, lv_group_add_obj(g, buttonCustom2));
150
-      TERN_(USER_CMD_3_ENABLE, lv_group_add_obj(g, buttonCustom3));
151
-      TERN_(USER_CMD_4_ENABLE, lv_group_add_obj(g, buttonCustom4));
152
-      TERN_(USER_CMD_5_ENABLE, lv_group_add_obj(g, buttonCustom5));
153
-      TERN_(USER_CMD_6_ENABLE, lv_group_add_obj(g, buttonCustom6));
174
+      #if HAS_USER_ITEM(1)
175
+        lv_group_add_obj(g, buttonCustom1);
176
+      #endif
177
+      #if HAS_USER_ITEM(2)
178
+        lv_group_add_obj(g, buttonCustom2);
179
+      #endif
180
+      #if HAS_USER_ITEM(3)
181
+        lv_group_add_obj(g, buttonCustom3);
182
+      #endif
183
+      #if HAS_USER_ITEM(4)
184
+        lv_group_add_obj(g, buttonCustom4);
185
+      #endif
186
+      #if HAS_USER_ITEM(5)
187
+        lv_group_add_obj(g, buttonCustom5);
188
+      #endif
189
+      #if HAS_USER_ITEM(6)
190
+        lv_group_add_obj(g, buttonCustom6);
191
+      #endif
154 192
       lv_group_add_obj(g, buttonBack);
155 193
     }
156 194
   #endif

+ 3
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp 파일 보기

@@ -71,7 +71,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
71 71
       uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target;
72 72
       lv_draw_filament_change();
73 73
       break;
74
-    case ID_T_MORE: lv_draw_more(); break;
74
+    case ID_T_MORE:
75
+      lv_draw_more();
76
+      break;
75 77
     case ID_T_RETURN:
76 78
       TERN_(MKS_TEST, curent_disp_ui = 1);
77 79
       lv_draw_ready_print();

Loading…
취소
저장