Really small performace improvement to voltage.c

Signed-off-by: Stefan `Sec` Zehl <sec@42.org>
This commit is contained in:
IKARUS 2012-01-31 19:42:10 +01:00 committed by Stefan `Sec` Zehl
parent 756b7385c1
commit 56519946c0
1 changed files with 61 additions and 58 deletions

View File

@ -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 rectFill(int x, int y, int width, int heigth, bool pixel);
void ram(void) { void ram(void) {
int v,mv,c; int v,mv,c,c_old=0,mv_old=0;
do{ do{
lcdClear();
lcdPrintln("Battery status:");
c = gpioGetValue(RB_PWR_CHRG); c = gpioGetValue(RB_PWR_CHRG);
mv = GetVoltage(); mv = GetVoltage();
// Need repaint?
if (c != c_old || mv != mv_old) {
c_old = c;
mv_old = mv;
lcdClear();
lcdPrintln("Battery status:");
v = mv/1000; v = mv/1000;
// Draw battery frame. // Draw battery frame.
@ -82,6 +86,7 @@ void ram(void) {
lcdPrintln("(not charging)"); lcdPrintln("(not charging)");
}; };
lcdRefresh(); lcdRefresh();
}
} while ((getInputWaitTimeout(242))==BTN_NONE); } 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) { void rectFill(int x, int y, int width, int heigth, bool pixel) {
for (int i=y; i<=y+heigth; ++i) { for (int i=y; i<=y+heigth; ++i) {
for (int j=x; j<=x+width; ++j) { hLine(i, x, x+width, pixel);
lcdSetPixel(j, i, pixel);
}
} }
} }