Browse Source

Clean up M80/M81, DWIN

Scott Lahteine 4 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
 
22
 
23
 #include "../gcode.h"
23
 #include "../gcode.h"
24
 #include "../../module/temperature.h"
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
 #include "../../inc/MarlinConfig.h"
28
 #include "../../inc/MarlinConfig.h"
29
 
29
 
30
-#if HAS_LCD_MENU
31
-  #include "../../lcd/ultralcd.h"
32
-#endif
33
-
34
 #if HAS_SUICIDE
30
 #if HAS_SUICIDE
35
   #include "../../MarlinCore.h"
31
   #include "../../MarlinCore.h"
36
 #endif
32
 #endif
39
 
35
 
40
   #if ENABLED(AUTO_POWER_CONTROL)
36
   #if ENABLED(AUTO_POWER_CONTROL)
41
     #include "../../feature/power.h"
37
     #include "../../feature/power.h"
38
+  #else
39
+    void restore_stepper_drivers();
42
   #endif
40
   #endif
43
 
41
 
44
   // Could be moved to a feature, but this is all the data
42
   // Could be moved to a feature, but this is all the data
108
     PSU_OFF();
106
     PSU_OFF();
109
   #endif
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
 
935
 
936
   // Copy into filebuf string before entry
936
   // Copy into filebuf string before entry
937
   char * const name = card.longest_filename();
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
   DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193);
941
   DWIN_ICON_Show(ICON, ICON_PrintTime, 17, 193);
941
   DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191);
942
   DWIN_ICON_Show(ICON, ICON_RemainTime, 150, 191);
1523
   if (!card.flag.filenameIsDir)
1524
   if (!card.flag.filenameIsDir)
1524
     while (pos && src[pos] != '.') pos--; // find last '.' (stop at 0)
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
   if (len > maxlen) { // Keep the name short
1528
   if (len > maxlen) { // Keep the name short
1528
     pos        = len = maxlen; // move nul down
1529
     pos        = len = maxlen; // move nul down
1529
     dst[--pos] = '.'; // insert dots
1530
     dst[--pos] = '.'; // insert dots
3436
         Popup_Window_Resume();
3437
         Popup_Window_Resume();
3437
         draw_first_option(false);
3438
         draw_first_option(false);
3438
         char * const name = card.longest_filename();
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
         DWIN_UpdateLCD();
3442
         DWIN_UpdateLCD();
3441
         break;
3443
         break;
3442
       }
3444
       }

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

38
 /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */
38
 /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */
39
 uint8_t* get_utf8_value_cb(uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval);
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
 uint8_t utf8_strlen(const char *pstart);
42
 uint8_t utf8_strlen(const char *pstart);
43
 uint8_t utf8_strlen_P(PGM_P pstart);
43
 uint8_t utf8_strlen_P(PGM_P pstart);

Loading…
Cancel
Save