Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Battery Info

Battery Info

Discuss PocketC for Palm OS (including Desktop Edition)

Postby Corzar on Wed Apr 25, 2001 11:21 pm

Is it possible to get an accurate battery indicator in the screen of a pocketc program? If you can help me do this, I would be very happy.:p
Xavier Smork

*Trying to make something important*

Love my Sony PDA!

http://www.geocities.com/xaviersmork
Corzar
 
Posts: 53
Joined: Mon Apr 23, 2001 11:19 pm
Location: USA

Postby Velvis on Thu Apr 26, 2001 11:54 am

Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby Corzar on Thu Apr 26, 2001 12:43 pm

I have tried it. This is what it tells me:

BatteryInfo -
int BatteryInfo(int getvalue)
Where getvalue is one of these values:
0 (zero) to get the Current Battery voltage times 100 (i.e. divide the value by 100 hundred and cast to a float to get the actual voltage)

1 (one) to get the Warning Threshold voltage times 100 (i.e. this is the voltage where the Palm device starts warning you about battery voltage)

2 (two) to get the Critical voltage below which the Palm device will not turn on.

3 (three) CheckTicks - according the PalmOS API, "Warning Threshold and CheckTicks are the battery-warning voltage threshold and time out. If the battery voltage falls below the threshold, or the timeout expires, a lowBatteryChr key event is put on the queue. Normally, applications call SysHandleEvent which calls SysBatteryWarningDialog in response to this event." This particular piece of information may have little value for PocketC programmers.

4 (four) Type of Battery. Returns 0 for Alkaline, 1 for NiCad, and 2 for Lithium.

5 (five) Plugged In??? Returns 1 if the pluggedIn value returned by SysBatteryInfo is true, otherwise returns 0 for false. I'm not sure what this does.

How does that result in a percentage of battery life?





Edited by - corzar on 04/26/2001 07:43:47
Xavier Smork

*Trying to make something important*

Love my Sony PDA!

http://www.geocities.com/xaviersmork
Corzar
 
Posts: 53
Joined: Mon Apr 23, 2001 11:19 pm
Location: USA

Postby Velvis on Fri Apr 27, 2001 11:00 am

Have you tried contacting the author of the system library? Perhaps he would know a way to do it. Also while maybe not ideal, doesnt every device have a starting voltage? (my iiic is 4.0) If you could gather this info for the other machines and use it with the sys library to determine battery types you should be able to get a percentage of battery life.
I am not sure but wouldnt all standard battery units be 3.0 volts? (1.5 x 2 AAA batteries)
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby awschwab on Fri Apr 27, 2001 1:52 pm

Start by determining the voltage after you put in a fresh battery (Vf). That corresponds to 100%. Decide what you will call 0% -- probably the warning voltage, not the critical voltage, but that's up to you (V0). Now, when you check the voltage of your battery (V), it will show up somewhere in between. The simplest thing to report would be the linear interpolation :
% remaining = 100*(V - V0)/(Vf - V0)

This assumes a linear relationship between voltage and time, which is unlikely to be correct, but it will give you a rough idea of battery life. After you have used your program for a while, perhaps timing how long it takes to change, or perhaps comparing your value to the system indicator, you can use your data to fit a curve more realistic than a straight line. However, the curve will depend on battery type, and the simple linear model may be good enough.

Here is a link to more information on alkaline battery lifetimes:
http://www.madsci.org/posts/archives/oc ... .Eg.r.html


Edited by - awschwab on 04/27/2001 10:08:19
awschwab
 
Posts: 270
Joined: Tue Feb 06, 2001 2:33 pm
Location: USA

Postby awschwab on Fri Apr 27, 2001 5:56 pm

Here is a function that will return the percentage of battery time remaining, based on a 3rd order polynomial fit of the time/voltage curves on the duracell site for alkaline batteries. The temperature and power draw will affect results, but curves for 24 ohm and 62 ohm draw gave equations that agreed within a few percent of battery lifetime, so this is derived from fitting both together. It is probably better than a linear fit. I suppose if you go to this much trouble, you should use the CControls 1.1 Cprogbar() function to display the output.

//batteryRemaining.pc
// Returns percentage of time left on battery,
// assuming alkaline lifetime curve taken from
// http://www.duracell.com/OEM/comparisons
// 3v = 100%, 1.6 v = 0% (2.1v is warning voltage).
library "PktCSysLib"

int batteryRemaining()
{
int v1, v2, v3; // voltage, square and cube
int percentLeft;

v1 = BatteryInfo(0);
v2 = v1 * v1;
v3 = v1 * v2;

// combined data from 62 and 24 ohm drain
percentLeft = 621 - 9.05*v1 + 0.0415*v2 - 0.000057*v3;

return(percentLeft);
}

main()
{
int left;

left = batteryRemaining();
alert("You have " + left + "% of your battery remaining.");
}


Note: This is from a fit of actual data on alkaline batteries. It does not apply to other types, particularly those at other voltages. If you know the voltages that correspond to full and empty, you can use linear interpolation for those. To adapt this to other types requires fit of data on time vs voltage behavior of those batteries.


Edited by - awschwab on 04/27/2001 17:52:26
awschwab
 
Posts: 270
Joined: Tue Feb 06, 2001 2:33 pm
Location: USA

Postby Corzar on Fri Apr 27, 2001 6:10 pm

Thanx, I'll try it. :)
Can you explain to me how this would be modified for 1.2volts and 4volts?


Edited by - Corzar on 04/27/2001 13:32:02
Xavier Smork

*Trying to make something important*

Love my Sony PDA!

http://www.geocities.com/xaviersmork
Corzar
 
Posts: 53
Joined: Mon Apr 23, 2001 11:19 pm
Location: USA

Postby jstadolnik on Fri Apr 27, 2001 6:59 pm

There's actually palm API to do this.

The PktCSysLib uses an older API call, the newer version of it (OS3.0+) returns the remaining battery power as a percentage.

I'll try to get this into the next toolbox release (~2 weeks away).

Joe
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby Corzar on Fri Apr 27, 2001 11:56 pm

Thank you so much everyone. Thank you Joe, I love your Toolbox. That will be a great update!
Xavier Smork

*Trying to make something important*

Love my Sony PDA!

http://www.geocities.com/xaviersmork
Corzar
 
Posts: 53
Joined: Mon Apr 23, 2001 11:19 pm
Location: USA


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 2 guests

cron