Browse Source

Clean up M80/M81, DWIN

Scott Lahteine 3 years ago
parent
commit
aaba9b7880
3 changed files with 11 additions and 13 deletions
  1. 5
    9
      Marlin/src/gcode/control/M80_M81.cpp
  2. 5
    3
      Marlin/src/lcd/dwin/dwin.cpp
  3. 1
    1
      Marlin/src/lcd/fontutils.h

+ 5
- 9
Marlin/src/gcode/control/M80_M81.cpp View File

@@ -22,15 +22,11 @@
22 22
 
23 23
 #include "../gcode.h"
24 24
 #include "../../module/temperature.h"
25
-#include "../../module/stepper.h"
26
-#include "../../module/printcounter.h" // for print_job_timer
25
+#include "../../module/printcounter.h"  // for print_job_timer
26
+#include "../../lcd/ultralcd.h"         // for LCD_MESSAGEPGM_P
27 27
 
28 28
 #include "../../inc/MarlinConfig.h"
29 29
 
30
-#if HAS_LCD_MENU
31
-  #include "../../lcd/ultralcd.h"
32
-#endif
33
-
34 30
 #if HAS_SUICIDE
35 31
   #include "../../MarlinCore.h"
36 32
 #endif
@@ -39,6 +35,8 @@
39 35
 
40 36
   #if ENABLED(AUTO_POWER_CONTROL)
41 37
     #include "../../feature/power.h"
38
+  #else
39
+    void restore_stepper_drivers();
42 40
   #endif
43 41
 
44 42
   // Could be moved to a feature, but this is all the data
@@ -108,7 +106,5 @@ void GcodeSuite::M81() {
108 106
     PSU_OFF();
109 107
   #endif
110 108
 
111
-  #if HAS_LCD_MENU
112
-    LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF "."));
113
-  #endif
109
+  LCD_MESSAGEPGM_P(PSTR(MACHINE_NAME " " STR_OFF "."));
114 110
 }

+ 5
- 3
Marlin/src/lcd/dwin/dwin.cpp View File

@@ -935,7 +935,8 @@ void Goto_PrintProcess(void) {
935 935
 
936 936
   // Copy into filebuf string before entry
937 937
   char * const name = card.longest_filename();
938
-  DWIN_Draw_String(false, false, font8x16, White, Background_black, (DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2, 60, name);
938
+  const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2;
939
+  DWIN_Draw_String(false, false, font8x16, White, Background_black, npos, 60, name);
939 940
 
940 941
   DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193);
941 942
   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
1523 1524
   if (!card.flag.filenameIsDir)
1524 1525
     while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0)
1525 1526
 
1526
-  int len = pos;      // nul or '.'
1527
+  size_t len = pos;   // nul or '.'
1527 1528
   if (len > maxlen) { // Keep the name short
1528 1529
     pos        = len = maxlen; // move nul down
1529 1530
     dst[--pos] = '.'; // insert dots
@@ -3436,7 +3437,8 @@ void EachMomentUpdate(void) {
3436 3437
         Popup_Window_Resume();
3437 3438
         draw_first_option(false);
3438 3439
         char * const name = card.longest_filename();
3439
-        DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, (DWIN_WIDTH - strlen(name) * MENU_CHR_W) / 2, 252, name);
3440
+        const int8_t npos = _MAX(0, DWIN_WIDTH - strlen(name) * (MENU_CHR_W)) / 2;
3441
+        DWIN_Draw_String(false, true, font8x16, Font_window, Background_window, npos, 252, name);
3440 3442
         DWIN_UpdateLCD();
3441 3443
         break;
3442 3444
       }

+ 1
- 1
Marlin/src/lcd/fontutils.h View File

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

Loading…
Cancel
Save