Browse Source

Clean up M80/M81, DWIN

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
aaba9b7880
  1. 14
      Marlin/src/gcode/control/M80_M81.cpp
  2. 8
      Marlin/src/lcd/dwin/dwin.cpp
  3. 2
      Marlin/src/lcd/fontutils.h

14
Marlin/src/gcode/control/M80_M81.cpp

@ -22,15 +22,11 @@
#include "../gcode.h" #include "../gcode.h"
#include "../../module/temperature.h" #include "../../module/temperature.h"
#include "../../module/stepper.h" #include "../../module/printcounter.h" // for print_job_timer
#include "../../module/printcounter.h" // for print_job_timer #include "../../lcd/ultralcd.h" // for LCD_MESSAGEPGM_P
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#if HAS_LCD_MENU
#include "../../lcd/ultralcd.h"
#endif
#if HAS_SUICIDE #if HAS_SUICIDE
#include "../../MarlinCore.h" #include "../../MarlinCore.h"
#endif #endif
@ -39,6 +35,8 @@
#if ENABLED(AUTO_POWER_CONTROL) #if ENABLED(AUTO_POWER_CONTROL)
#include "../../feature/power.h" #include "../../feature/power.h"
#else
void restore_stepper_drivers();
#endif #endif
// Could be moved to a feature, but this is all the data // Could be moved to a feature, but this is all the data
@ -108,7 +106,5 @@ void GcodeSuite::M81() {
PSU_OFF(); PSU_OFF();
#endif #endif
#if HAS_LCD_MENU LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF "."));
LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF "."));
#endif
} }

8
Marlin/src/lcd/dwin/dwin.cpp

@ -935,7 +935,8 @@ void Goto_PrintProcess(void) {
// Copy into filebuf string before entry // Copy into filebuf string before entry
char * const name = card.longest_filename(); 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_PrintTime, 17, 193);
DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191); 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) if (!card.flag.filenameIsDir)
while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0) 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 if (len > maxlen) { // Keep the name short
pos = len = maxlen; // move nul down pos = len = maxlen; // move nul down
dst[--pos] = '.'; // insert dots dst[--pos] = '.'; // insert dots
@ -3436,7 +3437,8 @@ void EachMomentUpdate(void) {
Popup_Window_Resume(); Popup_Window_Resume();
draw_first_option(false); draw_first_option(false);
char * const name = card.longest_filename(); 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(); DWIN_UpdateLCD();
break; break;
} }

2
Marlin/src/lcd/fontutils.h

@ -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 */ /* 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); 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(const char *pstart);
uint8_t utf8_strlen_P(PGM_P pstart); uint8_t utf8_strlen_P(PGM_P pstart);

Loading…
Cancel
Save