Browse Source

Merge pull request #4243 from thinkyhead/rc_fix_static_scrolling

Improve STATIC_ITEM implementation
Scott Lahteine 8 years ago
parent
commit
6e68dd292b

+ 1
- 6
Marlin/Conditionals.h View File

118
     #define REPRAP_DISCOUNT_SMART_CONTROLLER
118
     #define REPRAP_DISCOUNT_SMART_CONTROLLER
119
   #endif
119
   #endif
120
 
120
 
121
-  #if ENABLED(ULTIMAKERCONTROLLER) || ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL) || ENABLED(RIGIDBOT_PANEL)
122
-    #define ULTIPANEL
123
-    #define NEWPANEL
124
-  #endif
125
-
126
-  #if ENABLED(REPRAPWORLD_KEYPAD)
121
+  #if ENABLED(ULTIMAKERCONTROLLER) || ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL) || ENABLED(RIGIDBOT_PANEL) || ENABLED(REPRAPWORLD_KEYPAD)
127
     #define ULTIPANEL
122
     #define ULTIPANEL
128
     #define NEWPANEL
123
     #define NEWPANEL
129
   #endif
124
   #endif

+ 16
- 14
Marlin/dogm_lcd_implementation.h View File

138
   #define TALL_FONT_CORRECTION 0
138
   #define TALL_FONT_CORRECTION 0
139
 #endif
139
 #endif
140
 
140
 
141
-#define START_ROW              0
141
+#define START_COL              0
142
 
142
 
143
 // LCD selection
143
 // LCD selection
144
 #if ENABLED(U8GLIB_ST7920)
144
 #if ENABLED(U8GLIB_ST7920)
483
   else {
483
   else {
484
     u8g.setColorIndex(1); // unmarked text is black on white
484
     u8g.setColorIndex(1); // unmarked text is black on white
485
   }
485
   }
486
-  u8g.setPrintPos((START_ROW) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
486
+  u8g.setPrintPos((START_COL) * (DOG_CHAR_WIDTH), (row + 1) * (DOG_CHAR_HEIGHT));
487
 }
487
 }
488
 
488
 
489
 #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
489
 #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
490
 
490
 
491
-  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char* valstr=NULL, bool center=true) {
491
+  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char* valstr=NULL) {
492
+
493
+    lcd_implementation_mark_as_selected(row, invert);
494
+
492
     char c;
495
     char c;
493
-    int8_t n = LCD_WIDTH;
494
-    u8g.setPrintPos(0, (row + 1) * (DOG_CHAR_HEIGHT));
495
-    u8g.setColorIndex(1); // normal text
496
+    int8_t n = LCD_WIDTH - (START_COL);
497
+
496
     if (center && !valstr) {
498
     if (center && !valstr) {
497
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
499
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
498
       while (--pad >= 0) { lcd_print(' '); n--; }
500
       while (--pad >= 0) { lcd_print(' '); n--; }
499
     }
501
     }
500
-    while (c = pgm_read_byte(pstr)) {
502
+    while (n > 0 && (c = pgm_read_byte(pstr))) {
501
       n -= lcd_print(c);
503
       n -= lcd_print(c);
502
       pstr++;
504
       pstr++;
503
     }
505
     }
504
-    if (valstr) {
505
-      lcd_print(valstr);
506
-      n -= lcd_strlen(valstr);
506
+    if (valstr) while (n > 0 && (c = *valstr)) {
507
+      n -= lcd_print(c);
508
+      valstr++;
507
     }
509
     }
508
     while (n-- > 0) lcd_print(' ');
510
     while (n-- > 0) lcd_print(' ');
509
   }
511
   }
514
   UNUSED(pre_char);
516
   UNUSED(pre_char);
515
 
517
 
516
   char c;
518
   char c;
517
-  uint8_t n = LCD_WIDTH - 2;
519
+  uint8_t n = LCD_WIDTH - (START_COL) - 2;
518
 
520
 
519
   lcd_implementation_mark_as_selected(row, isSelected);
521
   lcd_implementation_mark_as_selected(row, isSelected);
520
 
522
 
531
 static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
533
 static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
532
   char c;
534
   char c;
533
   uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
