FEATURE: Added platform detection and got for Backlight and Bluetooth working on GTA02
git-svn-id: http://www.neo1973-germany.de/svn@91 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
25e1cb447f
commit
b0d2be73a9
3 changed files with 81 additions and 21 deletions
|
@ -296,12 +296,24 @@ class BluetoothPanel(gtk.VBox):
|
||||||
def toggle_power(self, event):
|
def toggle_power(self, event):
|
||||||
print "Toggleing Power state!"
|
print "Toggleing Power state!"
|
||||||
if not self.get_power_state():
|
if not self.get_power_state():
|
||||||
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 1)
|
""" power off """
|
||||||
|
if detect_device_type() == "GTA01" and detect_revision() == "":
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA01, 1)
|
||||||
|
else:
|
||||||
|
# invers, bugreport filed under #1703
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA02, 0)
|
||||||
|
|
||||||
self.list_store1.clear()
|
self.list_store1.clear()
|
||||||
self.list_store1.append(("Scanning for ", "Peers...", False))
|
self.list_store1.append(("Scanning for ", "Peers...", False))
|
||||||
self.update_btn.set_active(True)
|
self.update_btn.set_active(True)
|
||||||
else:
|
else:
|
||||||
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 0)
|
""" power on (and reset) """
|
||||||
|
if detect_device_type() == "GTA01" and detect_revision() == "":
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA01, 0)
|
||||||
|
else:
|
||||||
|
# invers, bugreport filed under #1703
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA02, 1)
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_RESET_GTA02, 0)
|
||||||
|
|
||||||
self.power_state_cbtn.set_active(self.get_power_state())
|
self.power_state_cbtn.set_active(self.get_power_state())
|
||||||
|
|
||||||
|
@ -332,7 +344,10 @@ class BluetoothPanel(gtk.VBox):
|
||||||
|
|
||||||
|
|
||||||
def get_power_state(self):
|
def get_power_state(self):
|
||||||
power_value = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER)
|
if detect_device_type() == "GTA01" and detect_revision() == "":
|
||||||
|
power_value = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA01)
|
||||||
|
else:
|
||||||
|
power_value = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER_GTA02)
|
||||||
|
|
||||||
## value will be empty if sysfs entry does not exist
|
## value will be empty if sysfs entry does not exist
|
||||||
if len(power_value) > 0:
|
if len(power_value) > 0:
|
||||||
|
|
|
@ -20,6 +20,23 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
############################ platform detection ################################
|
||||||
|
################################################################################
|
||||||
|
def detect_device_type():
|
||||||
|
cpuinfo = open("/proc/cpuinfo").read(1024)
|
||||||
|
if "GTA02" in cpuinfo:
|
||||||
|
return "GTA02"
|
||||||
|
else:
|
||||||
|
return "GTA01"
|
||||||
|
|
||||||
|
def detect_revision():
|
||||||
|
cpuinfo = open("/proc/cpuinfo").read(1024)
|
||||||
|
if "Revision\t: 0240" in cpuinfo:
|
||||||
|
return "0240"
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#################################### GUI #######################################
|
#################################### GUI #######################################
|
||||||
|
@ -31,14 +48,20 @@ GSM_Panel_Instance = None
|
||||||
################################################################################
|
################################################################################
|
||||||
############################# used in Screen Panel #############################
|
############################# used in Screen Panel #############################
|
||||||
################################################################################
|
################################################################################
|
||||||
SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS = "/sys/class/backlight/gta01-bl/brightness"
|
SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA01 = "/sys/class/backlight/gta01-bl/brightness"
|
||||||
SYSFS_ENTRY_BACKLIGHT_POWER = "/sys/class/backlight/gta01-bl/power" # reverse
|
SYSFS_ENTRY_BACKLIGHT_POWER_GTA01 = "/sys/class/backlight/gta01-bl/power" # reverse
|
||||||
|
|
||||||
|
SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA02 = "/sys/class/backlight/pcf50633-bl/brightness"
|
||||||
|
SYSFS_ENTRY_BACKLIGHT_POWER_GTA02 = "/sys/class/backlight/pcf50633-bl/bl_power"
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
############################ used in Bluetooth Panel ###########################
|
############################ used in Bluetooth Panel ###########################
|
||||||
################################################################################
|
################################################################################
|
||||||
SYSFS_ENTRY_BLUETOOTH_POWER = "/sys/bus/platform/devices/gta01-pm-bt.0/power_on"
|
SYSFS_ENTRY_BLUETOOTH_POWER_GTA01 = "/sys/bus/platform/devices/gta01-pm-bt.0/power_on"
|
||||||
|
|
||||||
|
SYSFS_ENTRY_BLUETOOTH_POWER_GTA02 = "/sys/bus/platform/devices/neo1973-pm-bt.0/power_on"
|
||||||
|
SYSFS_ENTRY_BLUETOOTH_RESET_GTA02 = "/sys/bus/platform/devices/neo1973-pm-bt.0/reset"
|
||||||
|
|
||||||
HCICONFIG_CMD = "hciconfig" ## using $PATH
|
HCICONFIG_CMD = "hciconfig" ## using $PATH
|
||||||
#HCICONFIG_CMD = "/sbin/hciconfig" ## openembedded
|
#HCICONFIG_CMD = "/sbin/hciconfig" ## openembedded
|
||||||
#HCICONFIG_CMD = "/usr/sbin/hciconfig" ## ubuntu
|
#HCICONFIG_CMD = "/usr/sbin/hciconfig" ## ubuntu
|
||||||
|
|
|
@ -37,13 +37,22 @@ class ScreenPanel(gtk.VBox):
|
||||||
|
|
||||||
def toggle_backlight(self, widget):
|
def toggle_backlight(self, widget):
|
||||||
print "trying to toggle the backlight"
|
print "trying to toggle the backlight"
|
||||||
value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER)
|
if detect_device_type() == "GTA01":
|
||||||
if value.find("1") != -1:
|
value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA01)
|
||||||
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER, 0)
|
if value.find("1") != -1:
|
||||||
value = "1"
|
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA01, 0)
|
||||||
else:
|
value = "1"
|
||||||
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER, 1)
|
else:
|
||||||
value = "0"
|
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA01, 1)
|
||||||
|
value = "0"
|
||||||
|
else:
|
||||||
|
value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA02)
|
||||||
|
if value.find("1") != -1:
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA02, 0)
|
||||||
|
value = "1"
|
||||||
|
else:
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER_GTA02, 1)
|
||||||
|
value = "0"
|
||||||
|
|
||||||
def toggle_orientation(self, widget):
|
def toggle_orientation(self, widget):
|
||||||
print "trying to toggle screen orientation"
|
print "trying to toggle screen orientation"
|
||||||
|
@ -67,10 +76,15 @@ class ScreenPanel(gtk.VBox):
|
||||||
|
|
||||||
|
|
||||||
def bl_level_changed(self, widget):
|
def bl_level_changed(self, widget):
|
||||||
tmp_value = widget.value
|
print "trying to set backlight to %s" % widget.value
|
||||||
tmp_value = tmp_value * 50
|
if detect_device_type() == "GTA01":
|
||||||
print "trying to set backlight to %s" % tmp_value
|
tmp_value = widget.value
|
||||||
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS, tmp_value)
|
tmp_value = tmp_value * 50
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA01, tmp_value)
|
||||||
|
else:
|
||||||
|
tmp_value = widget.value
|
||||||
|
tmp_value = int((tmp_value/100.0) * 64)
|
||||||
|
set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA02, tmp_value)
|
||||||
|
|
||||||
def create_notebook_page(self):
|
def create_notebook_page(self):
|
||||||
self.set_border_width(0)
|
self.set_border_width(0)
|
||||||
|
@ -80,11 +94,19 @@ class ScreenPanel(gtk.VBox):
|
||||||
level_box = gtk.VBox(False, 0)
|
level_box = gtk.VBox(False, 0)
|
||||||
level_box.set_border_width(15)
|
level_box.set_border_width(15)
|
||||||
|
|
||||||
init_value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS)
|
if detect_device_type() == "GTA01":
|
||||||
if len(init_value) > 0:
|
init_value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA01)
|
||||||
init_value = float(init_value) / 50
|
if len(init_value) > 0:
|
||||||
|
init_value = float(init_value) / 50
|
||||||
|
else:
|
||||||
|
init_value = 50
|
||||||
else:
|
else:
|
||||||
init_value = 50
|
init_value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS_GTA02)
|
||||||
|
if len(init_value) > 0:
|
||||||
|
init_value = int((float(init_value) / 64.0) * 100)
|
||||||
|
else:
|
||||||
|
init_value = 0.5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## scale to set backlight level
|
## scale to set backlight level
|
||||||
|
|
Loading…
Reference in a new issue