From 77928f1b74661c16d1149766a40150f9b701aba3 Mon Sep 17 00:00:00 2001 From: Scott Allen Date: Mon, 4 Aug 2014 17:54:10 -0400 Subject: [PATCH] Fixed compiler warning in MicroViewSlider. In drawFace, majorLine could be left uninitialised if style was invalid (although this couldn't happen with the current code). Also cleaned up the WIDGETSTYLE tests. --- MicroView.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/MicroView.cpp b/MicroView.cpp index bfc1f5a..ee0a0a5 100644 --- a/MicroView.cpp +++ b/MicroView.cpp @@ -1432,11 +1432,7 @@ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_ Initialise the MicroViewSlider widget with style WIDGETSTYLE0 or WIDGETSTYLE1 or WIDGETSTYLE2 (like 0, but vertical) or WIDGETSTYLE3 (like 1, but vertical). If this list gets any longer, it might be better as a switch/case statement. */ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty):MicroViewWidget(newx, newy, min, max) { - if (sty==WIDGETSTYLE0) { - style=0; - totalTicks=30; - } - else if (sty==WIDGETSTYLE1) { + if (sty==WIDGETSTYLE1) { style=1; totalTicks=60; } @@ -1448,7 +1444,7 @@ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_ style=3; totalTicks=40; } - else { //unrecognized style, so use default + else { // Use style 0 if specified or invalid style=0; totalTicks=30; } @@ -1468,14 +1464,14 @@ void MicroViewSlider::drawFace() { offsetX=getX(); offsetY=getY(); - if(style==0) - majorLine=4; - else if (style==1) - majorLine=7; - else if (style==2) - majorLine=3; - else if (style==3) - majorLine=5; + if (style==0) + majorLine=4; + else if (style==1) + majorLine=7; + else if (style==2) + majorLine=3; + else + majorLine=5; //Horizontal styles, style 0 or 1