535
   uint8_t vallen = (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
534
-  uint8_t n = LCD_WIDTH - 2 - vallen;
536
+  uint8_t n = LCD_WIDTH - (START_COL) - 2 - vallen;
535
 
537
 
536
   lcd_implementation_mark_as_selected(row, isSelected);
538
   lcd_implementation_mark_as_selected(row, isSelected);
537
 
539
 
571
 
573
 
572
 void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
574
 void lcd_implementation_drawedit(const char* pstr, const char* value=NULL) {
573
   uint8_t rows = 1;
575
   uint8_t rows = 1;
574
-  uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
576
+  uint8_t lcd_width = LCD_WIDTH - (START_COL), char_width = DOG_CHAR_WIDTH;
575
   uint8_t vallen = lcd_strlen(value);
577
   uint8_t vallen = lcd_strlen(value);
576
 
578
 
577
   #if ENABLED(USE_BIG_EDIT_FONT)
579
   #if ENABLED(USE_BIG_EDIT_FONT)
605
   static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
607
   static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char* const longFilename, bool isDir) {
606
     UNUSED(pstr);
608
     UNUSED(pstr);
607
     char c;
609
     char c;
608
-    uint8_t n = LCD_WIDTH - 1;
610
+    uint8_t n = LCD_WIDTH - (START_COL) - 1;
609
 
611
 
610
     if (longFilename[0]) {
612
     if (longFilename[0]) {
611
       filename = longFilename;
613
       filename = longFilename;

+ 102
- 78
Marlin/ultralcd.cpp View File

214
    * START_SCREEN generates the init code for a screen function
214
    * START_SCREEN generates the init code for a screen function
215
    *
215
    *
216
    *   encoderLine is the position based on the encoder
216
    *   encoderLine is the position based on the encoder
217
-   *   currentMenuViewOffset is the top menu line to display
218
-   *   _drawLineNr is the index of the LCD line (0-3)
219
-   *   _lineNr is the menu item to draw and process
220
-   *   _menuItemNr is the index of each MENU_ITEM
217
+   *   encoderTopLine is the top menu line to display
218
+   *   _lcdLineNr is the index of the LCD line (e.g., 0-3)
219
+   *   _menuLineNr is the menu item to draw and process
220
+   *   _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
221
    */
221
    */
222
-  #define _START_SCREEN(CODE) do { \
222
+  #define _START_SCREEN(CODE) \
223
     ENCODER_DIRECTION_MENUS(); \
223
     ENCODER_DIRECTION_MENUS(); \
224
     encoderRateMultiplierEnabled = false; \
224
     encoderRateMultiplierEnabled = false; \
225
     if (encoderPosition > 0x8000) encoderPosition = 0; \
225
     if (encoderPosition > 0x8000) encoderPosition = 0; \
226
-    uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
227
-    NOMORE(currentMenuViewOffset, encoderLine); \
228
-    uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
226
+    int8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
227
+    NOMORE(encoderTopLine, encoderLine); \
228
+    int8_t _menuLineNr = encoderTopLine, _thisItemNr; \
229
     CODE; \
229
     CODE; \
230
-    for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
231
-      _menuItemNr = 0;
230
+    for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
231
+      _thisItemNr = 0;
232
 
232
 
233
   #define START_SCREEN() _START_SCREEN(0)
233
   #define START_SCREEN() _START_SCREEN(0)
234
 
234
 
260
    *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
260
    *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
261
    *
261
    *
262
    */
262
    */
263
-  #define _MENU_ITEM_PART_1(type, label, args...) \
264
-    if (_menuItemNr == _lineNr) { \
263
+  #define _MENU_ITEM_PART_1(TYPE, LABEL, ARGS...) \
264
+    if (_menuLineNr == _thisItemNr) { \
265
       if (lcdDrawUpdate) \
265
       if (lcdDrawUpdate) \
266
-        lcd_implementation_drawmenu_ ## type(encoderLine == _menuItemNr, _drawLineNr, PSTR(label), ## args); \
267
-      if (wasClicked && encoderLine == _menuItemNr) { \
266
+        lcd_implementation_drawmenu_ ## TYPE(encoderLine == _thisItemNr, _lcdLineNr, PSTR(LABEL), ## ARGS); \
267
+      if (wasClicked && encoderLine == _thisItemNr) { \
268
         lcd_quick_feedback()
268
         lcd_quick_feedback()
269
 
269
 
270
-  #define _MENU_ITEM_PART_2(type, args...) \
271
-        menu_action_ ## type(args); \
270
+  #define _MENU_ITEM_PART_2(TYPE, ARGS...) \
271
+        menu_action_ ## TYPE(ARGS); \
272
         return; \
272
         return; \
273
       } \
273
       } \
274
     } \
274
     } \
275
-    _menuItemNr++
275
+    _thisItemNr++
276
 
276
 
277
-  #define MENU_ITEM(type, label, args...) do { \
278
-      _MENU_ITEM_PART_1(type, label, ## args); \
279
-      _MENU_ITEM_PART_2(type, ## args); \
277
+  #define MENU_ITEM(TYPE, LABEL, ARGS...) do { \
278
+      _MENU_ITEM_PART_1(TYPE, LABEL, ## ARGS); \
279
+      _MENU_ITEM_PART_2(TYPE, ## ARGS); \
280
     } while(0)
280
     } while(0)
281
 
281
 
282
   // Used to print static text with no visible cursor.
282
   // Used to print static text with no visible cursor.
283
-  #define STATIC_ITEM(label, args...) \
284
-    if (_menuItemNr == _lineNr) { \
285
-      if (encoderLine == _menuItemNr && _menuItemNr < LCD_HEIGHT - 1) \
283
+  #define STATIC_ITEM(LABEL, ARGS...) \
284
+    if (_menuLineNr == _thisItemNr) { \
285
+      if (encoderLine == _thisItemNr && _thisItemNr < LCD_HEIGHT - 1) { \
286
         encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
286
         encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
287
+        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
288
+      } \
287
       if (lcdDrawUpdate) \
289
       if (lcdDrawUpdate) \
288
-        lcd_implementation_drawmenu_static(_drawLineNr, PSTR(label), ## args); \
290
+        lcd_implementation_drawmenu_static(_lcdLineNr, PSTR(LABEL), ## ARGS); \
289
     } \
291
     } \
290
-    _menuItemNr++
292
+    _thisItemNr++
291
 
293
 
294
+  /**
295
+   *
296
+   * END_SCREEN  Closing code for a screen having only static items.
297
+   *             Do simplified scrolling of the entire screen.
298
+   *
299
+   * END_MENU    Closing code for a screen with menu items.
300
+   *             Scroll as-needed to keep the selected line in view.
301
+   *
302
+   * At this point _thisItemNr equals the total number of items.
303
+   * 
304
+   */
305
+
306
+  // Simple-scroll by using encoderLine as encoderTopLine
292
   #define END_SCREEN() \
307
   #define END_SCREEN() \
293
-      if (encoderLine >= _menuItemNr) { \
294
-        encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; \
295
-        encoderLine = _menuItemNr - 1; \
296
-      } \
297
-      if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { \
298
-        currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; \
299
-        lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
300
-        _lineNr = currentMenuViewOffset - 1; \
301
-        _drawLineNr = -1; \
302
-      } \
303
-    } } while(0)
308
+    } \
309
+    NOMORE(encoderLine, _thisItemNr - LCD_HEIGHT); \
310
+    NOLESS(encoderLine, 0); \
311
+    encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \
312
+    if (encoderTopLine != encoderLine) { \
313
+      encoderTopLine = encoderLine; \
314
+      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
315
+    }
304
 
316
 
305
-  #define END_MENU() END_SCREEN()
317
+  // Scroll through menu items, scrolling as-needed to stay in view
318
+  #define END_MENU() \
319
+    } \
320
+    if (encoderLine >= _thisItemNr) { \
321
+      encoderLine = _thisItemNr - 1; \
322
+      encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM); \
323
+    } \
324
+    if (encoderLine >= encoderTopLine + LCD_HEIGHT) { \
325
+      encoderTopLine = encoderLine - (LCD_HEIGHT - 1); \
326
+      lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
327
+    }
306
 
328
 
307
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
329
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
308
 
330
 
320
 
342
 
321
   #endif //ENCODER_RATE_MULTIPLIER
343
   #endif //ENCODER_RATE_MULTIPLIER
322
 
344
 
323
-  #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
345
+  #define MENU_ITEM_DUMMY() do { _thisItemNr++; } while(0)
324
   #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
346
   #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
325
   #define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
347
   #define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
326
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
348
   #if ENABLED(ENCODER_RATE_MULTIPLIER)
340
   #if ENABLED(LCD_HAS_SLOW_BUTTONS)
362
   #if ENABLED(LCD_HAS_SLOW_BUTTONS)
341
     volatile uint8_t slow_buttons; // Bits of the pressed buttons.
363
     volatile uint8_t slow_buttons; // Bits of the pressed buttons.
342
   #endif
364
   #endif
343
-  uint8_t currentMenuViewOffset;              /* scroll offset in the current menu */
365
+  int8_t encoderTopLine;              /* scroll offset in the current menu */
344
   millis_t next_button_update_ms;
366
   millis_t next_button_update_ms;
345
   uint8_t lastEncoderBits;
367
   uint8_t lastEncoderBits;
346
   uint32_t encoderPosition;
368
   uint32_t encoderPosition;
376
     if (currentScreen != screen) {
398
     if (currentScreen != screen) {
377
       currentScreen = screen;
399
       currentScreen = screen;
378
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
400
       lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
401
+      encoderTopLine = 0;
379
       #if ENABLED(NEWPANEL)
402
       #if ENABLED(NEWPANEL)
380
         encoderPosition = encoder;
403
         encoderPosition = encoder;
381
         if (feedback) lcd_quick_feedback();
404
         if (feedback) lcd_quick_feedback();
654
     long babysteps_done = 0;
677
     long babysteps_done = 0;
655
 
678
 
656
     static void _lcd_babystep(const AxisEnum axis, const char* msg) {
679
     static void _lcd_babystep(const AxisEnum axis, const char* msg) {
680
+      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
657
       ENCODER_DIRECTION_NORMAL();
681
       ENCODER_DIRECTION_NORMAL();
658
       if (encoderPosition) {
682
       if (encoderPosition) {
659
         int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
683
         int babystep_increment = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
666
         lcd_implementation_drawedit(msg, ftostr43sign(
690
         lcd_implementation_drawedit(msg, ftostr43sign(
667
           ((1000 * babysteps_done) / planner.axis_steps_per_mm[axis]) * 0.001f
691
           ((1000 * babysteps_done) / planner.axis_steps_per_mm[axis]) * 0.001f
668
         ));
692
         ));
669
-      if (LCD_CLICKED) lcd_goto_previous_menu(true);
670
     }
693
     }
671
 
694
 
672
     #if ENABLED(BABYSTEP_XY)
695
     #if ENABLED(BABYSTEP_XY)
1321
   float move_menu_scale;
1344
   float move_menu_scale;
1322
 
1345
 
1323
   static void _lcd_move_xyz(const char* name, AxisEnum axis, float min, float max) {
1346
   static void _lcd_move_xyz(const char* name, AxisEnum axis, float min, float max) {
1347
+    if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1324
     ENCODER_DIRECTION_NORMAL();
1348
     ENCODER_DIRECTION_NORMAL();
1325
     if (encoderPosition) {
1349
     if (encoderPosition) {
1326
       refresh_cmd_timeout();
1350
       refresh_cmd_timeout();
1332
       lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1356
       lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1333
     }
1357
     }
1334
     if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr41sign(current_position[axis]));
1358
     if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr41sign(current_position[axis]));
1335
-    if (LCD_CLICKED) lcd_goto_previous_menu(true);
1336
   }
1359
   }
1337
   #if ENABLED(DELTA)
1360
   #if ENABLED(DELTA)
1338
     static float delta_clip_radius_2 =  (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS);
1361
     static float delta_clip_radius_2 =  (DELTA_PRINTABLE_RADIUS) * (DELTA_PRINTABLE_RADIUS);
1349
       int8_t eindex = -1
1372
       int8_t eindex = -1
1350
     #endif
1373
     #endif
1351
   ) {
1374
   ) {
1375
+    if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1352
     ENCODER_DIRECTION_NORMAL();
1376
     ENCODER_DIRECTION_NORMAL();
1353
     if (encoderPosition) {
1377
     if (encoderPosition) {
1354
       current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1378
       current_position[E_AXIS] += float((int32_t)encoderPosition) * move_menu_scale;
1378
       #endif //EXTRUDERS > 1
1402
       #endif //EXTRUDERS > 1
1379
       lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]));
1403
       lcd_implementation_drawedit(pos_label, ftostr41sign(current_position[E_AXIS]));
1380
     }
1404
     }
1381
-    if (LCD_CLICKED) lcd_goto_previous_menu(true);
1382
   }
1405
   }
1383
 
1406
 
1384
   #if EXTRUDERS > 1
1407
   #if EXTRUDERS > 1
1837
    */
1860
    */
1838
   #if HAS_LCD_CONTRAST
1861
   #if HAS_LCD_CONTRAST
1839
     static void lcd_set_contrast() {
1862
     static void lcd_set_contrast() {
1863
+      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1840
       ENCODER_DIRECTION_NORMAL();
1864
       ENCODER_DIRECTION_NORMAL();
1841
       if (encoderPosition) {
1865
       if (encoderPosition) {
1842
         set_lcd_contrast(lcd_contrast + encoderPosition);
1866
         set_lcd_contrast(lcd_contrast + encoderPosition);
1852
           #endif
1876
           #endif
1853
         );
1877
         );
1854
       }
1878
       }
1855
-      if (LCD_CLICKED) lcd_goto_previous_menu(true);
1856
     }
1879
     }
1857
   #endif // HAS_LCD_CONTRAST
1880
   #endif // HAS_LCD_CONTRAST
1858
 
1881
 
1886
     #if !PIN_EXISTS(SD_DETECT)
1909
     #if !PIN_EXISTS(SD_DETECT)
1887
       static void lcd_sd_refresh() {
1910
       static void lcd_sd_refresh() {
1888
         card.initsd();
1911
         card.initsd();
1889
-        currentMenuViewOffset = 0;
1912
+        encoderTopLine = 0;
1890
       }
1913
       }
