Browse Source

Ok to use C++11 'auto'

Scott Lahteine 4 years ago
parent
commit
4472ba2b6b
1 changed files with 7 additions and 15 deletions
  1. 7
    15
      Marlin/src/lcd/dwin/e3v2/dwin.cpp

+ 7
- 15
Marlin/src/lcd/dwin/e3v2/dwin.cpp View File

497
   if (is_sel) Draw_Menu_Cursor(0);
497
   if (is_sel) Draw_Menu_Cursor(0);
498
 }
498
 }
499
 
499
 
500
-#define APPLY_ENCODER_F \
501
-  if (encoder_diffState == ENCODER_DIFF_CW)          \
502
-    valref += EncoderRate.encoderMoveValue;          \
503
-  else if (encoder_diffState == ENCODER_DIFF_CCW)    \
504
-    valref -= EncoderRate.encoderMoveValue;          \
505
-  else if (encoder_diffState == ENCODER_DIFF_ENTER)  \
506
-    return true;                                     \
507
-  return false;
508
-
509
-inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, int16_t &valref) {
510
-  APPLY_ENCODER_F
511
-}
512
-
513
-inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, float &valref) {
514
-  APPLY_ENCODER_F
500
+inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valref) {
501
+  if (encoder_diffState == ENCODER_DIFF_CW)
502
+    valref += EncoderRate.encoderMoveValue;
503
+  else if (encoder_diffState == ENCODER_DIFF_CCW)
504
+    valref -= EncoderRate.encoderMoveValue;
505
+  else if (encoder_diffState == ENCODER_DIFF_ENTER)
506
+    return true;
515
 }
507
 }
516
 
508
 
517
 //
509
 //

Loading…
Cancel
Save