Fix UI compile issues (#20092)

This commit is contained in:
Victor Oliveira 2020-11-10 22:39:34 -03:00 committed by Scott Lahteine
parent ee48fc6544
commit ccb5e34052
9 changed files with 75 additions and 73 deletions

View File

@ -55,7 +55,7 @@
#include "../../inc/MarlinConfigPre.h" #include "../../inc/MarlinConfigPre.h"
#if HAS_MARLINUI_U8GLIB #if HAS_MARLINUI_U8GLIB && DISABLED(TFT_CLASSIC_UI)
#include "HAL_LCD_com_defines.h" #include "HAL_LCD_com_defines.h"

View File

@ -181,7 +181,7 @@ static void disp_language(uint8_t language, uint8_t state) {
strcat_P(public_buf_l, PSTR(".bin")); strcat_P(public_buf_l, PSTR(".bin"));
lv_obj_set_event_cb_mks(obj, event_handler, id, nullptr, 0); lv_obj_set_event_cb_mks(obj, event_handler, id, "", 0);
lv_imgbtn_set_src_both(obj, public_buf_l); lv_imgbtn_set_src_both(obj, public_buf_l);
if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj); if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);

View File

@ -279,7 +279,7 @@ void disp_gcode_icon(uint8_t file_num) {
cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m); cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m);
if (list_file.IsFolder[i]) { if (list_file.IsFolder[i]) {
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0); lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin"); lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin");
if (i < 3) if (i < 3)
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
@ -298,7 +298,7 @@ void disp_gcode_icon(uint8_t file_num) {
strcat(test_public_buf_l, list_file.file_name[i]); strcat(test_public_buf_l, list_file.file_name[i]);
char *temp = strstr(test_public_buf_l, ".GCO"); char *temp = strstr(test_public_buf_l, ".GCO");
if (temp) strcpy(temp, ".bin"); if (temp) strcpy(temp, ".bin");
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0); lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
lv_imgbtn_set_src_both(buttonGcode[i], test_public_buf_l); lv_imgbtn_set_src_both(buttonGcode[i], test_public_buf_l);
if (i < 3) { if (i < 3) {
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); 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,7 +308,7 @@ void disp_gcode_icon(uint8_t file_num) {
lv_btn_use_label_style(buttonText[i]); lv_btn_use_label_style(buttonText[i]);
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0); //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),"", 0);
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); 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);
lv_obj_set_size(buttonText[i], 100, 40); lv_obj_set_size(buttonText[i], 100, 40);
} }
@ -320,7 +320,7 @@ void disp_gcode_icon(uint8_t file_num) {
lv_btn_use_label_style(buttonText[i]); lv_btn_use_label_style(buttonText[i]);
lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW); lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF); lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
//lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0); //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),"", 0);
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); 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);
lv_obj_set_size(buttonText[i], 100, 40); lv_obj_set_size(buttonText[i], 100, 40);
} }
@ -328,7 +328,7 @@ void disp_gcode_icon(uint8_t file_num) {
lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0); lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
} }
else { else {
lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0); lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "", 0);
lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin"); lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin");
if (i < 3) if (i < 3)
lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight); lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);

View File

@ -1680,7 +1680,7 @@ lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char
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*/) { 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*/) {
lv_obj_t *btn = lv_btn_create(par, nullptr); lv_obj_t *btn = lv_btn_create(par, nullptr);
if (id) if (id)
lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0); lv_obj_set_event_cb_mks(btn, cb, id, "", 0);
else else
lv_obj_set_event_cb(btn, cb); lv_obj_set_event_cb(btn, cb);
lv_btn_set_style_both(btn, style); lv_btn_set_style_both(btn, style);
@ -1748,7 +1748,7 @@ lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, con
lv_obj_t *btn = lv_imgbtn_create(par, nullptr); lv_obj_t *btn = lv_imgbtn_create(par, nullptr);
if (img) lv_imgbtn_set_src_both(btn, img); if (img) lv_imgbtn_set_src_both(btn, img);
if (id) if (id)
lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0); lv_obj_set_event_cb_mks(btn, cb, id, "", 0);
else else
lv_obj_set_event_cb(btn, cb); lv_obj_set_event_cb(btn, cb);
lv_imgbtn_use_label_style(btn); lv_imgbtn_use_label_style(btn);
@ -1785,7 +1785,7 @@ lv_obj_t* lv_screen_menu_item(lv_obj_t *par, const char *text, lv_coord_t x, lv_
lv_obj_t *btn = lv_btn_create(par, nullptr); /*Add a button the current screen*/ lv_obj_t *btn = lv_btn_create(par, nullptr); /*Add a button the current screen*/
lv_obj_set_pos(btn, x, y); /*Set its position*/ lv_obj_set_pos(btn, x, y); /*Set its position*/
lv_obj_set_size(btn, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/ lv_obj_set_size(btn, PARA_UI_SIZE_X, PARA_UI_SIZE_Y); /*Set its size*/
if (id > -1) lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0); if (id > -1) lv_obj_set_event_cb_mks(btn, cb, id, "", 0);
lv_btn_use_label_style(btn); lv_btn_use_label_style(btn);
lv_btn_set_layout(btn, LV_LAYOUT_OFF); lv_btn_set_layout(btn, LV_LAYOUT_OFF);
lv_obj_t *label = lv_label_create_empty(btn); /*Add a label to the button*/ lv_obj_t *label = lv_label_create_empty(btn); /*Add a label to the button*/

View File

@ -73,7 +73,7 @@ void lv_draw_wifi(void) {
buttonReconnect = lv_imgbtn_create(scr, nullptr); buttonReconnect = lv_imgbtn_create(scr, nullptr);
lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, nullptr, 0); lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, "", 0);
lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin"); lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin");
lv_imgbtn_use_label_style(buttonReconnect); lv_imgbtn_use_label_style(buttonReconnect);

View File

@ -21,7 +21,7 @@
*/ */
#include "../../../../inc/MarlinConfigPre.h" #include "../../../../inc/MarlinConfigPre.h"
#if HAS_TFT_LVGL_UI #if BOTH(HAS_TFT_LVGL_UI, USE_WIFI_FUNCTION)
#include "draw_ui.h" #include "draw_ui.h"
#include "wifi_module.h" #include "wifi_module.h"
@ -822,4 +822,4 @@ int32_t wifi_upload(int type) {
return esp_upload.uploadResult == success ? 0 : -1; return esp_upload.uploadResult == success ? 0 : -1;
} }
#endif // HAS_TFT_LVGL_UI #endif // HAS_TFT_LVGL_UI && USE_WIFI_FUNCTION

View File

@ -26,7 +26,7 @@
#include "../inc/MarlinConfigPre.h" #include "../inc/MarlinConfigPre.h"
#if HAS_WIRED_LCD #if HAS_WIRED_LCD && !HAS_GRAPHICAL_TFT
#include "lcdprint.h" #include "lcdprint.h"

View File

@ -262,67 +262,71 @@ millis_t MarlinUI::next_button_update_ms; // = 0
#endif #endif
void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) { #if !HAS_GRAPHICAL_TFT
SETCURSOR(col, row);
if (!string) return;
auto _newline = [&col, &row]{ void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
col = 0; row++; // Move col to string len (plus space) SETCURSOR(col, row);
SETCURSOR(0, row); // Simulate carriage return if (!string) return;
};
uint8_t *p = (uint8_t*)string; auto _newline = [&col, &row]{
wchar_t ch; col = 0; row++; // Move col to string len (plus space)
if (wordwrap) { SETCURSOR(0, row); // Simulate carriage return
uint8_t *wrd = nullptr, c = 0; };
// find the end of the part
for (;;) { uint8_t *p = (uint8_t*)string;
if (!wrd) wrd = p; // Get word start /before/ advancing wchar_t ch;
p = get_utf8_value_cb(p, cb_read_byte, &ch); if (wordwrap) {
const bool eol = !ch; // zero ends the string uint8_t *wrd = nullptr, c = 0;
// End or a break between phrases? // find the end of the part
if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') { for (;;) {
if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces if (!wrd) wrd = p; // Get word start /before/ advancing
// Past the right and the word is not too long? p = get_utf8_value_cb(p, cb_read_byte, &ch);
if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap? const bool eol = !ch; // zero ends the string
c += !eol; // +1 so the space will be printed // End or a break between phrases?
col += c; // advance col to new position if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
while (c) { // character countdown if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
--c; // count down to zero // Past the right and the word is not too long?
wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap?
lcd_put_wchar(ch); // character to the LCD c += !eol; // +1 so the space will be printed
col += c; // advance col to new position
while (c) { // character countdown
--c; // count down to zero
wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
lcd_put_wchar(ch); // character to the LCD
}
if (eol) break; // all done!
wrd = nullptr; // set up for next word
} }
if (eol) break; // all done! else c++; // count word characters
wrd = nullptr; // set up for next word }
}
else {
for (;;) {
p = get_utf8_value_cb(p, cb_read_byte, &ch);
if (!ch) break;
lcd_put_wchar(ch);
col++;
if (col >= LCD_WIDTH) _newline();
} }
else c++; // count word characters
} }
} }
else {
for (;;) {
p = get_utf8_value_cb(p, cb_read_byte, &ch);
if (!ch) break;
lcd_put_wchar(ch);
col++;
if (col >= LCD_WIDTH) _newline();
}
}
}
void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) { void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0; const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
uint8_t col = 0, row = 0; uint8_t col = 0, row = 0;
if (!string && plen + slen <= LCD_WIDTH) { if (!string && plen + slen <= LCD_WIDTH) {
col = (LCD_WIDTH - plen - slen) / 2; col = (LCD_WIDTH - plen - slen) / 2;
row = LCD_HEIGHT > 3 ? 1 : 0; row = LCD_HEIGHT > 3 ? 1 : 0;
}
wrap_string_P(col, row, pref, true);
if (string) {
if (col) { col = 0; row++; } // Move to the start of the next line
wrap_string(col, row, string);
}
if (suff) wrap_string_P(col, row, suff);
} }
wrap_string_P(col, row, pref, true);
if (string) { #endif // !HAS_GRAPHICAL_TFT
if (col) { col = 0; row++; } // Move to the start of the next line
wrap_string(col, row, string);
}
if (suff) wrap_string_P(col, row, suff);
}
#endif // HAS_LCD_MENU #endif // HAS_LCD_MENU

View File

@ -80,12 +80,10 @@
#include "lcdprint.h" #include "lcdprint.h"
void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false); #if !HAS_GRAPHICAL_TFT
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); } void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, const bool wordwrap=false);
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); } 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); }
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); }
#if ENABLED(SDSUPPORT)
#include "../sd/cardreader.h"
#endif #endif
typedef void (*screenFunc_t)(); typedef void (*screenFunc_t)();