Thanks everyone for the help. the script is now working great! The
script below sounds interesting though, I'll give it a try!

--- In [email protected], Marck D Pearlstone <[EMAIL PROTECTED]> wrote:
> Dear David,
> 
> @30-Jul-2005, 10:15 -0400 (30-Jul 15:15 UK time)
> [EMAIL PROTECTED] [DP] in
> mid:[EMAIL PROTECTED] said:
> 
> >> Following message might be helpful
> >> http://groups.yahoo.com/group/power-pro/message/16092
> 
> DP> I've tried that script, but it doesn't produce results that are
> DP> even close to real-world, and are more inaccurate than the
> DP> built-in tooltip info on the battery indicator. Haven't tried to
> DP> fix it yet...
> 
> I did. I have much improved it and been using it for a long while. I
> didn't think anybody else was since no bugs got reported back to me
> otherwise I'd have said sooner. The first projection is usually pretty
> silly, but the second change in battery charge value usually gives the
> script something more sensible to work with.
> 
> My battery has a discharge time of around 1:10 and a charge time of
> around 3:30 :-(. It copes with both of these ranges pretty well for
> me.
> 
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ; * Author   : Marck D. Pearlstone (c) 2004/5
> ; * Purpose  : Battery recharge / discharge time projection script
> ; * Name     : battCalc
> ;
> ; * Requires : PowerPro 3.8.10+ , Battery power system
> ;              A timer to run battCalc once every minute
> ;
> ; * Results  : a button showing "nn% h:mm" where nn is the current
> ;              charge state of the battery and h:mm is the time
> ;              remaining to either 0 or 100% depending on direction.
> ;              Tooltip shows Runtime/Charging=hh:mm of hh:mm where
> ;              the first figure is the elapsed time and the second
> ;              is the total time projected for completion
> ;
> ; * To display the results, I use the following "button":
> ;      Name    : *info expr(batt)% expr(timeRemain)
> ;      Tool Tip: *info expr(life)
> ;      Left    : .battCalc
> ;
> ; * Assumes  : '<' and '>' are not special command characters
> ;
> ; * Description:
> ;
> ; This script will estimate a projected completion time for laptop
> ; battery charge discharge.
> ;
> ; The result is published in hours:minutes in a global variable
"timeRemain"
> ; A secondary result is published in "life" and provides runtime
information 
> ; in the form "Runtime=h:mm of h:mm" showing how long the battery
has been 
> ; running and how long the final charge / discharge cycle will have
taken.
> ; The "batt" variable carries the current charge percentage of the
battery.
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ; Result variables
> global timeRemain, batt, life
> ; Some variables to keep track with
> static battH1, timeH1, start
> static count, totGap, totTime, going
> ; Some variables to work with
> local diff, gap, now, restart, xTime, g1, totExp
> ;
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ; Take a snapshot of the battery state and current time
> batt=batterypercent
> now = unixtime
> gap = batt - battH1
> ;
> ; First time in?
> if (timeH1==0 or batt==0 or batt==100 or (now-start)>50000)
>         restart = 1
> ;
> ; Record the direction of the gap (g1 will be '-' if negative)
> if (gap != "0")
>         g1 = select( gap, 1)
> ;
> ; Change of direction? If so, a restart is needed
> if (g1 != "") and (going != "") Do
>         if ((g1 != going) and (going == "-" or g1 == "-")) Do
>                 restart = 1
>         EndIf
> EndIf
> ;
> if (restart == 1) Do
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ; Reset all counters and stop the script for now
>         start = unixtime
>         if (gap != 0)
>                 timeH1 = start
>         battH1 = batt
>         timeRemain = ""
>         life = "(running)"
>         going = g1
>         count = 0
>         totGap = 0
>         totTime = 0
>         restart = 0
>         Quit
> EndIf
> ;
> ; Keep track of where we're going
> if (g1 != "" && g1 != going) 
>         going = g1
> ;
> if (going == "-" )
>         gap = 0 - gap
> ;
> ; Not enough data to work with yet
> xTime = now - timeH1
> ;
> ; Is this result "significant"?
> if (xTime <= 150) Do
>         if (xTime >= 60) do
>                 totTime = totTime + xTime
>                 count = count + 1
>                 totGap = totGap + ((gap * 1000) / xTime)
>         EndIf
> EndIf
> ;
> if (xTime >= 60)
>         timeH1 = now
> ;
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> battH1 = batt
> ;
> ;
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @setlife
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ;
> if (going == "-" ) Do
>         gap = batt * 100
> else
>         gap = (100 - batt) * 100
> Endif
> ;
> if (count == 0)
>         count = 1
> ;
> avgGap = 1 + (totGap / count)
> diff =  ((gap * 76)/ avgGap) / 600
> ;
> project = diff
> ;
> ; Now it's just a matter of formatting up the result fields
> if (diff >= 60)
>         diff = (diff / 60) ++ ":" ++ select( 100 + (diff % 60), -2)
> timeRemain = diff
> ;
> diff = (now - start) / 60
> ;
> project = project + diff
> ;
> life = "Runtime" ++ "=" ++ (diff / 60) ++ ":" ++ select( 100 + (diff
% 60), -2)
> if( (diff - totTime) > 5) 
>         life = life ++ " (" ++ totExp ++ ")"
> life = life ++ " of " ++ (project / 60) ++ ":" ++ select( 100 +
(project % 60), -2)
> ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> -- 
> Cheers --  //.arck  D Pearlstone -- Consultant Software Engineer
> ___________________________________________________________________
> \ BrainStorm -  a meeting of mind  - http://www.brainstormsw.com  /
>  \ ICQ# 173337671 | PGP 0x929DCDA0 | Marck: www.silverstones.com /
> '




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h00dgq3/M=362131.6882499.7825260.1510227/D=groups/S=1706030409:TM/Y=YAHOO/EXP=1122780958/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life 
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to