1891
     #endif
1914
     #endif
1892
 
1915
 
1893
     static void lcd_sd_updir() {
1916
     static void lcd_sd_updir() {
1894
       card.updir();
1917
       card.updir();
1895
-      currentMenuViewOffset = 0;
1918
+      encoderTopLine = 0;
1896
     }
1919
     }
1897
 
1920
 
1898
     /**
1921
     /**
1917
       }
1940
       }
1918
 
1941
 
1919
       for (uint16_t i = 0; i < fileCnt; i++) {
1942
       for (uint16_t i = 0; i < fileCnt; i++) {
1920
-        if (_menuItemNr == _lineNr) {
1943
+        if (_menuLineNr == _thisItemNr) {
1921
           card.getfilename(
1944
           card.getfilename(
1922
              #if ENABLED(SDCARD_RATHERRECENTFIRST)
1945
              #if ENABLED(SDCARD_RATHERRECENTFIRST)
1923
                fileCnt-1 -
1946
                fileCnt-1 -
1944
     #if ENABLED(PRINTCOUNTER)
1967
     #if ENABLED(PRINTCOUNTER)
1945
       /**
1968
       /**
1946
        *
1969
        *
1947
-       * About Printer > Stastics submenu
1970
+       * About Printer > Statistics submenu
1948
        *
1971
        *
1949
        */
