On Aug 27, Daniel Dadap wrote:
> Hello Community,
>
> I just bought a portable USB battery pack ( one of these:
> http://apc.com/products/family/index.cfm?id=314 ) to use with my
> FreeRunner so that I could keep tangogps running to log a track for me
> during a bike ride. It worked quite well: I was able to keep the unit
> powered on for over 12 hours and still had some juice left over to
> make some phone calls at the end of the day. However, I noticed that
> the FR was only drawing 100mA. I was sort of hoping that the battery
> pack would emulate a USB host and negotiate current, but it looks like
> it just has available power.
have a look at
http://wiki.openmoko.org/wiki/Forcing_fast_charge_mode
for
http://hdr.meetr.de/neo/openmoko/battery/battery_0.20080721_armv4t.ipk
which works nice for me (you can force charge mode to 500/1000 mA),
after patching pygtk:
https://docs.openmoko.org/trac/ticket/1718
and if the icon doesn't show up:
http://n2.nabble.com/Battery-Charge-Solution(Not)-td684534.html
I've modified battery.py a bit to display the (de)charging current too,
my script version attached...
Harald
--
"I hope to die ___ _____
before I *have* to use Microsoft Word.", 0--,| /OOOOOOO\
Donald E. Knuth, 02-Oct-2001 in Tuebingen. <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
\/\/\/\/\/\/\/\/\/
Harald Koenig // / \\ \
[EMAIL PROTECTED] ^^^^^ ^^^^^
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# GUI for battery on Neo Freerunner
# written by HdR <[EMAIL PROTECTED]>
# battery status icons made by Kore Nordmann <[EMAIL PROTECTED]>
# start icon from tango icons <http://tango.freedesktop.org/Tango_Desktop_Project>
#
# ! this script comes with explicit no warranty !
# License: gpl
import gobject,gtk
import os
class BatteryGUI:
charger_type = "/sys/class/i2c-adapter/i2c-0/0-0073/charger_type"
capacity = "/sys/devices/platform/bq27000-battery.0/power_supply/bat/capacity"
voltage = "/sys/devices/platform/bq27000-battery.0/power_supply/bat/voltage_now"
current = "/sys/devices/platform/bq27000-battery.0/power_supply/bat/current_now"
status = "/sys/devices/platform/bq27000-battery.0/power_supply/bat/status"
image_dir = "/usr/share/battery/"
usb_limit = "/sys/class/i2c-adapter/i2c-0/0-0073/force_usb_limit_dangerous"
#charger_type = "charger_type"
#capacity = "capacity"
#voltage = "voltage"
#status = "status"
#image_dir = "./"
def delete_event(self, widget, event=None, data=None):
gtk.main_quit()
return False
# Check the current amperage
def check_type(self):
self.f = open(self.charger_type, 'r')
self.type = self.f.readline().rstrip('\n')
self.f.close()
try:
self.current_range = self.type.split(" ")[3]
except:
return False
if (self.current_range == '1A'):
self.amperage = 1000;
elif (self.current_range == '500mA'):
self.amperage = 500;
elif (self.current_range == '100mA'):
self.amperage = 100;
else:
self.amperage = False;
return (self.amperage)
# Check current battery capacity
def check_capacity(self):
self.f = open(self.capacity, 'r')
self.q = self.f.readline().rstrip('\n')
self.f.close()
return (int(self.q))
# Check current battery voltage
def check_voltage(self):
self.f = open(self.voltage, 'r')
self.q = float(self.f.readline().rstrip('\n'))
self.f.close()
self.v = self.q/1000000;
return (self.v)
# Check current battery current
def check_current(self):
self.f = open(self.current, 'r')
self.q = float(self.f.readline().rstrip('\n'))
self.f.close()
self.v = - self.q/1000;
return (self.v)
# Check current status (Charging/Discharging)
def check_status(self):
self.f = open(self.status, 'r')
self.q = self.f.readline().rstrip('\n')
self.f.close()
return(self.q)
# Set the load amperage manually
def set_charge_limit(self, button, limit):
if (self.check_type()):
os.system("echo %d > %s" % (limit,self.usb_limit))
return True
# Update the capacity label
def update_capacity(self, label, image):
cap = self.check_capacity()
label.set_text ("Battery capacity: %d%%" % cap)
if (cap <= 5):
image.set_from_file(self.image_dir+"battery_stat_00.png")
elif (cap <= 20):
image.set_from_file(self.image_dir+"battery_stat_11.png")
elif (cap <= 38):
image.set_from_file(self.image_dir+"battery_stat_23.png")
elif (cap <= 56):
image.set_from_file(self.image_dir+"battery_stat_42.png")
elif (cap <= 85):
image.set_from_file(self.image_dir+"battery_stat_64.png")
else:
image.set_from_file(self.image_dir+"battery_stat_99.png")
return True
# Update the charge label
def update_charge(self, label):
rate = self.check_type()
if (rate):
label.set_text ("Battery charging: %d mA" % rate)
else:
label.set_text ("Battery charging: %s" % self.check_status())
return True
def update_voltage(self, label):
voltage = self.check_voltage()
label.set_text ("Current voltage: %.2f V" % voltage)
return True
def update_current(self, label):
current = self.check_current()
label.set_text ("Current current: %.0f mA" % current)
return True
# Gtk GUI
def __init__(self):
# init main window
self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.win.connect("delete_event", self.delete_event)
# add a VBox
self.vbox = gtk.VBox(homogeneous=False, spacing=5)
self.win.add(self.vbox)
self.vbox.show()
# add a HBox
self.hbox0 = gtk.HBox()
self.vbox.pack_start(self.hbox0)
self.hbox0.show()
# Add a Image
self.stat_image = gtk.Image()
self.stat_image.set_from_file(self.image_dir+"battery_stat_01.png")
self.hbox0.pack_start(self.stat_image)
self.stat_image.show()
# Add a Vbox for info labels
self.vbox1 = gtk.VBox()
self.hbox0.pack_start(self.vbox1)
self.vbox1.show()
t=1000
# Add Capacity label
self.capacity_label = gtk.Label("Battery capacity: checking")
self.vbox1.pack_start(self.capacity_label)
self.capacity_label.show()
gobject.timeout_add (t, self.update_capacity, self.capacity_label, self.stat_image)
# Add chargelevel label
self.charge_label = gtk.Label("Battery charging: checking")
self.vbox1.pack_start(self.charge_label)
self.charge_label.show()
gobject.timeout_add (t, self.update_charge, self.charge_label)
# Add voltage label
self.voltage_label = gtk.Label("Current voltage: checking")
self.vbox1.pack_start(self.voltage_label)
self.voltage_label.show()
gobject.timeout_add (t, self.update_voltage, self.voltage_label)
# Add current label
self.current_label = gtk.Label("Current current: checking")
self.vbox1.pack_start(self.current_label)
self.current_label.show()
gobject.timeout_add (t, self.update_current, self.current_label)
# Add HBox for buttons
self.hbox1 = gtk.HBox(homogeneous=False, spacing=5)
self.vbox.pack_start(self.hbox1)
self.hbox1.show()
# Add button for 100mA
self.button_100 = gtk.Button("Charge at\n100mA")
self.hbox1.pack_start(self.button_100)
self.button_100.connect("clicked", self.set_charge_limit, 100)
self.button_100.show()
# Add button for 500mA
self.button_500 = gtk.Button("Charge at\n500mA")
self.hbox1.pack_start(self.button_500)
self.button_500.connect("clicked", self.set_charge_limit, 500)
self.button_500.show()
# add button for 1000mA
self.button_1000 = gtk.Button("Charge at\n1000mA")
self.hbox1.pack_start(self.button_1000)
self.button_1000.connect("clicked", self.set_charge_limit, 1000)
self.button_1000.show()
# add exit button
self.button_exit = gtk.Button("Close battery")
self.vbox.pack_start(self.button_exit)
self.button_exit.connect("clicked", self.delete_event)
self.button_exit.show()
# show main window
self.win.show()
def main(self):
gtk.main()
if __name__ == '__main__':
gui = BatteryGUI()
gui.main()
_______________________________________________
Openmoko community mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/community