Really small performace improvement to voltage.c
Signed-off-by: Stefan `Sec` Zehl <sec@42.org>
This commit is contained in:
parent
756b7385c1
commit
56519946c0
|
@ -23,12 +23,16 @@ void vLine(int x, int y1, int y2, bool pixel);
|
|||
void rectFill(int x, int y, int width, int heigth, bool pixel);
|
||||
|
||||
void ram(void) {
|
||||
int v,mv,c;
|
||||
int v,mv,c,c_old=0,mv_old=0;
|
||||
do{
|
||||
lcdClear();
|
||||
lcdPrintln("Battery status:");
|
||||
c = gpioGetValue(RB_PWR_CHRG);
|
||||
mv = GetVoltage();
|
||||
// Need repaint?
|
||||
if (c != c_old || mv != mv_old) {
|
||||
c_old = c;
|
||||
mv_old = mv;
|
||||
lcdClear();
|
||||
lcdPrintln("Battery status:");
|
||||
v = mv/1000;
|
||||
|
||||
// Draw battery frame.
|
||||
|
@ -82,6 +86,7 @@ void ram(void) {
|
|||
lcdPrintln("(not charging)");
|
||||
};
|
||||
lcdRefresh();
|
||||
}
|
||||
} while ((getInputWaitTimeout(242))==BTN_NONE);
|
||||
}
|
||||
|
||||
|
@ -99,8 +104,6 @@ void vLine(int x, int y1, int y2, bool pixel) {
|
|||
|
||||
void rectFill(int x, int y, int width, int heigth, bool pixel) {
|
||||
for (int i=y; i<=y+heigth; ++i) {
|
||||
for (int j=x; j<=x+width; ++j) {
|
||||
lcdSetPixel(j, i, pixel);
|
||||
}
|
||||
hLine(i, x, x+width, pixel);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue