|
|
01-22-2009
, 11:38 PM
|
|
|
Posts: 885 |
Thanked: 573 times |
Joined on Apr 2008
|
#42
|
|
|
01-23-2009
, 07:42 AM
|
|
Posts: 997 |
Thanked: 1,226 times |
Joined on Jul 2007
|
#43
|
| The Following 2 Users Say Thank You to Matan For This Useful Post: | ||
|
|
01-27-2009
, 04:43 AM
|
|
|
Posts: 109 |
Thanked: 195 times |
Joined on Sep 2008
@ Guatemala
|
#44
|
You can tell if AC is connected by reading ADC number 3. I believe it shows input voltage level (or something similar). It appears to give three levels:
0 - No power source connected
about 0x100 - power source connected, charging
about 0x170 - power source connected, not charging.
If it is indeed showing input voltage level, then the reading will depend on charger used. A well regulated source will give the same level, whether charging or not.

|
|
01-28-2009
, 04:27 PM
|
|
|
Posts: 333 |
Thanked: 360 times |
Joined on Nov 2008
@ Italy
|
#45
|
|
|
01-28-2009
, 09:30 PM
|
|
|
Posts: 885 |
Thanked: 573 times |
Joined on Apr 2008
|
#46
|
| The Following User Says Thank You to BrentDC For This Useful Post: | ||
|
|
01-28-2009
, 10:32 PM
|
|
|
Posts: 333 |
Thanked: 360 times |
Joined on Nov 2008
@ Italy
|
#47
|
I don't know of any way to read retu as user...
My Python program just used "subprocess.Popen('sudo ./retu-adc', shell=True)" ....
.
)
|
|
01-28-2009
, 11:15 PM
|
|
|
Posts: 885 |
Thanked: 573 times |
Joined on Apr 2008
|
#48
|
I just know a little Python and trial and error usually results in the desired effect.
| The Following User Says Thank You to BrentDC For This Useful Post: | ||
|
|
01-28-2009
, 11:28 PM
|
|
|
Posts: 885 |
Thanked: 573 times |
Joined on Apr 2008
|
#49
|
I have no idea where it went...#!/bin/env python
# Copyright (C) 2009, Brent Chiodo
import commands
import time
import dbus, dbus.service
def average(list):
total = 0
count = 0
for each in list:
count = count + 1
total = total + float(each)
return total / count
date_stamp = commands.getoutput('date +"%-m-%-d-%-Y"' + '.csv')
cycle = 0
battery_log = []
commands.getoutput("mkdir pybattery_logs/")
while(cycle < 480):
add_time = commands.getoutput('date +"%l:%M %p"')
battery_level = commands.getoutput('sudo ./check_retu 8 9')
battery_log.append(battery_level)
if len(battery_log) > 120:
del battery_log[0]
logfile = open('pybattery_logs/' + date_stamp, 'a')
logfile.write('"%s","%s"\n' % (add_time, battery_level))
logfile.close()
if len(battery_log) < 11:
battery_average = average(battery_log)
else:
battery_average = average(battery_log[-10:-1])
if ((battery_average - 300) / 200 > 1):
print "Battery: 100%"
else:
print "Battery: %.1f%s" % ((((battery_average - 300) / 200) * 100), '%')
cycle + 1
print battery_log[-1]
time.sleep(60)

| The Following User Says Thank You to BrentDC For This Useful Post: | ||
|
|
01-29-2009
, 07:13 AM
|
|
Posts: 997 |
Thanked: 1,226 times |
Joined on Jul 2007
|
#50
|
No, I would like to query AC plugs/unplugs events by reading from somewhere (/dev/retu) but no luck so far...
NITdroid