From f26b8685bc15f312efcde82d03b050c0d96cd02b Mon Sep 17 00:00:00 2001 From: Ivan Zorin Date: Mon, 17 Jul 2023 03:58:13 +0300 Subject: [PATCH] OLED::printSymbolDeg(): attempt to improve read-ability replacing if/else by switch/case --- source/Core/Drivers/OLED.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 3c8b5f8f7..f54f8420c 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -483,14 +483,17 @@ void OLED::printWholeScreen(const char *string) { // Print *F or *C - in font style of Small, Large (by default) or Extra based on input arg void OLED::printSymbolDeg(const FontStyle fontStyle) { - if (FontStyle::EXTRAS == fontStyle) { + switch (fontStyle) { + case FontStyle::EXTRAS: OLED::drawSymbol(getSettingValue(SettingsOptions::TemperatureInF) ? 0 : 1); - } else { - if (getSettingValue(SettingsOptions::TemperatureInF)) { - OLED::print(fontStyle == FontStyle::LARGE ? LargeSymbolDegF : SmallSymbolDegF, fontStyle); - } else { - OLED::print(fontStyle == FontStyle::LARGE ? LargeSymbolDegC : SmallSymbolDegC, fontStyle); - } + break; + case FontStyle::LARGE: + OLED::print(getSettingValue(SettingsOptions::TemperatureInF) ? LargeSymbolDegF : LargeSymbolDegC, fontStyle); + break; + case FontStyle::SMALL: + default: + OLED::print(getSettingValue(SettingsOptions::TemperatureInF) ? SmallSymbolDegF : SmallSymbolDegC, fontStyle); + break; } }