[ltp] Battery dying
Thomas Hood
linux-thinkpad@www.bm-soft.com
Fri, 2 Nov 2001 21:51:54 +0000 (GMT)
I accept what you say, but one of the nice things
about running with the battery in is UPS.
Thomas
--- Rob Mayoff <mayoff@dqd.com> wrote:
> +---------- On Nov 1, Thomas Hood said:
> > PMO. I just bought a new battery in July, and already it's dying
> > just as my last battery did. When charging, after it charges to
> > about 20% it jumps up to "100%", and when I run on battery it
> > only runs down to about 85% before dropping suddenly to 5%.
> >
> > Is this a firmware bug, or what?
>
> I have found that the battery life on my 770Z is greatly shortened if I
> keep both the battery and the AC adapter connected when the battery is
> at 100%. The visible symptom is just as you described: the battery
> jumps to 100% from some lower value when it's charging. When it's
> discharging, it jumps to 5% from some higher number.
>
> I bought a new battery and wrote a Tcl/Tk script that monitors the
> battery level. When the battery reaches 100%, it prompts me to either
> remove the battery or the AC connection. The script is attached.
>
> > #!/usr/bin/env wish
>
> fconfigure stdout -buffering none
>
> wm state . withdrawn
> set font [font create -family {times new roman} -size 20 -weight normal
> -slant roman]
>
> set windowExists 0
>
> proc tai64n {} {
> format @40000000%08x00000000 [clock seconds]
> }
>
> proc log {args} {
> puts "[tai64n] [join $args " "]"
> }
>
> proc makeWindow {} {
> global font windowExists
>
> toplevel .w
> set windowExists 1
>
> wm geometry .w 400x300+440+362
> wm title .w "Battery Warning"
> wm iconname .w "Battery Warning"
>
> bind .w <Destroy> {
> global windowExists
> set windowExists 0
> }
>
> message .w.m -font $font -justify center -aspect 300 -text \
> "Eject battery or remove AC power now!"
> pack .w.m -expand 1 -fill both
> }
>
> proc changedState {note test newname oldname} {
> upvar 1 $newname new
> upvar 1 $oldname old
>
> set was [$test old]
> set is [$test new]
>
> if {$was && !$is} {
> return -$note
> } elseif {!$was && $is} {
> return +$note
> }
>
> return ""
> }
>
> proc currentState {note test newname junk} {
> upvar 1 $newname new
>
> if {[$test new]} {
> return +$note
> } else {
> return -$note
> }
> }
>
> proc getPowerStatus {arrayname} {
> global lastState
>
> upvar 1 $arrayname p
>
> set fd [open /proc/apm r]
> set line [read $fd]
> close $fd
>
> foreach label {
> driverVersion
> biosVersion
> biosFlags
> acStatus
> batteryStatus
> batteryFlag
> percentage
> time
> units
> } value [split $line] {
> set p($label) $value
> }
>
> set update {}
>
> if [info exists lastState] {
> set command changedState
> } else {
> set command currentState
> }
>
> foreach {note test} {
> ac hasAC
> battery hasBattery
> empty isBatteryEmpty
> full isBatteryFull
> } {
> set s [$command $note $test p lastState]
> if {[string length $s] > 0} {
> lappend update $s
> }
> }
>
> if {[llength $update] > 0} {
> log $update
> }
>
> array set lastState [array get p]
> }
>
> proc hasAC {arrayname} {
> upvar 1 $arrayname p
>
> return [expr {$p(acStatus) & 0x01}]
> }
>
> proc hasBattery {arrayname} {
> upvar 1 $arrayname p
>
> return [expr {($p(batteryFlag) & 0x80) == 0}]
> }
>
> proc isBatteryFull {arrayname} {
> upvar 1 $arrayname p
>
> return [string equal $p(percentage) "100%"]
> }
>
> proc isBatteryEmpty {arrayname} {
> upvar 1 $arrayname p
>
> return [string equal $p(percentage) "0%"]
> }
>
> proc isBadState {} {
> getPowerStatus p
> return [expr {[hasAC p] && [hasBattery p] && [isBatteryFull p]}]
> }
>
> proc monitor {} {
> if [isBadState] {
> after 5000 warn
> } else {
> after 5000 monitor
> }
> }
>
> proc warn {} {
> global windowExists
>
> if ![isBadState] {
> if {$windowExists} {
> destroy .w
> }
> after 5000 monitor
> } else {
> if {!$windowExists} {
> makeWindow
> }
> bell
> after 5000 warn
> }
> }
>
> monitor
>
=====
Linux on ThinkPad 600 page: http://panopticon.csustan.edu/thood/tp600lnx.htm
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html