Selaa lähdekoodia

Fix MKS LVGL UI Main screen / print buttons (#21468)

Malderin 3 vuotta sitten
vanhempi
commit
a335cf2edf
No account linked to committer's email address

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp Näytä tiedosto

@@ -486,7 +486,7 @@ void lv_draw_dialog(uint8_t type) {
486 486
 
487 487
 void filament_sprayer_temp() {
488 488
   char buf[20] = {0};
489
-  sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
489
+  sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
490 490
 
491 491
   strcpy(public_buf_l, uiCfg.extruderIndex < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
492 492
   strcat_P(public_buf_l, PSTR(": "));

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp Näytä tiedosto

@@ -195,7 +195,7 @@ void disp_ext_speed() {
195 195
 
196 196
 void disp_hotend_temp() {
197 197
   char buf[20] = {0};
198
-  sprintf(buf, extrude_menu.temp_value, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
198
+  sprintf(buf, extrude_menu.temp_value, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
199 199
   strcpy(public_buf_l, extrude_menu.temper_text);
200 200
   strcat(public_buf_l, buf);
201 201
   lv_label_set_text(tempText, public_buf_l);

+ 5
- 5
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp Näytä tiedosto

@@ -50,8 +50,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
50 50
   switch (obj->mks_obj_id) {
51 51
     case ID_FILAMNT_IN:
52 52
       uiCfg.filament_load_heat_flg = true;
53
-      if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1)
54
-          || (gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex))) {
53
+      if (abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1
54
+          || gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex)) {
55 55
         lv_clear_filament_change();
56 56
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
57 57
       }
@@ -67,8 +67,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
67 67
     case ID_FILAMNT_OUT:
68 68
       uiCfg.filament_unload_heat_flg = true;
69 69
       if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
70
-          && ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1)
71
-              || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp))
70
+          && (abs((int)(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1
71
+              || thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp)
72 72
       ) {
73 73
         lv_clear_filament_change();
74 74
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
@@ -154,7 +154,7 @@ void disp_filament_temp() {
154 154
   public_buf_l[0] = '\0';
155 155
 
156 156
   strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
157
-  sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
157
+  sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
158 158
 
159 159
   strcat_P(public_buf_l, PSTR(": "));
160 160
   strcat(public_buf_l, buf);

+ 4
- 4
Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp Näytä tiedosto

@@ -76,7 +76,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
76 76
 
77 77
     case ID_P_DEC:
78 78
       if (uiCfg.curTempType == 0) {
79
-        if ((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat)
79
+        if (thermalManager.degTargetHotend(uiCfg.extruderIndex) > uiCfg.stepHeat)
80 80
           thermalManager.temp_hotend[uiCfg.extruderIndex].target -= uiCfg.stepHeat;
81 81
         else
82 82
           thermalManager.setTargetHotend(0, uiCfg.extruderIndex);
@@ -84,7 +84,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
84 84
       }
85 85
       #if HAS_HEATED_BED
86 86
         else {
87
-          if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat)
87
+          if (thermalManager.degTargetBed() > uiCfg.stepHeat)
88 88
             thermalManager.temp_bed.target -= uiCfg.stepHeat;
89 89
           else
90 90
             thermalManager.setTargetBed(0);
@@ -217,12 +217,12 @@ void disp_desire_temp() {
217 217
 
218 218
   if (uiCfg.curTempType == 0) {
219 219
     strcat(public_buf_l, uiCfg.extruderIndex < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
220
-    sprintf(buf, preheat_menu.value_state, (int)thermalManager.degHotend(uiCfg.extruderIndex), (int)thermalManager.degTargetHotend(uiCfg.extruderIndex));
220
+    sprintf(buf, preheat_menu.value_state, thermalManager.degHotend(uiCfg.extruderIndex), thermalManager.degTargetHotend(uiCfg.extruderIndex));
221 221
   }
222 222
   #if HAS_HEATED_BED
223 223
     else {
224 224
       strcat(public_buf_l, preheat_menu.hotbed);
225
-      sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
225
+      sprintf(buf, preheat_menu.value_state, thermalManager.degBed(), thermalManager.degTargetBed());
226 226
     }
227 227
   #endif
228 228
   strcat_P(public_buf_l, PSTR(": "));

+ 36
- 22
Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp Näytä tiedosto

@@ -47,7 +47,7 @@ static lv_obj_t *scr;
47 47
 static lv_obj_t *labelExt1, *labelFan, *labelZpos, *labelTime;
48 48
 static lv_obj_t *labelPause, *labelStop, *labelOperat;
49 49
 static lv_obj_t *bar1, *bar1ValueText;
50
-static lv_obj_t *buttonPause, *buttonOperat, *buttonStop;
50
+static lv_obj_t *buttonPause, *buttonOperat, *buttonStop, *buttonExt1, *buttonExt2, *buttonBedstate, *buttonFanstate, *buttonZpos;
51 51
 
52 52
 #if ENABLED(HAS_MULTI_EXTRUDER)
53 53
   static lv_obj_t *labelExt2;
@@ -60,7 +60,11 @@ static lv_obj_t *buttonPause, *buttonOperat, *buttonStop;
60 60
 enum {
61 61
   ID_PAUSE = 1,
62 62
   ID_STOP,
63
-  ID_OPTION
63
+  ID_OPTION,
64
+  ID_TEMP_EXT,
65
+  ID_TEMP_BED,
66
+  ID_BABYSTEP,
67
+  ID_FAN
64 68
 };
65 69
 
66 70
 bool once_flag; // = false
@@ -100,7 +104,6 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
100 104
         }
101 105
       #endif
102 106
       break;
103
-
104 107
     case ID_STOP:
105 108
       lv_clear_printing();
106 109
       lv_draw_dialog(DIALOG_TYPE_STOP);
@@ -109,6 +112,24 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
109 112
       lv_clear_printing();
110 113
       lv_draw_operation();
111 114
       break;
115
+    case ID_TEMP_EXT:
116
+      uiCfg.curTempType = 0;
117
+      lv_clear_printing();
118
+      lv_draw_preHeat();
119
+      break;
120
+    case ID_TEMP_BED:
121
+      uiCfg.curTempType = 1;
122
+      lv_clear_printing();
123
+      lv_draw_preHeat();
124
+      break;
125
+    case ID_BABYSTEP:
126
+      lv_clear_printing();
127
+      lv_draw_baby_stepping();
128
+      break;
129
+    case ID_FAN:
130
+      lv_clear_printing();
131
+      lv_draw_fan();
132
+      break;
112 133
   }
113 134
 }
114 135
 
@@ -118,33 +139,23 @@ void lv_draw_printing() {
118 139
   scr = lv_screen_create(PRINTING_UI);
119 140
 
120 141
   // Create image buttons
121
-  lv_obj_t *buttonExt1 = lv_img_create(scr, nullptr);
122
-  lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
123
-  lv_obj_set_pos(buttonExt1, 205, 136);
142
+  buttonExt1 = lv_imgbtn_create(scr, "F:/bmp_ext1_state.bin", 206, 136, event_handler, ID_TEMP_EXT);
124 143
 
125 144
   #if HAS_MULTI_EXTRUDER
126
-    lv_obj_t *buttonExt2 = lv_img_create(scr, nullptr);
127
-    lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
128
-    lv_obj_set_pos(buttonExt2, 350, 136);
145
+    buttonExt2 = lv_imgbtn_create(scr, "F:/bmp_ext2_state.bin", 350, 136, event_handler, ID_TEMP_EXT);
129 146
   #endif
130 147
 
131 148
   #if HAS_HEATED_BED
132
-    lv_obj_t *buttonBedstate = lv_img_create(scr, nullptr);
133
-    lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
134
-    lv_obj_set_pos(buttonBedstate, 205, 186);
149
+    buttonBedstate = lv_imgbtn_create(scr, "F:/bmp_bed_state.bin", 206, 186, event_handler, ID_TEMP_BED);
135 150
   #endif
136 151
 
137
-  lv_obj_t *buttonFanstate = lv_img_create(scr, nullptr);
138
-  lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
139
-  lv_obj_set_pos(buttonFanstate, 350, 186);
152
+  buttonFanstate = lv_imgbtn_create(scr, "F:/bmp_fan_state.bin", 350, 186, event_handler, ID_FAN);
140 153
 
141 154
   lv_obj_t *buttonTime = lv_img_create(scr, nullptr);
142 155
   lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
143
-  lv_obj_set_pos(buttonTime, 205, 86);
156
+  lv_obj_set_pos(buttonTime, 206, 86);
144 157
 
145
-  lv_obj_t *buttonZpos = lv_img_create(scr, nullptr);
146
-  lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin");
147
-  lv_obj_set_pos(buttonZpos, 350, 86);
158
+  buttonZpos = lv_imgbtn_create(scr, "F:/bmp_zpos_state.bin", 350, 86, event_handler, ID_BABYSTEP);
148 159
 
149 160
   buttonPause = lv_imgbtn_create(scr, uiCfg.print_state == WORKING ? "F:/bmp_pause.bin" : "F:/bmp_resume.bin", 5, 240, event_handler, ID_PAUSE);
150 161
   buttonStop = lv_imgbtn_create(scr, "F:/bmp_stop.bin", 165, 240, event_handler, ID_STOP);
@@ -155,6 +166,9 @@ void lv_draw_printing() {
155 166
       lv_group_add_obj(g, buttonPause);
156 167
       lv_group_add_obj(g, buttonStop);
157 168
       lv_group_add_obj(g, buttonOperat);
169
+      lv_group_add_obj(g, buttonPause);
170
+      lv_group_add_obj(g, buttonPause);
171
+      lv_group_add_obj(g, buttonPause);
158 172
     }
159 173
   #endif
160 174
 
@@ -205,18 +219,18 @@ void lv_draw_printing() {
205 219
 }
206 220
 
207 221
 void disp_ext_temp() {
208
-  sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0));
222
+  sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0));
209 223
   lv_label_set_text(labelExt1, public_buf_l);
210 224
 
211 225
   #if HAS_MULTI_EXTRUDER
212
-    sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1));
226
+    sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1));
213 227
     lv_label_set_text(labelExt2, public_buf_l);
214 228
   #endif
215 229
 }
216 230
 
217 231
 void disp_bed_temp() {
218 232
   #if HAS_HEATED_BED
219
-    sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
233
+    sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed());
220 234
     lv_label_set_text(labelBed, public_buf_l);
221 235
   #endif
222 236
 }

+ 23
- 23
Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp Näytä tiedosto

@@ -63,7 +63,7 @@ static lv_obj_t *labelExt1, *labelExt1Target, *labelFan;
63 63
   uint8_t curent_disp_ui = 0;
64 64
 #endif
65 65
 
66
-enum { ID_TOOL = 1, ID_SET, ID_PRINT };
66
+enum { ID_TOOL = 1, ID_SET, ID_PRINT, ID_INFO_EXT, ID_INFO_BED, ID_INFO_FAN };
67 67
 
68 68
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
69 69
   if (event != LV_EVENT_RELEASED) return;
@@ -71,6 +71,9 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
71 71
   switch (obj->mks_obj_id) {
72 72
     case ID_TOOL:   lv_draw_tool(); break;
73 73
     case ID_SET:    lv_draw_set(); break;
74
+    case ID_INFO_EXT:  uiCfg.curTempType = 0; lv_draw_preHeat(); break;
75
+    case ID_INFO_BED:  uiCfg.curTempType = 1; lv_draw_preHeat(); break;
76
+    case ID_INFO_FAN:  lv_draw_fan(); break;
74 77
     case ID_PRINT:  lv_draw_print_file(); break;
75 78
   }
