aboutsummaryrefslogtreecommitdiff
path: root/ParrotZikTray
diff options
context:
space:
mode:
authorm0sia <m0sia@m0sia.ru>2016-02-18 15:04:42 -0600
committerm0sia <m0sia@m0sia.ru>2016-02-18 15:04:42 -0600
commit52c1c1f9d06631b94c3b8ce8eaf816c5a36842b3 (patch)
tree020f823cf692d1ce6898649a15c7633c831dd972 /ParrotZikTray
parentf57d9a8d4ebc30effbec71382cce7e0a37b697e3 (diff)
parent92e47683fc783a2dbd3d9737af40eb0b3372af61 (diff)
downloadpyParrotZikTCP-52c1c1f9d06631b94c3b8ce8eaf816c5a36842b3.tar.xz
pyParrotZikTCP-52c1c1f9d06631b94c3b8ce8eaf816c5a36842b3.zip
Merge pull request #12 from serathius/master
Rework and Zik 2.0 implementation.
Diffstat (limited to 'ParrotZikTray')
-rwxr-xr-xParrotZikTray174
1 files changed, 0 insertions, 174 deletions
diff --git a/ParrotZikTray b/ParrotZikTray
deleted file mode 100755
index d9bdbc1..0000000
--- a/ParrotZikTray
+++ /dev/null
@@ -1,174 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import gtk
-import re
-import os
-import ParrotZik
-import BluetoothPairedDevices
-from SysIndicator import *
-
-UPDATE_FREQUENCY = 30 # seconds
-
-class ParrotZikIndicator(SysIndicator):
- def __init__(self):
-
- self.menu = UniversalMenu()
-
- self.info_item = MenuItem("Parrot Zik Not connected..",None,sensitive = False)
- self.menu.append(self.info_item)
-
- self.battery_level = MenuItem("Battery Level:",None,sensitive = False)
- self.menu.append(self.battery_level)
-
- self.battery_state = MenuItem("Battery State:",None,sensitive = False)
- self.menu.append(self.battery_state)
-
- self.firmware_version = MenuItem("Firmware Version:",None,sensitive = False)
- self.menu.append(self.firmware_version)
-
- self.check = MenuItem("Noise Cancellation",self.toggleANC,sensitive = False, checkitem = True)
- self.menu.append(self.check)
-
- self.check2 = MenuItem("Auto Connection",self.toggleAuto,sensitive = False, checkitem = True)
- self.menu.append(self.check2)
-
- self.check3 = MenuItem("Lou Reed Mode",self.toggleLouReedMode,sensitive = False, checkitem = True)
- self.menu.append(self.check3)
-
- self.check4 = MenuItem("Concert Hall Mode",self.toggleParrotConcertHall,sensitive = False, checkitem = True)
- self.menu.append(self.check4)
-
- self.quit = MenuItem("Quit",sys.exit,sensitive = True, checkitem = True)
- self.menu.append(self.quit)
-
- SysIndicator.__init__(self,icon = "zik-audio-headset",menu = self.menu)
-
- self.connected=False
- self.p = re.compile('90:03:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}')
-
- def EstablishConnection(self):
- if self.connected:
- if not self.parrot.sock:
- print "Lost connection"
- self.connected = False
- else:
- print "Connection already established"
- else:
- mac=BluetoothPairedDevices.ParrotZikMac()
- if mac:
- self.parrot = ParrotZik.ParrotZik(mac)
- if not self.parrot.sock:
- print "Failed to connect to Parrot Zik %s" % mac
- return False
-
- self.connected = True
- self.name = self.parrot.getFriendlyName()
- self.version = self.parrot.getVersion()
-
- self.check.set_sensitive(True)
- self.check2.set_sensitive(True)
- self.check3.set_sensitive(True)
- self.check4.set_sensitive(True)
-
- if self.parrot.getNoiseCancel() == "true":
- self.check.set_active(True)
- else:
- self.check.set_active(False)
-
- if self.parrot.getAutoConnection() == "true":
- self.check2.set_active(True)
- else:
- self.check2.set_active(False)
-
- if self.parrot.getLouReedMode() == "true":
- self.check3.set_active(True)
- else:
- self.check3.set_active(False)
-
- if self.parrot.getParrotConcertHall() == "true":
- self.check4.set_active(True)
- else:
- self.check4.set_active(False)
-
- self.CheckBattery()
- return True
-
- def toggleANC(self,widget):
- if self.connected:
- if self.check.get_active():
- self.parrot.setNoiseCancel("true")
- else:
- self.parrot.setNoiseCancel("false")
-
- def toggleAuto(self,widget):
- if self.connected:
- if self.check2.get_active():
- self.parrot.setAutoConnection("true")
- else:
- self.parrot.setAutoConnection("false")
-
- def toggleLouReedMode(self,widget):
- if self.connected:
- if self.check3.get_active():
- self.parrot.setLouReedMode("true")
- self.check4.set_sensitive(False)
- else:
- self.parrot.setLouReedMode("false")
- self.check4.set_sensitive(True)
-
- def toggleParrotConcertHall(self,widget):
- if self.connected:
- if self.check4.get_active():
- self.parrot.setParrotConcertHall("true")
- else:
- self.parrot.setParrotConcertHall("false")
-
- def CheckBattery(self):
- if self.connected:
- print "Updating battery"
- self.batteryLevel = int(self.parrot.getBatteryLevel())
-
- if self.parrot.BatteryCharging:
- self.batteryLevel = "Charging"
- self.setIcon("zik-battery-charging")
- self.batteryLevel="Unknown"
- self.batteryState="Charging"
- elif self.batteryLevel>80:
- self.setIcon("zik-battery-100")
- self.batteryState="In Use"
- elif self.batteryLevel>60:
- self.setIcon("zik-battery-080")
- self.batteryState="In Use"
- elif self.batteryLevel>40:
- self.setIcon("zik-battery-060")
- self.batteryState="In Use"
- elif self.batteryLevel>20:
- self.setIcon("zik-battery-040")
- self.batteryState="In Use"
- else:
- self.setIcon("zik-battery-low")
- self.batteryState="In Use"
-
- self.info_item.set_label("Connected to: "+self.name)
- self.firmware_version.set_label("Firmware version: "+self.version)
- self.battery_state.set_label("State: "+self.batteryState)
- self.battery_level.set_label("Battery Level: "+str(self.batteryLevel))
- else:
- self.setIcon("zik-audio-headset")
- self.info_item.set_label("Parrot Zik Not connected..")
- self.check.set_sensitive(False)
- self.check2.set_sensitive(False)
- self.check3.set_sensitive(False)
- self.check4.set_sensitive(False)
- return True
-
- def main(self):
- self.EstablishConnection()
- gtk.timeout_add(UPDATE_FREQUENCY * 1000, self.EstablishConnection)
- gtk.timeout_add(UPDATE_FREQUENCY * 1000, self.CheckBattery)
- SysIndicator.main(self)
-
-if __name__ == "__main__":
- indicator = ParrotZikIndicator()
- indicator.main() \ No newline at end of file