1972
        */
1950
       static void lcd_info_stats_menu() {
1973
       static void lcd_info_stats_menu() {
1974
+        if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1975
+
1951
         PrintCounter print_job_counter = PrintCounter();
1976
         PrintCounter print_job_counter = PrintCounter();
1952
         print_job_counter.loadStats();
1977
         print_job_counter.loadStats();
1953
         printStatistics stats = print_job_counter.getStats();
1978
         printStatistics stats = print_job_counter.getStats();
1955
         char printTime[6];
1980
         char printTime[6];
1956
         sprintf(printTime, "%02d:%02d", int(stats.printTime / 3600), int(stats.printTime / 60) % 60);
1981
         sprintf(printTime, "%02d:%02d", int(stats.printTime / 3600), int(stats.printTime / 60) % 60);
1957
 
1982
 
1958
-        if (LCD_CLICKED) lcd_goto_previous_menu(true);
1959
         START_SCREEN();
1983
         START_SCREEN();
1960
-        STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", itostr3left(stats.totalPrints));        // Print Count : 999
1961
-        STATIC_ITEM(MSG_INFO_FINISHED_PRINTS ": ", itostr3left(stats.finishedPrints)); // Finished    : 666
1962
-        STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", printTime);                              // Total Time  : 12:34
1984
+        STATIC_ITEM(MSG_INFO_PRINT_COUNT ": ", false, false, itostr3left(stats.totalPrints));        // Print Count : 999
1985
+        STATIC_ITEM(MSG_INFO_FINISHED_PRINTS ": ", false, false, itostr3left(stats.finishedPrints)); // Finished    : 666
1986
+        STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", false, false, printTime);                              // Total Time  : 12:34
1963
         END_SCREEN();
1987
         END_SCREEN();
1964
       }
1988
       }
