Added graph. battery for voltage l0dable.
Signed-off-by: Stefan `Sec` Zehl <sec@42.org>
This commit is contained in:
parent
54d4c31250
commit
756b7385c1
|
@ -11,6 +11,17 @@
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
|
// Improved version by Ikarus:
|
||||||
|
// Fixed 4.xxV --> 4.0xxV output problem
|
||||||
|
// & added graphical battery.
|
||||||
|
|
||||||
|
// hLine and vLine code from Juna, nougad and fu86
|
||||||
|
// (camp 2011, CTHN Village)
|
||||||
|
void hLine(int y, int x1, int x2, bool pixel);
|
||||||
|
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) {
|
void ram(void) {
|
||||||
int v,mv,c;
|
int v,mv,c;
|
||||||
do{
|
do{
|
||||||
|
@ -20,32 +31,76 @@ void ram(void) {
|
||||||
mv = GetVoltage();
|
mv = GetVoltage();
|
||||||
v = mv/1000;
|
v = mv/1000;
|
||||||
|
|
||||||
lcdNl();
|
// Draw battery frame.
|
||||||
|
hLine(20, 14, 72, true);
|
||||||
|
hLine(40, 14, 72, true);
|
||||||
|
vLine(14, 20, 40, true);
|
||||||
|
vLine(72, 20, 25, true);
|
||||||
|
vLine(72, 35, 40, true);
|
||||||
|
hLine(25, 72, 78, true);
|
||||||
|
hLine(35, 72, 78, true);
|
||||||
|
vLine(78, 25, 35, true);
|
||||||
|
|
||||||
|
// Print and draw status.
|
||||||
if(!c){
|
if(!c){
|
||||||
lcdPrintln("CHARGING");
|
lcdNl();
|
||||||
|
DoString(17, 26, "Charging");
|
||||||
}else if (mv<3550){
|
}else if (mv<3550){
|
||||||
lcdPrintln(" Charge NOW!");
|
lcdPrintln(" Charge NOW!");
|
||||||
}else if (mv<3650){
|
}else if (mv<3650){
|
||||||
lcdPrintln(" Charge soon");
|
lcdPrintln(" Charge soon");
|
||||||
|
rectFill(16, 22, 12, 16, true);
|
||||||
}else if (mv<4000){
|
}else if (mv<4000){
|
||||||
lcdPrintln(" OK");
|
lcdPrintln(" OK");
|
||||||
}else if(mv<4200){
|
rectFill(16, 22, 12, 16, true);
|
||||||
|
rectFill(30, 22, 12, 16, true);
|
||||||
|
}else if (mv<4120){
|
||||||
lcdPrintln(" Good");
|
lcdPrintln(" Good");
|
||||||
|
rectFill(16, 22, 12, 16, true);
|
||||||
|
rectFill(30, 22, 12, 16, true);
|
||||||
|
rectFill(44, 22, 12, 16, true);
|
||||||
}else{
|
}else{
|
||||||
lcdPrintln(" Full");
|
lcdPrintln(" Full");
|
||||||
|
rectFill(16, 22, 12, 16, true);
|
||||||
|
rectFill(30, 22, 12, 16, true);
|
||||||
|
rectFill(44, 22, 12, 16, true);
|
||||||
|
rectFill(58, 22, 12, 16, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Print voltage.
|
||||||
|
lcdNl();
|
||||||
|
lcdNl();
|
||||||
|
lcdNl();
|
||||||
lcdNl();
|
lcdNl();
|
||||||
lcdPrint(" ");
|
lcdPrint(" ");
|
||||||
lcdPrint(IntToStr(v,2,0));
|
lcdPrint(IntToStr(v,2,0));
|
||||||
lcdPrint(".");
|
lcdPrint(".");
|
||||||
lcdPrint(IntToStr(mv%1000, 3, F_ZEROS | F_LONG));
|
lcdPrint(IntToStr(mv%1000, 3, F_ZEROS | F_LONG));
|
||||||
lcdPrintln("V");
|
lcdPrintln("V");
|
||||||
|
// Print if not charging.
|
||||||
lcdNl();
|
|
||||||
if(c){
|
if(c){
|
||||||
lcdPrintln("(not charging)");
|
lcdPrintln("(not charging)");
|
||||||
};
|
};
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
} while ((getInputWaitTimeout(242))==BTN_NONE);
|
} while ((getInputWaitTimeout(242))==BTN_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hLine(int y, int x1, int x2, bool pixel) {
|
||||||
|
for (int i=x1; i<=x2; ++i) {
|
||||||
|
lcdSetPixel(i, y, pixel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vLine(int x, int y1, int y2, bool pixel) {
|
||||||
|
for (int i=y1; i<=y2; ++i) {
|
||||||
|
lcdSetPixel(x, i, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue