Clean up M80/M81, DWIN

This commit is contained in:
Scott Lahteine
2020-08-13 21:30:12 -05:00
parent 16cb4303a4
commit aaba9b7880
3 changed files with 11 additions and 13 deletions

View File

@ -935,7 +935,8 @@ void Goto_PrintProcess(void) {
// Copy into filebuf string before entry
char * const name = card.longest_filename();
DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2, 60, name);
const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2;
DWIN_Draw_String(false, false, font8x16, White, Background_black, npos, 60, name);
DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193);
DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191);
@ -1523,7 +1524,7 @@ inline void make_name_without_ext(char *dst, char *src, int maxlen=MENU_CHAR_LIM
if (!card.flag.filenameIsDir)
while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0)
int len = pos; // nul or '.'
size_t len = pos; // nul or '.'
if (len > maxlen) { // Keep the name short
pos = len = maxlen; // move nul down
dst[--pos] = '.'; // insert dots
@ -3436,7 +3437,8 @@ void EachMomentUpdate(void) {
Popup_Window_Resume();
draw_first_option(false);
char * const name = card.longest_filename();
DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2, 252, name);
const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2;
DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name);
DWIN_UpdateLCD();
break;
}

View File

@ -38,6 +38,6 @@ int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp,
/* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */
uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval);
/* Returns lenght of string in CHARACTERS, NOT BYTES */
/* Returns length of string in CHARACTERS, NOT BYTES */
uint8_t utf8_strlen(const char *pstart);
uint8_t utf8_strlen_P(PGM_P pstart);