mirror of
https://github.com/geekammo/MicroView-Arduino-Library.git
synced 2026-02-19 19:11:22 +01:00
moved reDraw() to parent
This commit is contained in:
@@ -1396,6 +1396,16 @@ void MicroViewWidget::setValue(int16_t val) {
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief MicroView Widget reDraw routine.
|
||||
|
||||
Redraws the widget.
|
||||
*/
|
||||
void MicroViewWidget::reDraw() {
|
||||
needFirstDraw=true;
|
||||
this->drawFace();
|
||||
this->draw();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
// MicroViewWidget Class - end
|
||||
// -------------------------------------------------------------------------------------
|
||||
@@ -1417,16 +1427,6 @@ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_
|
||||
draw();
|
||||
}
|
||||
|
||||
/** \brief MicroView Widget reDraw routine.
|
||||
|
||||
Redraws the widget.
|
||||
*/
|
||||
void MicroViewSlider::reDraw() {
|
||||
needFirstDraw=true;
|
||||
drawFace();
|
||||
draw();
|
||||
}
|
||||
|
||||
/** \brief MicroViewSlider class initialisation with style.
|
||||
|
||||
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.
|
||||
@@ -1545,16 +1545,6 @@ void MicroViewSlider::draw() {
|
||||
offsetY=getY();
|
||||
|
||||
if (needFirstDraw) {
|
||||
/*
|
||||
if (style==0 || style==1){ //Horizontal
|
||||
uView.lineH(offsetX+tickPosition, offsetY, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+1+tickPosition, offsetY+1, WHITE, XOR);
|
||||
}
|
||||
else { //Vertical
|
||||
uView.lineV(offsetX+7, offsetY+tickPosition, 3, WHITE, XOR);
|
||||
uView.pixel(offsetX+6, offsetY+1+tickPosition, WHITE, XOR);
|
||||
}
|
||||
*/
|
||||
tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
|
||||
if (style==0 || style==1){ //Horizontal
|
||||
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR);
|
||||
@@ -1629,16 +1619,6 @@ MicroViewGauge::MicroViewGauge(uint8_t newx, uint8_t newy, int16_t min, int16_t
|
||||
draw();
|
||||
}
|
||||
|
||||
/** \brief MicroView Widget reDraw routine.
|
||||
|
||||
Redraws the widget.
|
||||
*/
|
||||
void MicroViewGauge::reDraw() {
|
||||
needFirstDraw=true;
|
||||
drawFace();
|
||||
draw();
|
||||
}
|
||||
|
||||
/** \brief MicroViewGauge class initialisation with style.
|
||||
|
||||
Initialise the MicroViewGauge widget with style WIDGETSTYLE0 or WIDGETSTYLE1.
|
||||
|
||||
@@ -226,6 +226,7 @@ private:
|
||||
|
||||
class MicroViewWidget {
|
||||
public:
|
||||
bool needFirstDraw;
|
||||
MicroViewWidget(uint8_t newx, uint8_t newy, int16_t min, int16_t max);
|
||||
uint8_t getX();
|
||||
uint8_t getY();
|
||||
@@ -242,8 +243,7 @@ public:
|
||||
virtual void draw(){};
|
||||
/** \brief Draw widget face overridden by child class. */
|
||||
virtual void drawFace(){};
|
||||
/** \brief ReDraw widget overridden by child class. */
|
||||
virtual void reDraw(){};
|
||||
void reDraw();
|
||||
|
||||
private:
|
||||
uint8_t x;
|
||||
@@ -262,7 +262,6 @@ public:
|
||||
void reDraw();
|
||||
private:
|
||||
uint8_t totalTicks, style;
|
||||
bool needFirstDraw;
|
||||
int16_t prevValue;
|
||||
};
|
||||
|
||||
@@ -275,7 +274,6 @@ public:
|
||||
void reDraw();
|
||||
private:
|
||||
uint8_t radius, style;
|
||||
bool needFirstDraw;
|
||||
int16_t prevValue;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ void loop() {
|
||||
uView.display();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
delay(500);
|
||||
uView.clear(PAGE);
|
||||
|
||||
widget[1]->reDraw();
|
||||
@@ -43,6 +43,6 @@ void loop() {
|
||||
uView.display();
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
delay(500);
|
||||
uView.clear(PAGE);
|
||||
}
|
||||
Reference in New Issue
Block a user