diff --git a/MicroView.cpp b/MicroView.cpp index 882d5cb..433c812 100644 --- a/MicroView.cpp +++ b/MicroView.cpp @@ -1424,11 +1424,11 @@ size_t MicroView::write(uint8_t c) { } else if (sty==WIDGETSTYLE2) { style=2; - totalTicks=30; + totalTicks=20; } else if (sty==WIDGETSTYLE3) { style=3; - totalTicks=60; + totalTicks=40; } else { //unrecognized style, so use default style=0; @@ -1450,11 +1450,17 @@ size_t MicroView::write(uint8_t c) { offsetX=getX(); offsetY=getY(); - if(style%2==1) //style 1 or 3 - majorLine=7; - else //style 0 or 2 + if(style==0) majorLine=4; - + else if (style==1) + majorLine=7; + else if (style==2) + majorLine=3; + else if (style==3) + majorLine=5; + + + //Horizontal styles, style 0 or 1 if (style==0 || style==1) { @@ -1473,7 +1479,7 @@ size_t MicroView::write(uint8_t c) { uView.lineV(offsetX+23+(i*2), offsetY+5, 3); } - if(style==1) { //Explicit test for style + if(style==1) { //Longer line, more minor ticks for (uint8_t i=0; i<4;i++) { uView.lineV(offsetX+33+(i*2), offsetY+5, 3); } @@ -1489,29 +1495,24 @@ size_t MicroView::write(uint8_t c) { else { // Draw major tickers for (uint8_t i=0; i 0) //Style 1 or Style 3 - uView.setCursor(offsetX,offsetY+10); - else //Style 0 or Style 2 + if(style==0) uView.setCursor(offsetX+34,offsetY+1); + else if (style==1) + uView.setCursor(offsetX,offsetY+10); + else if (style==2) + uView.setCursor(offsetX+1,offsetY+24); + else //style==3 + uView.setCursor(offsetX+9,offsetY); + uView.print(strBuffer); } diff --git a/vert_slider_test.ino b/vert_slider_test.ino new file mode 100644 index 0000000..e491de2 --- /dev/null +++ b/vert_slider_test.ino @@ -0,0 +1,47 @@ +#include + +int buttonPin = A0; // push button pin +int buttonState = 0; // variable for reading the pushbutton status +int onCount = 0; +MicroViewWidget *hWidget, *vWidget1, *vWidget2; + +void setup() { + uView.begin(); + uView.clear(PAGE); + + // initialize the pushbutton pin as an input: + pinMode(buttonPin, INPUT); + digitalWrite(buttonPin,HIGH); + + //Create a slider to count how long the switch is on +// hWidget = new MicroViewSlider(0, 0, 0, 99, WIDGETSTYLE0); + vWidget1 = new MicroViewSlider(0, 0, 0, 255, WIDGETSTYLE2); + vWidget2 = new MicroViewSlider(31, 0, 0, 255, WIDGETSTYLE3); +} + +void loop() { + // read the state of the pushbutton value: + buttonState = digitalRead(buttonPin); + + // check if the pushbutton is pressed. + // if it is not pressed, the buttonState is HIGH: + if (buttonState == HIGH) { + onCount = min(onCount+1, 255); +// hWidget->setValue(onCount); + vWidget1->setValue(onCount); + vWidget2->setValue(onCount); +// uView.setCursor(0,0); +// uView.print("OFF"); + uView.display(); + } + else { + onCount = max(onCount-1, 0); +// hWidget->setValue(onCount); + vWidget1->setValue(onCount); + vWidget2->setValue(onCount); +// uView.setCursor(0,0); +// uView.print("ON "); + uView.display(); + } +} +