6 Commits

Author SHA1 Message Date
JP
78e7abeafa merged vSlider_reverse_2 2014-08-05 09:41:47 +10:00
jpliew
0d06e90e3d Merge pull request #9 from MLXXXp/vSlider_reverse_2
Reverse direction of virtical sliders
2014-08-05 09:39:19 +10:00
Scott Allen
cc1d78384a Changed vertical slider direction.
Low values at the bottom. High values at the top.
2014-08-04 19:20:18 -04:00
Scott Allen
77928f1b74 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.
2014-08-04 17:54:10 -04:00
JP
00a80911de fixed typo 2014-08-04 21:27:06 +10:00
JP
b64d5e4417 fixed child widget double declare of reDraw() 2014-08-04 21:23:06 +10:00
3 changed files with 21 additions and 20 deletions

View File

@@ -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
@@ -1545,12 +1541,13 @@ void MicroViewSlider::draw() {
offsetY=getY();
if (needFirstDraw) {
tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
if (style==0 || style==1){ //Horizontal
tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR);
uView.pixel(offsetX+1+tickPosition,offsetY+1, WHITE, XOR);
}
else { //Vertical
tickPosition= (((float)(getMaxValue()-prevValue)/(float)(getMaxValue()-getMinValue()))*totalTicks);
uView.lineV(offsetX+7, offsetY+tickPosition, 3, WHITE, XOR);
uView.pixel(offsetX+6, offsetY+1+tickPosition, WHITE, XOR);
}
@@ -1560,23 +1557,25 @@ void MicroViewSlider::draw() {
}
else {
// Draw previous pointer in XOR mode to erase it
tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
if (style==0 || style==1){ //Horizontal
tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR);
uView.pixel(offsetX+1+tickPosition,offsetY+1, WHITE, XOR);
}
else { //Vertical
tickPosition= (((float)(getMaxValue()-prevValue)/(float)(getMaxValue()-getMinValue()))*totalTicks);
uView.lineV(offsetX+7, offsetY+tickPosition, 3, WHITE, XOR);
uView.pixel(offsetX+6, offsetY+1+tickPosition, WHITE, XOR);
}
// Draw current pointer
tickPosition= (((float)(getValue()-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
if (style==0 || style==1){ //Horizontal
tickPosition= (((float)(getValue()-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR);
uView.pixel(offsetX+1+tickPosition,offsetY+1, WHITE, XOR);
}
else { //Vertical
tickPosition= (((float)(getMaxValue()-getValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
uView.lineV(offsetX+7, offsetY+tickPosition, 3, WHITE, XOR);
uView.pixel(offsetX+6, offsetY+1+tickPosition, WHITE, XOR);
}

View File

@@ -259,7 +259,6 @@ public:
MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty);
void draw();
void drawFace();
void reDraw();
private:
uint8_t totalTicks, style;
int16_t prevValue;
@@ -271,7 +270,6 @@ public:
MicroViewGauge(uint8_t newx, uint8_t newy, int16_t min, int16_t max, uint8_t sty);
void draw();
void drawFace();
void reDraw();
private:
uint8_t radius, style;
int16_t prevValue;

View File

@@ -92,6 +92,10 @@ void loop() {
</code></pre>
## History
**v1.18b: 5th August 2014 by Scott Allen**
* fixed compiler warning in MicroViewSlider
* changed vertical slider direction.
**v1.17b: 4th August 2014 by JP Liew**
* added reDraw() for MicroViewWidget class
* removed Serial.begin() from uView.begin() so that user can have control
@@ -104,7 +108,7 @@ void loop() {
* improved lots of low level routines, Fast SPI
* fixed some compilation warnings
* reduced overdriving display inputs
* added uVuew.end() to power off the display
* added uView.end() to power off the display
* improved speed of display() and clear() functions
* fixed positionning of "3" on clock face