ソースを参照

Fixes issue #1447 - Overlapping of long descriptions with values.

AnHardt 10年前
コミット
9381bfe7f9
1個のファイルの変更23行の追加6行の削除
  1. 23
    6
      Marlin/dogm_lcd_implementation.h

+ 23
- 6
Marlin/dogm_lcd_implementation.h ファイルの表示

@@ -51,7 +51,7 @@
51 51
 #endif
52 52
 */
53 53
 
54
-#define USE_BIG_EDIT_FONT
54
+#define USE_BIG_EDIT_FONT                // save 3120 bytes of PROGMEM by commenting out this line
55 55
 #define FONT_STATUSMENU u8g_font_6x9
56 56
 #define FONT_MENU u8g_font_6x10_marlin
57 57
 
@@ -65,9 +65,9 @@
65 65
   #define LCD_WIDTH_EDIT       14
66 66
 #else
67 67
   #define FONT_MENU_EDIT u8g_font_6x10_marlin
68
-  #define DOG_CHAR_WIDTH_EDIT 6
68
+  #define DOG_CHAR_WIDTH_EDIT  6
69 69
   #define DOG_CHAR_HEIGHT_EDIT 12
70
-  #define LCD_WIDTH_EDIT 22
70
+  #define LCD_WIDTH_EDIT       22
71 71
 #endif
72 72
 
73 73
 #define START_ROW              0
@@ -375,11 +375,28 @@ static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char p
375 375
 #define lcd_implementation_drawmenu_setting_edit_callback_bool(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
376 376
 
377 377
 void lcd_implementation_drawedit(const char* pstr, char* value) {
378
-  u8g.setPrintPos(0 * DOG_CHAR_WIDTH_EDIT, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_EDIT) - (1 * DOG_CHAR_HEIGHT_EDIT) - START_ROW );
379
-  u8g.setFont(FONT_MENU_EDIT);
378
+  uint8_t rows = 1;
379
+  uint8_t lcd_width = LCD_WIDTH;
380
+  uint8_t char_width = DOG_CHAR_WIDTH;
381
+
382
+#ifdef USE_BIG_EDIT_FONT
383
+  if (strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
384
+    u8g.setFont(FONT_MENU_EDIT);
385
+    lcd_width = LCD_WIDTH_EDIT + 1;
386
+    char_width = DOG_CHAR_WIDTH_EDIT;
387
+    if (strlen_P(pstr) >= LCD_WIDTH_EDIT - strlen(value)) rows = 2;
388
+  }
389
+  else {
390
+    u8g.setFont(FONT_MENU);
391
+  }
392
+#endif
393
+
394
+  if ( strlen_P(pstr) > LCD_WIDTH - 2 - strlen(value) ) rows = 2;
395
+
396
+  u8g.setPrintPos(                                     0, u8g.getHeight() *  1/(1+rows) + DOG_CHAR_HEIGHT_EDIT/2); //1/(1+rows) = 1/2 or 1/3
380 397
   lcd_printPGM(pstr);
381 398
   u8g.print(':');
382
-  u8g.setPrintPos((14 - strlen(value)) * DOG_CHAR_WIDTH_EDIT, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_EDIT) - (1 * DOG_CHAR_HEIGHT_EDIT) - START_ROW );
399
+  u8g.setPrintPos((lcd_width-1-strlen(value))*char_width, u8g.getHeight()*rows/(1+rows) + DOG_CHAR_HEIGHT_EDIT/2); //rows/(1+rows) = 1/2 or 2/3
383 400
   u8g.print(value);
384 401
 }
385 402
 

読み込み中…
キャンセル
保存