From 4472ba2b6bc0835d0fcc039ad66d9dab40e13010 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Jan 2021 18:08:16 -0600 Subject: [PATCH] Ok to use C++11 'auto' --- Marlin/src/lcd/dwin/e3v2/dwin.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Marlin/src/lcd/dwin/e3v2/dwin.cpp b/Marlin/src/lcd/dwin/e3v2/dwin.cpp index 5adf6e8ab..ca1d7223f 100644 --- a/Marlin/src/lcd/dwin/e3v2/dwin.cpp +++ b/Marlin/src/lcd/dwin/e3v2/dwin.cpp @@ -497,21 +497,13 @@ inline void Draw_Back_First(const bool is_sel=true) { if (is_sel) Draw_Menu_Cursor(0); } -#define APPLY_ENCODER_F \ - if (encoder_diffState == ENCODER_DIFF_CW) \ - valref += EncoderRate.encoderMoveValue; \ - else if (encoder_diffState == ENCODER_DIFF_CCW) \ - valref -= EncoderRate.encoderMoveValue; \ - else if (encoder_diffState == ENCODER_DIFF_ENTER) \ - return true; \ - return false; - -inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, int16_t &valref) { - APPLY_ENCODER_F -} - -inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, float &valref) { - APPLY_ENCODER_F +inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, auto &valref) { + if (encoder_diffState == ENCODER_DIFF_CW) + valref += EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_CCW) + valref -= EncoderRate.encoderMoveValue; + else if (encoder_diffState == ENCODER_DIFF_ENTER) + return true; } //