kennethdm
Joined: 24 Jan 2006 Posts: 8
|
Posted: Wed May 31, 2006 4:03 am Post subject: battery update problem |
|
|
Hi, I'm currently adding some battery indication in my program, what I want to be shown is the battery level (indicated with an image), and how long the battery will last. To do this I have written two procedures (or whatever they are called in C):
| Code: |
void drukBatterijTijd()
{
char tekst[8];
int batterijTijd = 0;
if(scePowerIsBatteryCharging())
{
printTextScreen(400,6,"Charging",RGB(255,255,255));
}
else
{
batterijTijd = scePowerGetBatteryLifeTime();
sprintf(tekst,"%02dh%02dm", batterijTijd/60, batterijTijd-(batterijTijd/60*60));
printTextScreen(400,6,tekst,RGB(255,255,255));
}
}
void drukBatterij(Image* batterij, Image* batterijStreepje)
{
pspTime clock;
sceRtcGetCurrentClockLocalTime( &clock );
int tick = 0;
int batterijProcent = scePowerGetBatteryLifePercent();
int teller = 0;
int aantal = 0;
if(scePowerIsLowBattery()||scePowerIsBatteryCharging())
//flikker indien opladen of laag batterijniveau
{
if( !tick && clock.microseconds >= 500000)
{
tick = 1;
} else {
tick = 0;
}
} else {
//laadt niet op of is niet laag qua niveau => geen flikker
tick = 1;
}
if(batterijProcent>70)
{
aantal = 3;
}
if(batterijProcent<=70)
{
aantal = 2;
}
if(batterijProcent<=40)
{
aantal = 1;
}
if(batterijProcent<=10)
{
aantal = 0;
}
if(tick)
{
blitAlphaImageToScreen(0 ,0 ,33 , 22, batterij, 445, 2);
for(teller = 0;teller<aantal;teller++)
{
blitAlphaImageToScreen(0 ,0 ,6 , 16, batterijStreepje, 452+(teller*8), 5);
}
}
}
|
the image is shown just fine, it flickers when it is charging or low, but there seems to be something wrong with the printing of how long the battery will last. When I try it in my app, and the power cable is not plugged in, everything works fine, the remaining time is displayed, and the battery level is indicated. But when I plug in my power cable, the program freezes... I seriously have no idea why this happens, it's probably something small, but can't find it.
any suggestions? |
|