Browse Source

Cleanup for menu optimization

- Compare pr_char to space
- Fewer calls to lcd_strlen
Scott Lahteine 10 years ago
parent
commit
7629c4f05c
1 changed files with 6 additions and 6 deletions
  1. 6
    6
      Marlin/dogm_lcd_implementation.h

+ 6
- 6
Marlin/dogm_lcd_implementation.h View File

@@ -282,7 +282,7 @@ static void lcd_implementation_status_screen() {
282 282
 }
283 283
 
284 284
 static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
285
-  if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0])) {
285
+  if (pr_char != ' ') {
286 286
     u8g.setColorIndex(1);  // black on white
287 287
     u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
288 288
     u8g.setColorIndex(0);  // following text must be white on black
@@ -351,22 +351,22 @@ static void _drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* ps
351 351
 
352 352
 void lcd_implementation_drawedit(const char* pstr, char* value) {
353 353
   uint8_t rows = 1;
354
-  uint8_t lcd_width = LCD_WIDTH;
355
-  uint8_t char_width = DOG_CHAR_WIDTH;
354
+  uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
355
+  uint8_t vallen = lcd_strlen(value);
356 356
 
357 357
   #ifdef USE_BIG_EDIT_FONT
358 358
     if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
359 359
       u8g.setFont(FONT_MENU_EDIT);
360 360
       lcd_width = LCD_WIDTH_EDIT + 1;
361 361
       char_width = DOG_CHAR_WIDTH_EDIT;
362
-      if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - lcd_strlen(value)) rows = 2;
362
+      if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
363 363
     }
364 364
     else {
365 365
       u8g.setFont(FONT_MENU);
366 366
     }
367 367
   #endif
368 368
 
369
-  if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - lcd_strlen(value)) rows = 2;
369
+  if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
370 370
 
371 371
   const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
372 372
   float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
@@ -374,7 +374,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
374 374
   u8g.setPrintPos(0, rowHeight + kHalfChar);
375 375
   lcd_printPGM(pstr);
376 376
   u8g.print(':');
377
-  u8g.setPrintPos((lcd_width-1-lcd_strlen(value)) * char_width, rows * rowHeight + kHalfChar);
377
+  u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
378 378
   u8g.print(value);
379 379
 }
380 380
 

Loading…
Cancel
Save