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
 }
282
 }
283
 
283
 
284
 static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
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
     u8g.setColorIndex(1);  // black on white
286
     u8g.setColorIndex(1);  // black on white
287
     u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
287
     u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
288
     u8g.setColorIndex(0);  // following text must be white on black
288
     u8g.setColorIndex(0);  // following text must be white on black
351
 
351
 
352
 void lcd_implementation_drawedit(const char* pstr, char* value) {
352
 void lcd_implementation_drawedit(const char* pstr, char* value) {
353
   uint8_t rows = 1;
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
   #ifdef USE_BIG_EDIT_FONT
357
   #ifdef USE_BIG_EDIT_FONT
358
     if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
358
     if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
359
       u8g.setFont(FONT_MENU_EDIT);
359
       u8g.setFont(FONT_MENU_EDIT);
360
       lcd_width = LCD_WIDTH_EDIT + 1;
360
       lcd_width = LCD_WIDTH_EDIT + 1;
361
       char_width = DOG_CHAR_WIDTH_EDIT;
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
     else {
364
     else {
365
       u8g.setFont(FONT_MENU);
365
       u8g.setFont(FONT_MENU);
366
     }
366
     }
367
   #endif
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
   const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
371
   const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
372
   float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
372
   float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
374
   u8g.setPrintPos(0, rowHeight + kHalfChar);
374
   u8g.setPrintPos(0, rowHeight + kHalfChar);
375
   lcd_printPGM(pstr);
375
   lcd_printPGM(pstr);
376
   u8g.print(':');
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
   u8g.print(value);
378
   u8g.print(value);
379
 }
379
 }
380
 
380
 

Loading…
Cancel
Save