1965
     #endif // PRINTCOUNTER
1989
     #endif // PRINTCOUNTER
1970
      *
1994
      *
1971
      */
1995
      */
1972
     static void lcd_info_thermistors_menu() {
1996
     static void lcd_info_thermistors_menu() {
1973
-      if (LCD_CLICKED) lcd_goto_previous_menu(true);
1997
+      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
1974
       START_SCREEN();
1998
       START_SCREEN();
1975
       #define THERMISTOR_ID TEMP_SENSOR_0
1999
       #define THERMISTOR_ID TEMP_SENSOR_0
1976
       #include "thermistornames.h"
2000
       #include "thermistornames.h"
1977
-      STATIC_ITEM("T0: " THERMISTOR_NAME);
1978
-      STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_0_MINTEMP));
1979
-      STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_0_MAXTEMP));
2001
+      STATIC_ITEM("T0: " THERMISTOR_NAME, false, true);
2002
+      STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_0_MINTEMP), false);
2003
+      STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_0_MAXTEMP), false);
1980
 
2004
 
1981
       #if TEMP_SENSOR_1 != 0
2005
       #if TEMP_SENSOR_1 != 0
1982
         #undef THERMISTOR_ID
2006
         #undef THERMISTOR_ID
1983
         #define THERMISTOR_ID TEMP_SENSOR_1
2007
         #define THERMISTOR_ID TEMP_SENSOR_1
1984
         #include "thermistornames.h"
2008
         #include "thermistornames.h"
1985
-        STATIC_ITEM("T1: " THERMISTOR_NAME);
1986
-        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_1_MINTEMP));
1987
-        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_1_MAXTEMP));
2009
+        STATIC_ITEM("T1: " THERMISTOR_NAME, false, true);
2010
+        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_1_MINTEMP), false);
2011
+        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_1_MAXTEMP), false);
1988
       #endif
2012
       #endif
1989
 
2013
 
1990
       #if TEMP_SENSOR_2 != 0
2014
       #if TEMP_SENSOR_2 != 0
1991
         #undef THERMISTOR_ID
2015
         #undef THERMISTOR_ID
1992
         #define THERMISTOR_ID TEMP_SENSOR_2
2016
         #define THERMISTOR_ID TEMP_SENSOR_2
1993
         #include "thermistornames.h"
2017
         #include "thermistornames.h"
1994
-        STATIC_ITEM("T2: " THERMISTOR_NAME);
1995
-        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_2_MINTEMP));
1996
-        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_2_MAXTEMP));
2018
+        STATIC_ITEM("T2: " THERMISTOR_NAME, false, true);
2019
+        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_2_MINTEMP), false);
2020
+        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_2_MAXTEMP), false);
1997
       #endif
2021
       #endif
1998
 
2022
 
1999
       #if TEMP_SENSOR_3 != 0
2023
       #if TEMP_SENSOR_3 != 0
2000
         #undef THERMISTOR_ID
2024
         #undef THERMISTOR_ID
2001
         #define THERMISTOR_ID TEMP_SENSOR_3
2025
         #define THERMISTOR_ID TEMP_SENSOR_3
2002
         #include "thermistornames.h"
2026
         #include "thermistornames.h"
2003
-        STATIC_ITEM("T3: " THERMISTOR_NAME);
2004
-        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_3_MINTEMP));
2005
-        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_3_MAXTEMP));
2027
+        STATIC_ITEM("T3: " THERMISTOR_NAME, false, true);
2028
+        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(HEATER_3_MINTEMP), false);
2029
+        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(HEATER_3_MAXTEMP), false);
2006
       #endif
2030
       #endif
2007
 
2031
 
2008
       #if TEMP_SENSOR_BED != 0
2032
       #if TEMP_SENSOR_BED != 0
2009
         #undef THERMISTOR_ID
