[EMAIL PROTECTED] wrote:
> 
> I recieved some code a while back on how to do this but after modifying it to
> run on the palm pro (the sysBatteryInfo call is different) I get the
> percentage but the guage is no longer correct. I am assuming that the new call
> for Palm 3 must return something other that battery volts (mine is based a a 3
> volt battery which I also need a better way of doing this too). Can somebody
> help?

   I use the following code to display a battery in any version of the
OS, including PalmV's LiIon batteries:

void GetVoltage(UIntPtr voltage, BytePtr percent) {
   UInt warning;
   DWord romVersion;

   // we have to correctly calculate the current voltage on a PalmPilot,
   // PalmIII, PalmIIIx and PalmV...and in the future, PalmVII.
   FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
   if (sysGetROMVerMajor(romVersion) < 3) {
      *voltage = SysBatteryInfoV20(false, /*set*/
         &warning,
         NULL, /*criticalThresholdP*/
         NULL, /*maxTicksP*/
         NULL, /*kindP*/
         NULL /*pluggedIn*/);
      // calculate the current percentage using pseudo-floats
      // instead of doubles and their corresponding 3.5k FPL
      *percent = (*voltage - warning) * 100 / (MaxVoltage - warning);
   } else
      *voltage = SysBatteryInfo(false, /*set*/
         NULL, /*warnThresholdP*/
         NULL, /*criticalThresholdP*/
         NULL, /*maxTicksP*/
         NULL, /*kindP*/
         NULL, /*pluggedIn*/
         percent);
}

   (MaxVoltage is define'd as 300.)

Hope this helps,
Daniel.




Reply via email to