Merge pull request #27 from MLXXXp/widget_setvalue_nodraw

Add optional second argument to widget setValue which can supress display buffer update
This commit is contained in:
JP Liew
2015-03-29 09:26:15 +11:00
2 changed files with 17 additions and 6 deletions

View File

@@ -1441,19 +1441,29 @@ void MicroViewWidget::setMaxValue(int16_t max) {
*/
uint8_t MicroViewWidget::getMaxValLen() { return maxValLen; }
/** \brief Set current value.
/** \brief Set current value and update widget.
The current value of the widget is set to the variable passed in.
The current value of the widget is set to the variable passed in and the widget is drawn with the new value.
*/
void MicroViewWidget::setValue(int16_t val) {
setValue(val, true);
}
/** \brief Set current value with optional update.
The current value of the widget is set to the variable passed in. The widget is drawn with the new value if the doDraw argument is true.
*/
void MicroViewWidget::setValue(int16_t val, boolean doDraw) {
if ((val<=maxValue) && (val>=minValue)) {
value = val;
valLen = getInt16PrintLen(val);
this->draw();
if (doDraw) {
this->draw();
}
}
}
/** \brief Get the print length of the value
/** \brief Get the print length of the value.
Return the number of characters that would be printed using uView.print(value) for the current value.
*/

View File

@@ -241,6 +241,7 @@ public:
void setMinValue(int16_t min);
void setMaxValue(int16_t max);
void setValue(int16_t val);
void setValue(int16_t val, boolean doDraw);
uint8_t getValLen();
uint8_t getMaxValLen();
/** \brief Draw widget value overridden by child class. */
@@ -273,7 +274,7 @@ public:
private:
void drawPointer();
uint8_t style, totalTicks;
bool noValDraw;
boolean noValDraw;
int16_t prevValue;
};
@@ -286,7 +287,7 @@ public:
private:
void drawPointer();
uint8_t style, radius;
bool noValDraw;
boolean noValDraw;
int16_t prevValue;
};