76 79
 }
@@ -181,32 +184,14 @@ void lv_draw_ready_print() {
181 184
     lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 180, event_handler, ID_PRINT);
182 185
 
183 186
     // Monitoring
184
-    lv_obj_t *buttonExt1 = lv_img_create(scr, NULL);
187
+    lv_obj_t *buttonExt1 = lv_big_button_create(scr, "F:/bmp_ext1_state.bin", " ", 55, ICON_POS_Y, event_handler, ID_INFO_EXT);
185 188
     #if HAS_MULTI_EXTRUDER
186
-      lv_obj_t *buttonExt2 = lv_img_create(scr, NULL);
189
+        lv_obj_t *buttonExt2 = lv_big_button_create(scr, "F:/bmp_ext2_state.bin", " ", 55, ICON_POS_Y + SECOND_EXT_MOD_Y, event_handler, ID_INFO_EXT);
187 190
     #endif
188 191
     #if HAS_HEATED_BED
189
-      lv_obj_t *buttonBedstate = lv_img_create(scr, NULL);
192
+        lv_obj_t *buttonBedstate = lv_big_button_create(scr, "F:/bmp_bed_state.bin", " ", 210, ICON_POS_Y, event_handler, ID_INFO_BED);
190 193
     #endif
191
-    lv_obj_t *buttonFanstate = lv_img_create(scr, NULL);
192
-
193
-    lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
194
-    #if HAS_MULTI_EXTRUDER
195
-      lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
196
-    #endif
197
-    #if HAS_HEATED_BED
198
-      lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
199
-    #endif
200
-    lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
201
-
202
-    lv_obj_set_pos(buttonExt1, 55, ICON_POS_Y);
203
-    #if HAS_MULTI_EXTRUDER
204
-      lv_obj_set_pos(buttonExt2, 55, ICON_POS_Y + SECOND_EXT_MOD_Y);
205
-    #endif
206
-    #if HAS_HEATED_BED
207
-      lv_obj_set_pos(buttonBedstate, 210, ICON_POS_Y);
208
-    #endif
209
-    lv_obj_set_pos(buttonFanstate, 380, ICON_POS_Y);
194
+    lv_obj_t *buttonFanstate = lv_big_button_create(scr, "F:/bmp_fan_state.bin", " ", 380, ICON_POS_Y, event_handler, ID_INFO_FAN);
210 195
 
211 196
     labelExt1 = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr);
212 197
     labelExt1Target = lv_label_create(scr, 55, LABEL_MOD_Y, nullptr);
@@ -262,6 +247,21 @@ void lv_draw_ready_print() {
262 247
   #endif
263 248
 }
264 249
 
250
+void lv_temp_refr() {
251
+  #if HAS_HEATED_BED
252
+    sprintf(public_buf_l, printing_menu.bed_temp, thermalManager.degBed(), thermalManager.degTargetBed());
253
+    lv_label_set_text(labelBed, public_buf_l);
254
+  #endif
255
+
256
+  sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(0), thermalManager.degTargetHotend(0));
257
+  lv_label_set_text(labelExt1, public_buf_l);
258
+
259
+  #if HAS_MULTI_EXTRUDER
260
+    sprintf(public_buf_l, printing_menu.temp1, thermalManager.degHotend(1), thermalManager.degTargetHotend(1));
261
+    lv_label_set_text(labelExt2, public_buf_l);
262
+  #endif
263
+}
264
+
265 265
 void lv_clear_ready_print() {
266 266
   #if HAS_ROTARY_ENCODER
267 267
     if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);

+ 1
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.h Näytä tiedosto

@@ -32,6 +32,7 @@ extern void disp_Limit_error();
32 32
 extern void disp_det_error();
33 33
 extern void disp_det_ok();
34 34
 extern void lv_clear_ready_print();
35
+extern void lv_temp_refr();
35 36
 
36 37
 #ifdef __cplusplus
37 38
   } /* C-declarations for C++ */

+ 5
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp Näytä tiedosto

@@ -805,6 +805,10 @@ void GUI_RefreshPage() {
805 805
       }
806 806
       break;
807 807
     case PRINT_READY_UI:
808
+      if (temps_update_flag) {
809
+        temps_update_flag = false;
810
+        lv_temp_refr();
811
+      }
808 812
       break;
809 813
 
810 814
     case PRINT_FILE_UI: break;
@@ -843,8 +847,8 @@ void GUI_RefreshPage() {
843 847
     #if ENABLED(MKS_WIFI_MODULE)
844 848
       case WIFI_UI:
845 849
         if (temps_update_flag) {
846
-          disp_wifi_state();
847 850
           temps_update_flag = false;
851
+          disp_wifi_state();
848 852
         }
849 853
         break;
850 854
 

+ 6
- 6
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp Näytä tiedosto

@@ -897,9 +897,9 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
897 897
             strcpy_P(outBuf, PSTR(" B:"));
898 898
             outBuf += 3;
899 899
             #if HAS_HEATED_BED
900
-              strcpy(outBuf, dtostrf(thermalManager.temp_bed.celsius, 1, 1, str_1));
900
+              strcpy(outBuf, dtostrf(thermalManager.degBed(), 1, 1, str_1));
901 901
               strcat_P(outBuf, PSTR(" /"));
902
-              strcat(outBuf, dtostrf(thermalManager.temp_bed.target, 1, 1, str_1));
902
+              strcat(outBuf, dtostrf(thermalManager.degTargetBed(), 1, 1, str_1));
903 903
             #else
904 904
               strcpy_P(outBuf, PSTR("0 /0"));
905 905
             #endif
@@ -924,15 +924,15 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
924 924
           }
925 925
           else {
926 926
             sprintf_P((char *)tempBuf, PSTR("T:%d /%d B:%d /%d T0:%d /%d T1:%d /%d @:0 B@:0\r\n"),
927
-              (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0),
927
+              thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
928 928
               #if HAS_HEATED_BED
929
-                (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target,
929
+                thermalManager.degBed(), thermalManager.degTargetBed(),
930 930
               #else
931 931
                 0, 0,
932 932
               #endif
933
-              (int)thermalManager.degHotend(0), (int)thermalManager.degTargetHotend(0),
933
+              thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
934 934
               #if HAS_MULTI_HOTEND
935
-                (int)thermalManager.degHotend(1), (int)thermalManager.degTargetHotend(1)
935
+                thermalManager.degHotend(1), thermalManager.degTargetHotend(1)
936 936
               #else
937 937
                 0, 0
938 938
               #endif

Loading…
Peruuta
Tallenna