emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (display-battery-mode) reports incorrect battery percentage


From: Richard M. Stallman
Subject: Re: (display-battery-mode) reports incorrect battery percentage
Date: Sun, 08 Jan 2006 09:48:00 -0500

Does this solve it?

*** battery.el  25 Dec 2005 13:58:39 -0500      1.31
--- battery.el  07 Jan 2006 20:18:05 -0500      
***************
*** 271,276 ****
--- 271,278 ----
  %h Remaining time in hours
  %t Remaining time in the form `h:min'"
    (let ((design-capacity 0)
+       (last-full-capacity 0)
+       full-capacity
        (warn 0)
        (low 0)
        capacity rate rate-type charging-state minutes hours)
***************
*** 310,327 ****
          (when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$"
                                   nil t)
            (incf design-capacity (string-to-number (match-string 1))))
          (when (re-search-forward
                 "design capacity warning: +\\([0-9]+\\) m[AW]h$" nil t)
            (incf warn (string-to-number (match-string 1))))
          (when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$"
                                   nil t)
            (incf low (string-to-number (match-string 1)))))))
      (and capacity rate
         (setq minutes (if (zerop rate) 0
                         (floor (* (/ (float (if (string= charging-state
                                                          "charging")
!                                                (- design-capacity capacity)
!                                              capacity)) rate) 60)))
               hours (/ minutes 60)))
      (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A"))
          (cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state")
--- 312,336 ----
          (when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$"
                                   nil t)
            (incf design-capacity (string-to-number (match-string 1))))
+         (when (re-search-forward "last full capacity: +\\([0-9]+\\) m[AW]h$"
+                                  nil t)
+           (incf last-full-capacity (string-to-number (match-string 1))))
          (when (re-search-forward
                 "design capacity warning: +\\([0-9]+\\) m[AW]h$" nil t)
            (incf warn (string-to-number (match-string 1))))
          (when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$"
                                   nil t)
            (incf low (string-to-number (match-string 1)))))))
+     (setq full-capacity (if (> last-full-capacity 0)
+                           last-full-capacity design-capacity))
      (and capacity rate
         (setq minutes (if (zerop rate) 0
                         (floor (* (/ (float (if (string= charging-state
                                                          "charging")
!                                                (- full-capacity capacity)
!                                              capacity))
!                                     rate)
!                                  60)))
               hours (/ minutes 60)))
      (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A"))
          (cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state")
***************
*** 368,377 ****
          (cons ?t (or (and minutes
                            (format "%d:%02d" hours (- minutes (* 60 hours))))
                       "N/A"))
!         (cons ?p (or (and design-capacity capacity
                            (number-to-string
                             (floor (/ capacity
!                                      (/ (float design-capacity) 100)))))
                       "N/A")))))
  
  
--- 377,386 ----
          (cons ?t (or (and minutes
                            (format "%d:%02d" hours (- minutes (* 60 hours))))
                       "N/A"))
!         (cons ?p (or (and full-capacity capacity
                            (number-to-string
                             (floor (/ capacity
!                                      (/ (float full-capacity) 100)))))
                       "N/A")))))
  
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]