diff --git a/MicroView.cpp b/MicroView.cpp index 6a12b4c..d884d9f 100644 --- a/MicroView.cpp +++ b/MicroView.cpp @@ -1411,17 +1411,29 @@ size_t MicroView::write(uint8_t c) { /** \brief MicroViewSlider class initialisation with style. - Initialise the MicroViewSlider widget with style WIDGETSTYLE0 or WIDGETSTYLE1. + 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 { + else if (sty==WIDGETSTYLE1) { style=1; totalTicks=60; } + else if (sty==WIDGETSTYLE2) { + style=2; + totalTicks=30; + } + else if (sty==WIDGETSTYLE3) { + style=3; + totalTicks=60; + } + else { //unrecognized style, so use default + style=0; + totalTicks=30; + } needFirstDraw=true; prevValue=getMinValue(); @@ -1438,31 +1450,33 @@ size_t MicroView::write(uint8_t c) { offsetX=getX(); offsetY=getY(); - if(style>0) - majorLine=7; - else - majorLine=4; + if(style%2==1) //style 1 or 3 + majorLine=7; + else //style 0 or 2 + majorLine=4; - // Draw major tickers - for (uint8_t i=0; i0) { - for (uint8_t i=0; i<4;i++) { - uView.lineV(offsetX+33+(i*2), offsetY+5, 3); +//Horizontal styles, style 0 or 1 + + if (style1==0 || style==1) { + // Draw major tickers + for (uint8_t i=0; i0) { + // Draw minor tickers + for (uint8_t i=0; i<4;i++) { + uView.lineV(offsetX+3+(i*2), offsetY+5, 3); + } + for (uint8_t i=0; i<4;i++) { + uView.lineV(offsetX+13+(i*2), offsetY+5, 3); + } + for (uint8_t i=0; i<4;i++) { + uView.lineV(offsetX+23+(i*2), offsetY+5, 3); + } + + if(style==1) { //Explicit test for style + for (uint8_t i=0; i<4;i++) { + uView.lineV(offsetX+33+(i*2), offsetY+5, 3); + } for (uint8_t i=0; i<4;i++) { uView.lineV(offsetX+43+(i*2), offsetY+5, 3); } @@ -1471,6 +1485,36 @@ size_t MicroView::write(uint8_t c) { } } } +//Vertical styles, style 2 or 3 + else { + // Draw major tickers + for (uint8_t i=0; i0) - uView.setCursor(offsetX,offsetY+10); - else - uView.setCursor(offsetX+34,offsetY+1); + if(style%2 > 0) //Style 1 or Style 3 + uView.setCursor(offsetX,offsetY+10); + else //Style 0 or Style 2 + uView.setCursor(offsetX+34,offsetY+1); uView.print(strBuffer); } @@ -1635,7 +1700,7 @@ size_t MicroView::write(uint8_t c) { } // ------------------------------------------------------------------------------------- - // Slider Widget - end + // Gauge Widget - end // ------------------------------------------------------------------------------------- /** \brief SPI Initialisation. diff --git a/MicroView.h b/MicroView.h index 4b35a31..7bd46c9 100644 --- a/MicroView.h +++ b/MicroView.h @@ -49,6 +49,8 @@ #define WIDGETSTYLE0 0 #define WIDGETSTYLE1 1 #define WIDGETSTYLE2 2 +//Added for Vertical slider styles +#define WIDGETSTYLE3 3 #define SETCONTRAST 0x81 #define DISPLAYALLONRESUME 0xA4 diff --git a/keywords.txt b/keywords.txt index a10e127..da714d1 100644 --- a/keywords.txt +++ b/keywords.txt @@ -77,5 +77,6 @@ ALL LITERAL1 WIDGETSTYLE0 LITERAL1 WIDGETSTYLE1 LITERAL1 WIDGETSTYLE2 LITERAL1 +WIDGETSTYLE3 LITERAL1