From b60eb4c9caaa2ae5bc27688ca25293a458cf7004 Mon Sep 17 00:00:00 2001 From: Paulus Date: Sat, 18 Oct 2008 18:09:00 +0000 Subject: [PATCH] Initial import git-svn-id: http://www.neo1973-germany.de/svn@191 46df4e5c-bc4e-4628-a0fc-830ba316316d --- PyBat/trunk/PyBat.edc | 1025 +++++++++++++++++++++++++++++++++++++++++ PyBat/trunk/PyBat.edj | Bin 0 -> 12197 bytes PyBat/trunk/PyBat.py | 176 +++++++ PyBat/trunk/README | 1 + 4 files changed, 1202 insertions(+) create mode 100644 PyBat/trunk/PyBat.edc create mode 100644 PyBat/trunk/PyBat.edj create mode 100644 PyBat/trunk/PyBat.py create mode 100644 PyBat/trunk/README diff --git a/PyBat/trunk/PyBat.edc b/PyBat/trunk/PyBat.edc new file mode 100644 index 0000000..558f38d --- /dev/null +++ b/PyBat/trunk/PyBat.edc @@ -0,0 +1,1025 @@ +//test + +images { +// image, "background.jpg" LOSSY 95; +} + + + +collections { + group { + name, "main"; + min, 480 640; + max, 1024 768; + + parts { +#define COLOR_DEFAULT 30 30 30 255 +#define COLOR_CLICKED 80 80 80 255 + part { + name, "background"; + type, RECT; + mouse_events, 0; + + description { + state, "default" 0.0; + min, 480 640; + max, 1024 768; + color, 200 200 200 200; + rel1 { + relative, 0.0 0.0; + offset, 0 0; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + } + } + } + + part { + name, "button_device"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.0 0.0; + offset, 0 0; + } + rel2 { + relative, 0.5 0.2; + offset, 0 0; + } + } + description { + state, "clicked" 0.0; + min, 230 100; + max, 130 100; + align, 0.5 0.5; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.0 0.0; + offset, 0 0; + } + rel2 { + relative, 0.5 0.2; + offset, 0 0; + } + } + } + + part { + name, "button_host"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.5 0.0; + offset, 0 0; + } + rel2 { + relative, 1.0 0.2; + offset, 0 0; + } + } + description { + state, "clicked" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.5 0.0; + offset, 0 0; + } + rel2 { + relative, 1.0 0.2; + offset, 0 0; + } + } + } + + part { + name, "button_dontload"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.0 0.2; + offset, 0 -5; + } + rel2 { + relative, 0.5 0.4; + offset, 0 -5; + } + } + description { + state, "clicked" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.0 0.2; + offset, 0 -5; + } + rel2 { + relative, 0.5 0.4; + offset, 0 -5; + } + } + } + + part { + name, "button_l100"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.5 0.2; + offset, 0 -5; + } + rel2 { + relative, 1.0 0.4; + offset, 0 -5; + } + } + description { + state, "clicked" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.5 0.2; + offset, 0 -5; + } + rel2 { + relative, 1.0 0.4; + offset, 0 -5; + } + } + } + + part { + name, "button_l500"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.0 0.4; + offset, 0 -20; + } + rel2 { + relative, 0.5 0.6; + offset, 0 -20; + } + } + description { + state, "clicked" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.0 0.4; + offset, 0 -20; + } + rel2 { + relative, 0.5 0.6; + offset, 0 -20; + } + } + } + + part { + name, "button_l1000"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.5 0.4; + offset, 0 -20; + } + rel2 { + relative, 1.0 0.6; + offset, 0 -20; + } + } + description { + state, "clicked" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.5 0.4; + offset, 0 -20; + } + rel2 { + relative, 1.0 0.6; + offset, 0 -20; + } + } + } + + part { + name, "button_provide"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + visible: 1; + color, COLOR_DEFAULT; + + rel1 { + relative, 0.0 0.6; + offset, 0 -35; + } + rel2 { + relative, 1.0 0.8; + offset, 0 -35; + } + } + description { + state, "hidden" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.0 0.6; + offset, 0 -35; + } + rel2 { + relative, 1.0 0.8; + offset, 0 -35; + } + visible: 0; + } + description { + state, "clicked" 0.0; + min, 230 100; + max, 230 100; + align, 0.5 0.5; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.0 0.6; + offset, 0 -35; + } + rel2 { + relative, 1.0 0.8; + offset, 0 -35; + } + visible: 1; + } + } + + part { + name, "button_ok"; + type, RECT; + mouse_events, 1; + + description { + state, "default" 0.0; + min, 200 80; + max, 200 80; + align, 0.5 0.0; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.0 0.84; + offset, 0 0; + } + rel2 { + relative, 0.5 1.0; + offset, 0 0; + } + } + description { + state, "clicked" 0.0; + min, 200 80; + max, 200 80; + align, 0.5 0.0; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.0 0.84; + offset, 0 0; + } + rel2 { + relative, 0.5 1.0; + offset, -1 -1; + } + } + } + + part { + name, "button_cancel"; + type, RECT; + mouse_events, 1; + effect, OUTLINE; + + description { + state, "default" 0.0; + min, 200 80; + max, 200 80; + align, 0.5 0.0; + + color, COLOR_DEFAULT; + + rel1 { + relative, 0.5 0.84; + offset, 0 0; + } + rel2 { + relative, 1.0 1.0; + offset, 0 0; + } + } + description { + state, "clicked" 0.0; + min, 200 80; + max, 200 80; + align, 0.5 0.0; + + color, COLOR_CLICKED; + + rel1 { + relative, 0.5 0.84; + offset, 0 0; + } + rel2 { + relative, 1.0 1.0; + offset, 0 0; + } + } + } + + part { + name, "text_device"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_device"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_device"; + } + text { + text, "USB - Device"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + } + part { + name, "text_host"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_host"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_host"; + } + text { + text, "USB - Host"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + } + part { + name, "text_dontload"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_dontload"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_dontload"; + } + text { + text, "Don't Load"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + } + part { + name, "text_l100"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_l100"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_l100"; + } + text { + text, "Load 100mA"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + } + part { + name, "text_l500"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_l500"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_l500"; + } + text { + text, "Load 500mA"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + } + part { + name, "text_l1000"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_l1000"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_l1000"; + } + text { + text, "Load 1A"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + } + part { + name, "text_provide"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + visible: 1; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_provide"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_provide"; + } + text { + text, "Provied Power"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + description { + state, "hidden" 0.0; + visible: 0; + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_provide"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_provide"; + } + text { + text, "Provied Power"; + font, "sans serif"; + size, 26; + align, 0.5 0.5; + } + } + } + part { + name, "text_ok"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_ok"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_ok"; + } + text { + text, "OK"; + font, "sans serif"; + size, 22; + align, 0.5 0.5; + } + } + } + part { + name, "text_cancel"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + rel1 { + + relative, 0.0 0.0; + offset, 0 0; + to, "button_cancel"; + } + rel2 { + relative, 1.0 1.0; + offset, -1 -1; + to, "button_cancel"; + } + text { + text, "CANCEL"; + font, "sans serif"; + size, 22; + align, 0.5 0.5; + } + } + } + part { + name, "text_field"; + type, TEXT; + mouse_events, 0; + + description { + state, "default" 0.0; + + color, 200 000 000 255; + + rel1 { + + relative, 0.0 0.8; + offset, 0 -35; + + } + rel2 { + relative, 1.0 0.83; + offset, -1 -1; + + } + text { + text, ""; + font, "sans serif"; + fit, 1 1; + size, 22; + align, 0.5 0.5; + } + } + } + } /* Close Parts */ + + programs { +//Button_device + program { + name, "device_click"; + signal, "mouse,down,1"; + source, "button_device"; + after, "device_clicked"; + after, "host_default"; + after, "provide_hidden"; + } + + program { + name, "device_clicked"; + signal, "device"; + source, "is_clicked"; + action, STATE_SET "clicked" 0.0; + target, "button_device"; + } + + program { + name, "device_default"; + signal, "device"; + source, "is_default"; + action, STATE_SET "default" 0.0; + target, "button_device"; + } + + program { + name, "device_signal"; + signal, "mouse,down,1"; + source, "button_device"; + action, SIGNAL_EMIT "device" "usbmode"; + in, 0.0 0.0; + } +//Button_host + program { + name, "host_click"; + signal, "mouse,down,1"; + source, "button_host"; + after, "host_clicked"; + after, "device_default"; + after, "provide_default"; + } + + program { + name, "host_clicked"; + signal, "host"; + source, "is_clicked"; + action, STATE_SET "clicked" 0.0; + target, "button_host"; + } + + program { + name, "host_default"; + signal, "host"; + source, "is_default"; + action, STATE_SET "default" 0.0; + target, "button_host"; + } + + program { + name, "host_signal"; + signal, "mouse,down,1"; + source, "button_host"; + action, SIGNAL_EMIT "host" "usbmode"; + in, 0.0 0.0; + } +//Button_dontload + program { + name, "dontload_click"; + signal, "mouse,down,1"; + source, "button_dontload"; + after, "dontload_clicked"; + after, "l100_default"; + after, "l500_default"; + after, "l1000_default"; + } + + program { + name, "dontload_clicked"; + signal, "l0"; + source, "is_clicked"; + action, STATE_SET "clicked" 0.0; + target, "button_dontload"; + } + + program { + name, "dontload_default"; + signal, "l0"; + source, "is_default"; + action, STATE_SET "default" 0.0; + target, "button_dontload"; + } + + program { + name, "dontload_signal"; + signal, "mouse,down,1"; + source, "button_dontload"; + action, SIGNAL_EMIT "0" "power"; + in, 0.0 0.0; + } +//Button_l100 + program { + name, "l100_click"; + signal, "mouse,down,1"; + source, "button_l100"; + after, "l100_clicked"; + after, "dontload_default"; + after, "l500_default"; + after, "l1000_default"; + } + + program { + name, "l100_clicked"; + signal, "l100"; + source, "is_clicked"; + action, STATE_SET "clicked" 0.0; + target, "button_l100"; + } + + program { + name, "l100_default"; + signal, "l100"; + source, "is_default"; + action, STATE_SET "default" 0.0; + target, "button_l100"; + } + + program { + name, "l100_signal"; + signal, "mouse,down,1"; + source, "button_l100"; + action, SIGNAL_EMIT "100" "power"; + in, 0.0 0.0; + } +//Button_l500 + program { + name, "l500_click"; + signal, "mouse,down,1"; + source, "button_l500"; + after, "l500_clicked"; + after, "dontload_default"; + after, "l100_default"; + after, "l1000_default"; + } + + program { + name, "l500_clicked"; + signal, "l500"; + source, "is_clicked"; + action, STATE_SET "clicked" 0.0; + target, "button_l500"; + } + + program { + name, "l500_default"; + signal, "l500"; + source, "is_default"; + action, STATE_SET "default" 0.0; + target, "button_l500"; + } + + program { + name, "l500_signal"; + signal, "mouse,down,1"; + source, "button_l500"; + action, SIGNAL_EMIT "500" "power"; + in, 0.0 0.0; + } +//Button_l1000 + program { + name, "l1000_click"; + signal, "mouse,down,1"; + source, "button_l1000"; + after, "l1000_clicked"; + after, "dontload_default"; + after, "l500_default"; + after, "l100_default"; + } + + program { + name, "l1000_clicked"; + signal, "l1000"; + source, "is_clicked"; + action, STATE_SET "clicked" 0.0; + target, "button_l1000"; + } + + program { + name, "l1000_default"; + signal, "l1000"; + source, "is_default"; + action, STATE_SET "default" 0.0; + target, "button_l1000"; + } + + program { + name, "l1000_signal"; + signal, "mouse,down,1"; + source, "button_l1000"; + action, SIGNAL_EMIT "1000" "power"; + in, 0.0 0.0; + } +//Button_provide + program { + name, "provide_click"; + signal, "mouse,down,1"; + source, "button_provide"; + after, "provide_clicked"; + after, "l100_default"; + after, "dontload_default"; + after, "l500_default"; + after, "l1000_default"; + } + + program { + name, "provide_clicked"; + signal, "l-500"; + source, "is_clicked"; + action, STATE_SET "clicked" 0.0; + target, "button_provide"; + } + + program { + name, "provide_default"; + signal, "l-500"; + source, "is_default"; + action, STATE_SET "default" 0.0; + target, "button_provide"; + target, "text_provide"; + } + + program { + name, "provide_hidden"; + signal, "hide_provide"; + action, STATE_SET "hidden" 0.0; + target, "button_provide"; + target, "text_provide"; + } + + program { + name, "provide_signal"; + signal, "mouse,down,1"; + source, "button_provide"; + action, SIGNAL_EMIT "-500" "power"; + in, 0.0 0.0; + } +//Button_ok + program { + name, "ok_click"; + signal, "mouse,down,1"; + source, "button_ok"; + action, STATE_SET "clicked" 0.0; + target, "button_ok"; + } + + program { + name, "ok_unclick"; + signal, "mouse,up,1"; + source, "button_ok"; + action, STATE_SET "default" 0.0; + target, "button_ok"; + } + + program { + name, "ok_signal"; + signal, "mouse,down,1"; + source, "button_ok"; + action, SIGNAL_EMIT "ok" "programm"; + in, 0.0 0.0; + } +//Button_cancle + program { + name, "cancel_click"; + signal, "mouse,down,1"; + source, "button_cancel"; + action, STATE_SET "clicked" 0.0; + target, "button_cancel"; + } + + program { + name, "cancel_unclick"; + signal, "mouse,up,1"; + source, "button_cancel"; + action, STATE_SET "default" 0.0; + target, "button_cancel"; + } + + program { + name, "cancel_signal"; + signal, "mouse,down,1"; + source, "button_cancel"; + action, SIGNAL_EMIT "cancel" "programm"; + in, 0.0 0.0; + } + + + + } /* Close Prog */ + } /* Close Group */ +} /* Close Coll */ diff --git a/PyBat/trunk/PyBat.edj b/PyBat/trunk/PyBat.edj new file mode 100644 index 0000000000000000000000000000000000000000..3da3fd26427ff4326716f9dfa2f21d900a26f11f GIT binary patch literal 12197 zcmaKv2|QKX`~P<-4VMP<5K2V@GDMn4lnh0~EonFo=iuaUbj~p*bQ`JAZ4wolH4mC@ zWr#G1ZW>6@Eup$94T_@wXYI3(yZL=z|E=dd>v`{It@W&DO*{Si{!=N6Qh@xTsKFW( z)q6BWJ)A^QYE!`aL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{!8*^ZG3%QeGZ$L;?ww>(aQgN)1J&HohkpE> z-7tIk`@jl^LC;;MKXESH{>sqGC}pfq&f&^!Ok`n+hUIl z_pbD`+I%tbYcx+K&uaR(bk)RLyYDX@AMKkp$V<}u-hj8(S$}jts4&wiLao$6sFQlQ zac1`@;irBrkJ73I)wUFM$07H*8kvQW z_p_w;zYfb>&1;X}eV}lv%lbDi>t%)8F6(!t^lNch@BQ>oGq3V9Jmr*(m)#Cr&J^knzSoC)SeFv?J94RS ZiodgEhWdtuDJ6cZpZ20oZB?4|{{UDHkF5Xz literal 0 HcmV?d00001 diff --git a/PyBat/trunk/PyBat.py b/PyBat/trunk/PyBat.py new file mode 100644 index 0000000..87e44ff --- /dev/null +++ b/PyBat/trunk/PyBat.py @@ -0,0 +1,176 @@ +#!/usr/bin/python +''' +authors: Pau1us +license: gpl v2 or later +''' + +import ecore +import ecore.evas +import edje +import sys +import os +import e_dbus +from dbus import SystemBus, Interface + +# Parse command line +from optparse import OptionParser + +def parse_geometry(option, opt, value, parser): + try: + w, h = value.split("x") + w = int(w) + h = int(h) + except Exception, e: + raise optparse.OptionValueError("Invalid format for %s" % option) + parser.values.geometry = (w, h) + +usage = "usage: %prog [options]" +op = OptionParser(usage=usage) +op.add_option("-e", "--engine", type="choice", + choices=("x11", "x11-16"), default="x11-16", + help=("which display engine to use (x11, x11-16), " + "default=%default")) +op.add_option("-n", "--no-fullscreen", action="store_true", + help="do not launch in fullscreen") +op.add_option("-g", "--geometry", type="string", metavar="WxH", + action="callback", callback=parse_geometry, + default=(480, 640), + help="use given window geometry") +op.add_option("-f", "--fps", type="int", default=50, + help="frames per second to use, default=%default") + + +# Handle options and create output window +options, args = op.parse_args() +if options.engine == "x11": + f = ecore.evas.SoftwareX11 +elif options.engine == "x11-16": + if ecore.evas.engine_type_supported_get("software_x11_16"): + f = ecore.evas.SoftwareX11_16 + else: + print "warning: x11-16 is not supported, fallback to x11" + f = ecore.evas.SoftwareX11 + +w, h = options.geometry +ee = f(w=w, h=h) +ee.fullscreen = 0 # not options.no_fullscreen +edje.frametime_set(1.0 / options.fps) + + +# Load and setup UI +ee.title = "PyBat" +ee.name_class = ("pybat", "pybat") +canvas = ee.evas +edje_file = os.path.join(os.path.dirname(sys.argv[0]), "PyBat.edj") +#edje_file = 'PyBat.edj' +try: + edje_obj = edje.Edje(canvas, file=edje_file, group="main") +except Exception, e: # should be EdjeLoadError, but it's wrong on python2.5 + raise SystemExit("Failed to load Edje file: %s" % edje_file) + +# resize edje to fit our window, show and remember it for later use +edje_obj.size = canvas.size +edje_obj.show() +ee.data["edje"] = edje_obj + + +# Setup callbacks for resize, keydown and selected item +def resize_cb(ee): + r = ee.evas.rect + ee.data["edje"].size = r.size + +ee.callback_resize = resize_cb + + +def key_down_cb(bg, event, ee): + k = event.key + if k == "Escape": + ecore.main_loop_quit() + if k in ("F6", "f"): + ee.fullscreen = not ee.fullscreen + +edje_obj.on_key_down_add(key_down_cb, ee) + + +class PyBatclass: + def __init__(self, edje_obj): +#open sys-devices + self.filePower = os.open( "/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/force_usb_limit_dangerous", os.O_RDWR ) + self.filePowerread = os.open( "/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/usb_curlim", os.O_RDONLY ) + self.fileusbmode = os.open( "/sys/devices/platform/s3c2410-ohci/usb_mode", os.O_RDWR ) + self.filehostmode = os.open( "/sys/devices/platform/neo1973-pm-host.0/hostmode", os.O_RDWR ) +#read default values + self.mode = str(os.read(self.fileusbmode, 6)) + self.power = str(os.read(self.filePowerread, 4)) + self.mode = self.mode.split()[0] + self.power = self.power.split()[0] + print self.mode + print "l%st" % (self.power) + edje_obj.signal_emit("%s" % (self.mode), "is_clicked") + edje_obj.signal_emit("l%s" % (self.power), "is_clicked") +#open dbus + self.systembus=systembus = SystemBus(mainloop=e_dbus.DBusEcoreMainLoop()) + self.odeviced_proxy = self.systembus.get_object('org.freesmartphone.odeviced', '/org/freesmartphone/Device/PowerControl/UsbHost') + self.PowerControl_iface = Interface(self.odeviced_proxy, 'org.freesmartphone.Device.PowerControl') + def write_data(self, usbmode, power): + if usbmode == "host": + if power == "-500": + #dbus: + self.PowerControl_iface.SetPower(1) + else: + os.write(self.fileusbmode, "host") + print "#echo host > /sys/devices/platform/s3c2410-ohci/usb_mode" + os.write(self.filehostmode, "0") + print "#echo 0 > /sys/devices/platform/neo1973-pm-host.0/hostmode" + os.write(self.filePower, power) + print "#echo %s > /sys/class/i2c-adapter/i2c-0/0-0073/force_usb_limit_dangerous" % (power) + elif usbmode == "device": + if power == "-500": + print "won't work!" + else: + #dbus: + self.PowerControl_iface.SetPower(0) + print "#echo device > /sys/devices/platform/s3c2410-ohci/usb_mode" + print "#echo 0 > /sys/devices/platform/neo1973-pm-host.0/hostmode" + os.write(self.filePower, power) + print "#echo %s > /sys/class/i2c-adapter/i2c-0/0-0073/force_usb_limit_dangerous" % (power) + + def button_pressed(self, edje_obj, signal, source): + if source == "usbmode": #host or device + self.mode = signal + if self.mode == "device" and self.power == "-500": + edje_obj.part_text_set("text_field", "won't work!") + else: + edje_obj.part_text_set("text_field", "") + elif source == "power": #set charging speed + self.power = signal + if signal != "-500": + if self.mode == "device": + edje_obj.signal_emit("hide_provide", "") + elif self.mode == "host": + edje_obj.signal_emit("l-500", "is_default") + if signal == "0": + edje_obj.part_text_set("text_field", "") + elif signal == "100": + edje_obj.part_text_set("text_field", "") + elif signal == "500": + edje_obj.part_text_set("text_field", "make shure your charger can provide 0.5A") + elif signal == "1000": + edje_obj.part_text_set("text_field", "make shure your charger can provide 1A") + elif signal == "-500": + edje_obj.part_text_set("text_field", "") + elif source == "programm": + if signal == "ok": #write data and quit + self.write_data(self.mode, self.power) + ecore.main_loop_quit() + elif signal == "cancel": #quit + ecore.main_loop_quit() + +test = PyBatclass(edje_obj) +edje_obj.signal_callback_add("*", "*", test.button_pressed) +#edje_obj.signal_callback_add("StopSelected", "*", icon_selected) + +# Give focus to object, show window and enter event loop +edje_obj.focus = True +ee.show() +ecore.main_loop_begin() diff --git a/PyBat/trunk/README b/PyBat/trunk/README new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/PyBat/trunk/README @@ -0,0 +1 @@ +