Browse Source

Apply TERN to status screen

Scott Lahteine 5 years ago
parent
commit
4cdd51cd3a
1 changed files with 7 additions and 32 deletions
  1. 7
    32
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp

+ 7
- 32
Marlin/src/lcd/dogm/status_screen_DOGM.cpp View File

305
 // Homed and known, display constantly.
305
 // Homed and known, display constantly.
306
 //
306
 //
307
 FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
307
 FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink) {
308
-  const AxisEnum a = (
309
-    #if ENABLED(LCD_SHOW_E_TOTAL)
310
-      axis == E_AXIS ? X_AXIS :
311
-    #endif
312
-    axis
313
-  );
308
+  const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
314
   const uint8_t offs = (XYZ_SPACING) * a;
309
   const uint8_t offs = (XYZ_SPACING) * a;
315
   lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, axis_codes[axis]);
310
   lcd_put_wchar(X_LABEL_POS + offs, XYZ_BASELINE, axis_codes[axis]);
316
   lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
311
   lcd_moveto(X_VALUE_POS + offs, XYZ_BASELINE);
332
 
327
 
333
 void MarlinUI::draw_status_screen() {
328
 void MarlinUI::draw_status_screen() {
334
 
329
 
335
-  static char xstring[5
336
-    #if ENABLED(LCD_SHOW_E_TOTAL)
337
-      + 7
338
-    #endif
339
-  ], ystring[5], zstring[8];
330
+  static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, 5)], ystring[5], zstring[8];
340
   #if ENABLED(FILAMENT_LCD_DISPLAY)
331
   #if ENABLED(FILAMENT_LCD_DISPLAY)
341
     static char wstring[5], mstring[4];
332
     static char wstring[5], mstring[4];
342
   #endif
333
   #endif
365
     #endif
356
     #endif
366
   #endif
357
   #endif
367
 
358
 
368
-  const bool showxy = (true
369
-    #if ENABLED(LCD_SHOW_E_TOTAL)
370
-      && !printingIsActive()
371
-    #endif
372
-  );
359
+  const bool showxy = TERN1(LCD_SHOW_E_TOTAL, !printingIsActive());
373
 
360
 
374
   // At the first page, generate new display values
361
   // At the first page, generate new display values
375
   if (first_page) {
362
   if (first_page) {
411
 
398
 
412
     // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw
399
     // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw
413
     #if HAS_PRINT_PROGRESS
400
     #if HAS_PRINT_PROGRESS
414
-      const progress_t progress =
415
-        #if HAS_PRINT_PROGRESS_PERMYRIAD
416
-          get_progress_permyriad()
417
-        #else
418
-          get_progress_percent()
419
-        #endif
420
-      ;
401
+      const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
421
       duration_t elapsed = print_job_timer.duration();
402
       duration_t elapsed = print_job_timer.duration();
422
       const uint8_t p = progress & 0xFF, ev = elapsed.value & 0xFF;
403
       const uint8_t p = progress & 0xFF, ev = elapsed.value & 0xFF;
423
       if (p != lastProgress) {
404
       if (p != lastProgress) {
433
               estimation_x_pos = _SD_INFO_X(0);
414
               estimation_x_pos = _SD_INFO_X(0);
434
             #endif
415
             #endif
435
           }
416
           }
436
-          else {
437
-            strcpy(progress_string, (
438
-              #if ENABLED(PRINT_PROGRESS_SHOW_DECIMALS)
439
-                permyriadtostr4(progress)
440
-              #else
441
-                ui8tostr3rj(progress / (PROGRESS_SCALE))
442
-              #endif
443
-            ));
444
-          }
417
+          else
418
+            strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))));
419
+
445
           #if BOTH(SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) // Tri-state progress display mode
420
           #if BOTH(SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) // Tri-state progress display mode
446
             progress_x_pos = _SD_INFO_X(strlen(progress_string) + 1);
421
             progress_x_pos = _SD_INFO_X(strlen(progress_string) + 1);
447
           #endif
422
           #endif

Loading…
Cancel
Save