![]() |
2009-01-23
, 04:38
|
|
Posts: 903 |
Thanked: 632 times |
Joined on Apr 2008
|
#42
|
![]() |
2009-01-23
, 12:42
|
Posts: 1,224 |
Thanked: 1,763 times |
Joined on Jul 2007
|
#43
|
The Following 2 Users Say Thank You to Matan For This Useful Post: | ||
![]() |
2009-01-27
, 09:43
|
|
Posts: 109 |
Thanked: 196 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.
![]() |
2009-01-28
, 21:27
|
|
Posts: 334 |
Thanked: 366 times |
Joined on Nov 2008
@ Italy
|
#45
|
![]() |
2009-01-29
, 02:30
|
|
Posts: 903 |
Thanked: 632 times |
Joined on Apr 2008
|
#46
|
The Following User Says Thank You to BrentDC For This Useful Post: | ||
![]() |
2009-01-29
, 03:32
|
|
Posts: 334 |
Thanked: 366 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)" ....
![]() |
2009-01-29
, 04:15
|
|
Posts: 903 |
Thanked: 632 times |
Joined on Apr 2008
|
#48
|
The Following User Says Thank You to BrentDC For This Useful Post: | ||
![]() |
2009-01-29
, 04:28
|
|
Posts: 903 |
Thanked: 632 times |
Joined on Apr 2008
|
#49
|
#!/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: | ||
![]() |
2009-01-29
, 12:13
|
Posts: 1,224 |
Thanked: 1,763 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