2033
         #undef THERMISTOR_ID
2010
         #define THERMISTOR_ID TEMP_SENSOR_BED
2034
         #define THERMISTOR_ID TEMP_SENSOR_BED
2011
         #include "thermistornames.h"
2035
         #include "thermistornames.h"
2012
-        STATIC_ITEM("TBed:" THERMISTOR_NAME);
2013
-        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(BED_MINTEMP));
2014
-        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(BED_MAXTEMP));
2036
+        STATIC_ITEM("TBed:" THERMISTOR_NAME, false, true);
2037
+        STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(BED_MINTEMP), false);
2038
+        STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(BED_MAXTEMP), false);
2015
       #endif
2039
       #endif
2016
       END_SCREEN();
2040
       END_SCREEN();
2017
     }
2041
     }
2022
      *
2046
      *
2023
      */
2047
      */
2024
     static void lcd_info_board_menu() {
2048
     static void lcd_info_board_menu() {
2025
-      if (LCD_CLICKED) lcd_goto_previous_menu(true);
2049
+      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2026
       START_SCREEN();
2050
       START_SCREEN();
2027
-      STATIC_ITEM(BOARD_NAME);                                 // MyPrinterController
2051
+      STATIC_ITEM(BOARD_NAME, true, true);                     // MyPrinterController
2028
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE)); // Baud: 250000
2052
       STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE)); // Baud: 250000
2029
       STATIC_ITEM(MSG_INFO_PROTOCOL ": " PROTOCOL_VERSION);    // Protocol: 1.0
2053
       STATIC_ITEM(MSG_INFO_PROTOCOL ": " PROTOCOL_VERSION);    // Protocol: 1.0
2030
       #ifdef POWER_SUPPLY
2054
       #ifdef POWER_SUPPLY
2043
      *
2067
      *
2044
      */
2068
      */
2045
     static void lcd_info_printer_menu() {
2069
     static void lcd_info_printer_menu() {
2046
-      if (LCD_CLICKED) lcd_goto_previous_menu(true);
2070
+      if (LCD_CLICKED) { lcd_goto_previous_menu(true); return; }
2047
       START_SCREEN();
2071
       START_SCREEN();
2048
-      STATIC_ITEM(MSG_MARLIN);                                   // Marlin
2072
+      STATIC_ITEM(MSG_MARLIN, true, true);                       // Marlin
2049
       STATIC_ITEM(SHORT_BUILD_VERSION);                          // x.x.x-Branch
2073
       STATIC_ITEM(SHORT_BUILD_VERSION);                          // x.x.x-Branch
2050
       STATIC_ITEM(STRING_DISTRIBUTION_DATE);                     // YYYY-MM-DD HH:MM
2074
       STATIC_ITEM(STRING_DISTRIBUTION_DATE);                     // YYYY-MM-DD HH:MM
2051
       STATIC_ITEM(MACHINE_NAME);                                 // My3DPrinter
2075
       STATIC_ITEM(MACHINE_NAME);                                 // My3DPrinter
2087
     static void lcd_filament_change_option_menu() {
2111
     static void lcd_filament_change_option_menu() {
2088
       START_MENU();
2112
       START_MENU();
2089
       #if LCD_HEIGHT > 2
2113
       #if LCD_HEIGHT > 2
2090
-        STATIC_ITEM(MSG_FILAMENT_CHANGE_OPTION_HEADER);
2114
+        STATIC_ITEM(MSG_FILAMENT_CHANGE_OPTION_HEADER, true, false);
2091
       #endif
2115
       #endif
2092
       MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_RESUME, lcd_filament_change_resume_print);
2116
       MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_RESUME, lcd_filament_change_resume_print);
2093
       MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_EXTRUDE, lcd_filament_change_extrude_more);
2117
       MENU_ITEM(function, MSG_FILAMENT_CHANGE_OPTION_EXTRUDE, lcd_filament_change_extrude_more);
2096
 
2120
 
2097
     static void lcd_filament_change_init_message() {
2121
     static void lcd_filament_change_init_message() {
2098
       START_SCREEN();
2122
       START_SCREEN();
2099
-      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2123
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true);
2100
       STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_1);
2124
       STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_1);
2101
       #ifdef MSG_FILAMENT_CHANGE_INIT_2
2125
       #ifdef MSG_FILAMENT_CHANGE_INIT_2
