Changes between Version 1 and Version 2 of PowerManagementIntegration

Show
Ignore:
Timestamp:
12/15/09 15:31:09 (3 years ago)
Author:
kevin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PowerManagementIntegration

    v1 v2  
    1 +Battery 
     1'''Battery''' 
    22 
    33To get the battery voltage, do 
    44 
     5{{{ 
    56int f = open ("/dev/atmg", O_RDONLY); 
    6 int l, p; 
     7int l, percent; 
    78ioctl(f, 0x03, &l); 
     9}}} 
    810 
    9 l is set to the battery voltage in millivolts. 
     11l is set to the battery voltage in millivolts. The nominal battery voltage is 4.2V, but it's unusual to see such a high level except on AC power. I am taking 4100mV as full charge. When on charge the battery voltage is still available, but it isn't particularly meaningful. AVOS does not display charge level on external power, and there's probably a good reason for that. 
     12 
     13AVOS takes the minimum working voltage to be 3.5V. I believe that the hardware shuts down automatically when it gets to 3.25V. I am taking 3.25V as `empty'. In practice, the readings fluctuate widely and, because it's a raw voltage reading, they are affected by current drawn. It does not appear to be possible to measure the current, so I've not found an easy solution to this variability other than to average readings over a minute or so. When averaged, the battery voltage does appear to fall more-or-less linearly with time, so it's relatively straightforward to work out the remaining percentage charge as 
     14 
     15{{{ 
     16percent = 100 * (l - 3250) / (4100 - 3250) 
     17}}} 
     18 
     19 
     20'''Power status''' 
     21 
     22The presence of external power can be detected by reading 
     23 
     24{{{ 
     25/sys/devices/system/battery/battery0/charge_level 
     26}}} 
     27 
     28The value will be 0 (battery), 1 (usb), or 2 (mains). 
     29 
     30The OMAP kernel provides neither APM nor ACPI support so, as far as I know, the methods described here are the only way to get power status information. 
     31 
     32 
     33 
     34 
     35 
     36 
     37 
     38 
     39