阅读:1385回复:4
电池驱动的问题
下面是我写的BatteryPDDGetStatus函数的代码,我跟踪了一下,这个函数也不断被系统调用。可是系统显示的电源状态老是外部供电,而且没有电池电量的显示。
我把(gpStatus->sps).ACLineStatus = AC_LINE_OFFLINE; (gpStatus->sps).BatteryFlag = BATTERY_FLAG_CHARGING; 这两个变量都强行赋值了,还是不行,显示的还是外部供电,而且没有电池电量的显示。请高手看看,这段代码有问题吗? BOOL WINAPI BatteryPDDGetStatus( PSYSTEM_POWER_STATUS_EX2 pstatus, PBOOL pfBatteriesChangedSinceLastCall ) { BOOL fOk = TRUE; SETFNAME(_T("BatteryPDDGetStatus")); DEBUGMSG(ZONE_PDD, (_T("%s: invoked w/ pstatus 0x%08x, pfChange 0x%08x\r\n"), pszFname, pstatus, pfBatteriesChangedSinceLastCall)); DEBUGCHK(gpStatus != NULL); DEBUGCHK(pstatus != NULL); DEBUGCHK(pfBatteriesChangedSinceLastCall != NULL); #if 1 DEBUGCHK(v_pIOPregs!=NULL); /*if(v_pIOPregs->rGPFDAT&(1<<7)) { (gpStatus->sps).ACLineStatus = AC_LINE_ONLINE; } else { (gpStatus->sps).ACLineStatus = AC_LINE_OFFLINE; } if(v_pIOPregs->rGPFDAT&(1<<6)) { (gpStatus->sps).BatteryFlag = BATTERY_FLAG_CHARGING; } else { (gpStatus->sps).BatteryFlag = BATTERY_FLAG_LOW; }*/ (gpStatus->sps).ACLineStatus = AC_LINE_OFFLINE; (gpStatus->sps).BatteryFlag = BATTERY_FLAG_CHARGING; (gpStatus->sps).BatteryLifePercent = 20; (gpStatus->sps).Reserved1 = 0; (gpStatus->sps).BatteryLifeTime = BATTERY_LIFE_UNKNOWN; (gpStatus->sps).BatteryFullLifeTime = BATTERY_LIFE_UNKNOWN; (gpStatus->sps).Reserved2 = 0; (gpStatus->sps).BackupBatteryFlag = BATTERY_FLAG_UNKNOWN; (gpStatus->sps).BackupBatteryLifePercent = BATTERY_PERCENTAGE_UNKNOWN; (gpStatus->sps).Reserved3 = 0; (gpStatus->sps).BackupBatteryLifeTime = BATTERY_LIFE_UNKNOWN; (gpStatus->sps).BackupBatteryFullLifeTime = BATTERY_LIFE_UNKNOWN; (gpStatus->sps).BatteryChemistry = BATTERY_CHEMISTRY_UNKNOWN; (gpStatus->sps).BatteryVoltage = 0; (gpStatus->sps).BatteryCurrent = 0; (gpStatus->sps).BatteryAverageCurrent = 0; (gpStatus->sps).BatteryAverageInterval = 0; (gpStatus->sps).BatterymAHourConsumed = 0; (gpStatus->sps).BatteryTemperature = 0; (gpStatus->sps).BackupBatteryVoltage = 0; #endif // get battery status information from the shared structure LockBattery(); memcpy(pstatus, &gpStatus->sps, sizeof(*pstatus)); *pfBatteriesChangedSinceLastCall = TRUE/*gpStatus->fChanged*/; if(*pfBatteriesChangedSinceLastCall) { gpStatus->fChanged = FALSE; // reset changed flag if it's set } UnlockBattery(); DEBUGMSG(ZONE_PDD, (_T("%s: returning %d\r\n"), pszFname, fOk)); return (fOk); } |
|
沙发#
发布于:2007-02-10 18:29
你有那么多的变量都设成UNKOWN了,是不是与这些有关啊?
|
|
|
板凳#
发布于:2007-02-10 23:38
LockBattery(); 个人感觉这一段可能会有问题,仔细跟踪一下 |
|
|
地板#
发布于:2007-02-12 12:03
呵呵,问题解决了。原来是没有把battdrvr.dll加到OS中,在PLATFORM。BIB中增加一句
battdrvr.dll $(_FLATRELEASEDIR)\battdrvr.dll NK SH 就好了。 |
|
地下室#
发布于:2007-03-03 17:05
to wince_lover
我按照你的方法配置了代码,可是在屏幕下方的状态条上却没有电池电量的显示,但是开机是却有一个电源插头显示,只不过一闪而过就没有了,不知道什么原因,请讲解一下,谢谢! |
|