Browse Source

Fix UI compile issues (#20092)

Victor Oliveira 4 years ago
parent
commit
f8ee6f8b31
No account linked to committer's email address

+ 1
- 1
Marlin/src/lcd/dogm/u8g_dev_st7920_128x64_HAL.cpp View File

55
 
55
 
56
 #include "../../inc/MarlinConfigPre.h"
56
 #include "../../inc/MarlinConfigPre.h"
57
 
57
 
58
-#if HAS_MARLINUI_U8GLIB
58
+#if HAS_MARLINUI_U8GLIB && DISABLED(TFT_CLASSIC_UI)
59
 
59
 
60
 #include "HAL_LCD_com_defines.h"
60
 #include "HAL_LCD_com_defines.h"
61
 
61
 

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp View File

181
 
181
 
182
   strcat_P(public_buf_l, PSTR(".bin"));
182
   strcat_P(public_buf_l, PSTR(".bin"));
183
 
183
 
184
-  lv_obj_set_event_cb_mks(obj, event_handler, id, nullptr, 0);
184
+  lv_obj_set_event_cb_mks(obj, event_handler, id, "", 0);
185
   lv_imgbtn_set_src_both(obj, public_buf_l);
185
   lv_imgbtn_set_src_both(obj, public_buf_l);
186
 
186
 
187
   if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);
187
   if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);

+ 5
- 5
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp View File

279
       cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m);
279
       cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m);
280
 
280
 
281
       if (list_file.IsFolder[i]) {
281
       if (list_file.IsFolder[i]) {
282
-        lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
282
+        lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
283
         lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin");
283
         lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin");
284
         if (i < 3)
284
         if (i < 3)
285
           lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
285
           lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
298
           strcat(test_public_buf_l, list_file.file_name[i]);
298
           strcat(test_public_buf_l, list_file.file_name[i]);
299
           char *temp = strstr(test_public_buf_l, ".GCO");
299
           char *temp = strstr(test_public_buf_l, ".GCO");
300
           if (temp) strcpy(temp, ".bin");
300
           if (temp) strcpy(temp, ".bin");
301
-          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
301
+          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
302
           lv_imgbtn_set_src_both(buttonGcode[i], test_public_buf_l);
302
           lv_imgbtn_set_src_both(buttonGcode[i], test_public_buf_l);
303
           if (i < 3) {
303
           if (i < 3) {
304
             lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET);
304
             lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET);
308
             lv_btn_use_label_style(buttonText[i]);
308
             lv_btn_use_label_style(buttonText[i]);
309
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
309
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
310
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
310
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
311
-            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0);
311
+            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),"", 0);
312
             lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
312
             lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
313
             lv_obj_set_size(buttonText[i], 100, 40);
313
             lv_obj_set_size(buttonText[i], 100, 40);
314
           }
314
           }
320
             lv_btn_use_label_style(buttonText[i]);
320
             lv_btn_use_label_style(buttonText[i]);
321
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
321
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
322
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
322
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
323
-            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0);
323
+            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),"", 0);
324
             lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
324
             lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
325
             lv_obj_set_size(buttonText[i], 100, 40);
325
             lv_obj_set_size(buttonText[i], 100, 40);
326
           }
326
           }
328
           lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
328
           lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
329
         }
329
         }
330
         else {
330
         else {
331
-          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
331
+          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
332
           lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin");
332
           lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin");
333
           if (i < 3)
333
           if (i < 3)
334
             lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
334
             lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);

+ 3
- 3
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp View File

1680
 lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/, lv_style_t *style/*=&style_para_value*/) {
1680
 lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/, lv_style_t *style/*=&style_para_value*/) {
1681
   lv_obj_t *btn = lv_btn_create(par, nullptr);
1681
   lv_obj_t *btn = lv_btn_create(par, nullptr);
1682
   if (id)
1682
   if (id)
1683
-    lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
1683
+    lv_obj_set_event_cb_mks(btn, cb, id, "", 0);
1684
   else
1684
   else
1685
     lv_obj_set_event_cb(btn, cb);
1685
     lv_obj_set_event_cb(btn, cb);
1686
   lv_btn_set_style_both(btn, style);
1686
   lv_btn_set_style_both(btn, style);
1748
   lv_obj_t *btn = lv_imgbtn_create(par, nullptr);
1748
   lv_obj_t *btn = lv_imgbtn_create(par, nullptr);
1749
   if (img) lv_imgbtn_set_src_both(btn, img);
1749
   if (img) lv_imgbtn_set_src_both(btn, img);
1750
   if (id)
1750
   if (id)
1751
-    lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
1751
+    lv_obj_set_event_cb_mks(btn, cb, id, "", 0);
1752
   else
1752
   else
1753
     lv_obj_set_event_cb(btn, cb);
1753
     lv_obj_set_event_cb(btn, cb);
1754
   lv_imgbtn_use_label_style(btn);
1754
   lv_imgbtn_use_label_style(btn);
1785
   lv_obj_t *btn = lv_btn_create(par, nullptr);   /*Add a button the current screen*/
1785
   lv_obj_t *btn = lv_btn_create(par, nullptr);   /*Add a button the current screen*/
1786
   lv_obj_set_pos(btn, x, y);                         /*Set its position*/
1786
   lv_obj_set_pos(btn, x, y);                         /*Set its position*/
1787
   lv_obj_set_size(btn, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
1787
   lv_obj_set_size(btn, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
1788
-  if (id > -1) lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
1788
+  if (id > -1) lv_obj_set_event_cb_mks(btn, cb, id, "", 0);
1789
   lv_btn_use_label_style(btn);
1789
   lv_btn_use_label_style(btn);
1790
   lv_btn_set_layout(btn, LV_LAYOUT_OFF);
1790
   lv_btn_set_layout(btn, LV_LAYOUT_OFF);
1791
   lv_obj_t *label = lv_label_create_empty(btn);        /*Add a label to the button*/
1791
   lv_obj_t *label = lv_label_create_empty(btn);        /*Add a label to the button*/

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp View File

73
 
73
 
74
     buttonReconnect = lv_imgbtn_create(scr, nullptr);
74
     buttonReconnect = lv_imgbtn_create(scr, nullptr);
75
 
75
 
76
-    lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, nullptr, 0);
76
+    lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, "", 0);
77
     lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin");
77
     lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin");
78
     lv_imgbtn_use_label_style(buttonReconnect);
78
     lv_imgbtn_use_label_style(buttonReconnect);
79
 
79
 

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp View File

21
  */
21
  */
22
 #include "../../../../inc/MarlinConfigPre.h"
22
 #include "../../../../inc/MarlinConfigPre.h"
23
 
23
 
24
-#if HAS_TFT_LVGL_UI
24
+#if BOTH(HAS_TFT_LVGL_UI, USE_WIFI_FUNCTION)
25
 
25
 
26
 #include "draw_ui.h"
26
 #include "draw_ui.h"
27
 #include "wifi_module.h"
27
 #include "wifi_module.h"
822
   return esp_upload.uploadResult == success ? 0 : -1;
822
   return esp_upload.uploadResult == success ? 0 : -1;
823
 }
823
 }
824
 
824
 
825
-#endif  // HAS_TFT_LVGL_UI
825
+#endif // HAS_TFT_LVGL_UI && USE_WIFI_FUNCTION

+ 1
- 1
Marlin/src/lcd/lcdprint.cpp View File

26
 
26
 
27
 #include "../inc/MarlinConfigPre.h"
27
 #include "../inc/MarlinConfigPre.h"
28
 
28
 
29
-#if HAS_WIRED_LCD
29
+#if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT
30
 
30
 
31
 #include "lcdprint.h"
31
 #include "lcdprint.h"
32
 
32
 

+ 58
- 54
Marlin/src/lcd/marlinui.cpp View File

262
 
262
 
263
   #endif
263
   #endif
264
 
264
 
265
-  void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
266
-    SETCURSOR(col, row);
267
-    if (!string) return;
268
-
269
-    auto _newline = [&col, &row]{
270
-      col = 0; row++;                 // Move col to string len (plus space)
271
-      SETCURSOR(0, row);              // Simulate carriage return
272
-    };
273
-
274
-    uint8_t *p = (uint8_t*)string;
275
-    wchar_t ch;
276
-    if (wordwrap) {
277
-      uint8_t *wrd = nullptr, c = 0;
278
-      // find the end of the part
279
-      for (;;) {
280
-        if (!wrd) wrd = p;            // Get word start /before/ advancing
281
-        p = get_utf8_value_cb(p, cb_read_byte, &ch);
282
-        const bool eol = !ch;         // zero ends the string
283
-        // End or a break between phrases?
284
-        if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
285
-          if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
286
-          // Past the right and the word is not too long?
287
-          if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap?
288
-          c += !eol;                  // +1 so the space will be printed
289
-          col += c;                   // advance col to new position
290
-          while (c) {                 // character countdown
291
-            --c;                      // count down to zero
292
-            wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
293
-            lcd_put_wchar(ch);        // character to the LCD
265
+  #if !HAS_GRAPHICAL_TFT
266
+
267
+    void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
268
+      SETCURSOR(col, row);
269
+      if (!string) return;
270
+
271
+      auto _newline = [&col, &row]{
272
+        col = 0; row++;                 // Move col to string len (plus space)
273
+        SETCURSOR(0, row);              // Simulate carriage return
274
+      };
275
+
276
+      uint8_t *p = (uint8_t*)string;
277
+      wchar_t ch;
278
+      if (wordwrap) {
279
+        uint8_t *wrd = nullptr, c = 0;
280
+        // find the end of the part
281
+        for (;;) {
282
+          if (!wrd) wrd = p;            // Get word start /before/ advancing
283
+          p = get_utf8_value_cb(p, cb_read_byte, &ch);
284
+          const bool eol = !ch;         // zero ends the string
285
+          // End or a break between phrases?
286
+          if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
287
+            if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
288
+            // Past the right and the word is not too long?
289
+            if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap?
290
+            c += !eol;                  // +1 so the space will be printed
291
+            col += c;                   // advance col to new position
292
+            while (c) {                 // character countdown
293
+              --c;                      // count down to zero
294
+              wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
295
+              lcd_put_wchar(ch);        // character to the LCD
296
+            }
297
+            if (eol) break;             // all done!
298
+            wrd = nullptr;              // set up for next word
294
           }
299
           }
295
-          if (eol) break;             // all done!
296
-          wrd = nullptr;              // set up for next word
300
+          else c++;                     // count word characters
297
         }
301
         }
298
-        else c++;                     // count word characters
299
       }
302
       }
300
-    }
301
-    else {
302
-      for (;;) {
303
-        p = get_utf8_value_cb(p, cb_read_byte, &ch);
304
-        if (!ch) break;
305
-        lcd_put_wchar(ch);
306
-        col++;
307
-        if (col >= LCD_WIDTH) _newline();
303
+      else {
304
+        for (;;) {
305
+          p = get_utf8_value_cb(p, cb_read_byte, &ch);
306
+          if (!ch) break;
307
+          lcd_put_wchar(ch);
308
+          col++;
309
+          if (col >= LCD_WIDTH) _newline();
310
+        }
308
       }
311
       }
309
     }
312
     }
310
-  }
311
 
313
 
312
-  void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
313
-    const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
314
-    uint8_t col = 0, row = 0;
315
-    if (!string && plen + slen <= LCD_WIDTH) {
316
-      col = (LCD_WIDTH - plen - slen) / 2;
317
-      row = LCD_HEIGHT > 3 ? 1 : 0;
318
-    }
319
-    wrap_string_P(col, row, pref, true);
320
-    if (string) {
321
-      if (col) { col = 0; row++; } // Move to the start of the next line
322
-      wrap_string(col, row, string);
314
+    void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
315
+      const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
316
+      uint8_t col = 0, row = 0;
317
+      if (!string && plen + slen <= LCD_WIDTH) {
318
+        col = (LCD_WIDTH - plen - slen) / 2;
319
+        row = LCD_HEIGHT > 3 ? 1 : 0;
320
+      }
321
+      wrap_string_P(col, row, pref, true);
322
+      if (string) {
323
+        if (col) { col = 0; row++; } // Move to the start of the next line
324
+        wrap_string(col, row, string);
325
+      }
326
+      if (suff) wrap_string_P(col, row, suff);
323
     }
327
     }
324
-    if (suff) wrap_string_P(col, row, suff);
325
-  }
328
+
329
+  #endif // !HAS_GRAPHICAL_TFT
326
 
330
 
327
 #endif // HAS_LCD_MENU
331
 #endif // HAS_LCD_MENU
328
 
332
 

+ 4
- 6
Marlin/src/lcd/marlinui.h View File

80
 
80
 
81
     #include "lcdprint.h"
81
     #include "lcdprint.h"
82
 
82
 
83
-    void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false);
84
-    inline void wrap_string_P(uint8_t &col, uint8_t &row, PGM_P const pstr, const bool wordwrap=false) { _wrap_string(col, row, pstr, read_byte_rom, wordwrap); }
85
-    inline void wrap_string(uint8_t &col, uint8_t &row, const char * const string, const bool wordwrap=false) { _wrap_string(col, row, string, read_byte_ram, wordwrap); }
86
-
87
-    #if ENABLED(SDSUPPORT)
88
-      #include "../sd/cardreader.h"
83
+    #if !HAS_GRAPHICAL_TFT
84
+      void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false);
85
+      inline void wrap_string_P(uint8_t &col, uint8_t &row, PGM_P const pstr, const bool wordwrap=false) { _wrap_string(col, row, pstr, read_byte_rom, wordwrap); }
86
+      inline void wrap_string(uint8_t &col, uint8_t &row, const char * const string, const bool wordwrap=false) { _wrap_string(col, row, string, read_byte_ram, wordwrap); }
89
     #endif
87
     #endif
90
 
88
 
91
     typedef void (*screenFunc_t)();
89
     typedef void (*screenFunc_t)();

Loading…
Cancel
Save