moved reDraw() to parent

This commit is contained in:
JP
2014-08-04 11:00:08 +10:00
parent 7c3ec25d70
commit 94fc7e6437
3 changed files with 14 additions and 36 deletions

View File

@@ -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 // MicroViewWidget Class - end
// ------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------
@@ -1417,16 +1427,6 @@ MicroViewSlider::MicroViewSlider(uint8_t newx, uint8_t newy, int16_t min, int16_
draw(); draw();
} }
/** \brief MicroView Widget reDraw routine.
Redraws the widget.
*/
void MicroViewSlider::reDraw() {
needFirstDraw=true;
drawFace();
draw();
}
/** \brief MicroViewSlider class initialisation with style. /** \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. 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(); offsetY=getY();
if (needFirstDraw) { 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); tickPosition= (((float)(prevValue-getMinValue())/(float)(getMaxValue()-getMinValue()))*totalTicks);
if (style==0 || style==1){ //Horizontal if (style==0 || style==1){ //Horizontal
uView.lineH(offsetX+tickPosition,offsetY, 3, WHITE, XOR); 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(); draw();
} }
/** \brief MicroView Widget reDraw routine.
Redraws the widget.
*/
void MicroViewGauge::reDraw() {
needFirstDraw=true;
drawFace();
draw();
}
/** \brief MicroViewGauge class initialisation with style. /** \brief MicroViewGauge class initialisation with style.
Initialise the MicroViewGauge widget with style WIDGETSTYLE0 or WIDGETSTYLE1. Initialise the MicroViewGauge widget with style WIDGETSTYLE0 or WIDGETSTYLE1.

View File

@@ -226,6 +226,7 @@ private:
class MicroViewWidget { class MicroViewWidget {
public: public:
bool needFirstDraw;
MicroViewWidget(uint8_t newx, uint8_t newy, int16_t min, int16_t max); MicroViewWidget(uint8_t newx, uint8_t newy, int16_t min, int16_t max);
uint8_t getX(); uint8_t getX();
uint8_t getY(); uint8_t getY();
@@ -242,8 +243,7 @@ public:
virtual void draw(){}; virtual void draw(){};
/** \brief Draw widget face overridden by child class. */ /** \brief Draw widget face overridden by child class. */
virtual void drawFace(){}; virtual void drawFace(){};
/** \brief ReDraw widget overridden by child class. */ void reDraw();
virtual void reDraw(){};
private: private:
uint8_t x; uint8_t x;
@@ -262,7 +262,6 @@ public:
void reDraw(); void reDraw();
private: private:
uint8_t totalTicks, style; uint8_t totalTicks, style;
bool needFirstDraw;
int16_t prevValue; int16_t prevValue;
}; };
@@ -275,7 +274,6 @@ public:
void reDraw(); void reDraw();
private: private:
uint8_t radius, style; uint8_t radius, style;
bool needFirstDraw;
int16_t prevValue; int16_t prevValue;
}; };

View File

@@ -34,7 +34,7 @@ void loop() {
uView.display(); uView.display();
} }
delay(1000); delay(500);
uView.clear(PAGE); uView.clear(PAGE);
widget[1]->reDraw(); widget[1]->reDraw();
@@ -43,6 +43,6 @@ void loop() {
uView.display(); uView.display();
} }
delay(1000); delay(500);
uView.clear(PAGE); uView.clear(PAGE);
} }