aboutsummaryrefslogtreecommitdiff
path: root/ParrotZikTray
diff options
context:
space:
mode:
authorMarek Siarkowicz <mareksiarkowicz@gmail.com>2015-06-12 19:41:13 +0200
committerMarek Siarkowicz <mareksiarkowicz@gmail.com>2015-06-12 20:12:54 +0200
commit3093abbcd7d08680bf39ab2e9d404faecb433965 (patch)
tree53afbb329cda6d14a9f78706acb983129ecb0e82 /ParrotZikTray
parent0b259b140bfa455ff65cbe74907286d87de15d2e (diff)
downloadpyParrotZikTCP-3093abbcd7d08680bf39ab2e9d404faecb433965.tar.xz
pyParrotZikTCP-3093abbcd7d08680bf39ab2e9d404faecb433965.zip
Refactor.
Diffstat (limited to 'ParrotZikTray')
-rwxr-xr-xParrotZikTray23
1 files changed, 12 insertions, 11 deletions
diff --git a/ParrotZikTray b/ParrotZikTray
index bd85db5..1e32e23 100755
--- a/ParrotZikTray
+++ b/ParrotZikTray
@@ -4,9 +4,10 @@ import ParrotZik
import BluetoothPairedDevices
from SysIndicator import *
-UPDATE_FREQUENCY = 1000
+REFRESH_FREQUENCY = 1000
RECONNECT_FREQUENCY = 5000
+
class repeat(object):
def __init__(self, f):
self.f = f
@@ -48,35 +49,35 @@ class ParrotZikIndicator(SysIndicator):
self.active_interface = None
@repeat
- def EstablishConnection(self):
+ def reconnect(self):
if self.active_interface:
if not self.active_interface.parrot.sock:
print "Lost connection"
self.active_interface.deactivate()
else:
- self.EstablishConnection.stop()
+ self.reconnect.stop()
else:
mac = BluetoothPairedDevices.ParrotZikMac()
if mac:
parrot = ParrotZik.ParrotZik(mac)
if parrot.sock:
self.version_1_interface.activate(parrot)
- self.CheckBattery.start(self, UPDATE_FREQUENCY)
- self.EstablishConnection.stop()
+ self.autorefresh.start(self, REFRESH_FREQUENCY)
+ self.reconnect.stop()
print "Connected"
else:
print "Failed to connect to Parrot Zik %s" % mac
@repeat
- def CheckBattery(self):
+ def autorefresh(self):
if self.active_interface:
- self.active_interface.CheckBattery()
+ self.active_interface.refresh()
else:
- self.EstablishConnection.start(self, RECONNECT_FREQUENCY)
- self.CheckBattery.stop()
+ self.reconnect.start(self, RECONNECT_FREQUENCY)
+ self.autorefresh.stop()
def main(self):
- self.EstablishConnection.start(self, RECONNECT_FREQUENCY)
+ self.reconnect.start(self, RECONNECT_FREQUENCY)
SysIndicator.main(self)
class ParrotZikBaseInterface(object):
@@ -204,7 +205,7 @@ class ParrotZikVersion1Interface(ParrotZikBaseInterface):
else:
self.parrot.concert_hall = "false"
- def CheckBattery(self):
+ def refresh(self):
if self.connected:
print "Updating battery"
self.batteryLevel = int(self.parrot.battery_level)