2102
         STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_2);
2126
         STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_2);
2109
 
2133
 
2110
     static void lcd_filament_change_unload_message() {
2134
     static void lcd_filament_change_unload_message() {
2111
       START_SCREEN();
2135
       START_SCREEN();
2112
-      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2136
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true);
2113
       STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_1);
2137
       STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_1);
2114
       #ifdef MSG_FILAMENT_CHANGE_UNLOAD_2
2138
       #ifdef MSG_FILAMENT_CHANGE_UNLOAD_2
2115
         STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_2);
2139
         STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_2);
2122
 
2146
 
2123
     static void lcd_filament_change_insert_message() {
2147
     static void lcd_filament_change_insert_message() {
2124
       START_SCREEN();
2148
       START_SCREEN();
2125
-      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2149
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true);
2126
       STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_1);
2150
       STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_1);
2127
       #ifdef MSG_FILAMENT_CHANGE_INSERT_2
2151
       #ifdef MSG_FILAMENT_CHANGE_INSERT_2
2128
         STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_2);
2152
         STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_2);
2135
 
2159
 
2136
     static void lcd_filament_change_load_message() {
2160
     static void lcd_filament_change_load_message() {
2137
       START_SCREEN();
2161
       START_SCREEN();
2138
-      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2162
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true);
2139
       STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_1);
2163
       STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_1);
2140
       #ifdef MSG_FILAMENT_CHANGE_LOAD_2
2164
       #ifdef MSG_FILAMENT_CHANGE_LOAD_2
2141
         STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_2);
2165
         STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_2);
2148
 
2172
 
2149
     static void lcd_filament_change_extrude_message() {
2173
     static void lcd_filament_change_extrude_message() {
2150
       START_SCREEN();
2174
       START_SCREEN();
2151
-      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2175
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true);
2152
       STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_1);
2176
       STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_1);
2153
       #ifdef MSG_FILAMENT_CHANGE_EXTRUDE_2
2177
       #ifdef MSG_FILAMENT_CHANGE_EXTRUDE_2
2154
         STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_2);
2178
         STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_2);
2161
 
2185
 
2162
     static void lcd_filament_change_resume_message() {
2186
     static void lcd_filament_change_resume_message() {
2163
       START_SCREEN();
2187
       START_SCREEN();
2164
-      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
2188
+      STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, true, true);
2165
       STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_1);
2189
       STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_1);
2166
       #ifdef MSG_FILAMENT_CHANGE_RESUME_2
2190
       #ifdef MSG_FILAMENT_CHANGE_RESUME_2
2167
         STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_2);
2191
         STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_2);

+ 6
- 5
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

830
 
830
 
831
 #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
831
 #if ENABLED(LCD_INFO_MENU) || ENABLED(FILAMENT_CHANGE_FEATURE)
832
 
832
 
833
-  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, const char *valstr=NULL, bool center=true) {
833
+  static void lcd_implementation_drawmenu_static(uint8_t row, const char* pstr, bool center=true, bool invert=false, const char *valstr=NULL) {
834
+    UNUSED(invert);
834
     char c;
835
     char c;
835
     int8_t n = LCD_WIDTH;
836
     int8_t n = LCD_WIDTH;
836
     lcd.setCursor(0, row);
837
     lcd.setCursor(0, row);
838
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
839
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
839
       while (--pad >= 0) { lcd.print(' '); n--; }
840
       while (--pad >= 0) { lcd.print(' '); n--; }
840
     }
841
     }
841
-    while ((c = pgm_read_byte(pstr)) && n > 0) {
842
+    while (n > 0 && (c = pgm_read_byte(pstr))) {
842
       n -= lcd_print(c);
843
       n -= lcd_print(c);
843
       pstr++;
844
       pstr++;
844
     }
845
     }
845
-    if (valstr) {
846
-      lcd_print(valstr);
847
-      n -= lcd_strlen(valstr);
846
+    if (valstr) while (n > 0 && (c = *valstr)) {
847
+      n -= lcd_print(c);
848
+      valstr++;
848
     }
849
     }
849
     while (n-- > 0) lcd.print(' ');
850
     while (n-- > 0) lcd.print(' ');
850
   }
851
   }

Loading…
Cancel
Save