Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nts-python into NicksonYap-master
  • Loading branch information
krichardsson committed Aug 26, 2019
2 parents fb1db30 + e51e2d5 commit 4af02bb
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/cfclient/configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"max_rp": 30,
"client_side_xmode": false,
"auto_reconnect": false,
"keep_alive": false,
"device_config_mapping": {},
"enable_debug_driver": false,
"input_device_blacklist": "(VirtualBox|VMware)",
Expand Down
18 changes: 18 additions & 0 deletions src/cfclient/ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ def __init__(self, *args):
self._auto_reconnect_changed)
self.autoReconnectCheckBox.setChecked(Config().get("auto_reconnect"))

self._keep_alive_enabled = Config().get("keep_alive")
self.keepAliveCheckBox.toggled.connect(
self._keep_alive_changed)
self.keepAliveCheckBox.setChecked(Config().get("keep_alive"))

self._disable_input = False

self.joystickReader.input_updated.add_callback(
Expand Down Expand Up @@ -551,6 +556,19 @@ def _auto_reconnect_changed(self, checked):
Config().set("auto_reconnect", checked)
logger.info("Auto reconnect enabled: {}".format(checked))

def _keep_alive_changed(self, checked):
self._keep_alive_enabled = checked
Config().set("keep_alive", checked)
logger.info("Keep alive enabled: {}".format(checked))

if checked:
cflib.crtp.radiodriver.set_retries_before_disconnect(99999999999999999) # never disconnect :)
cflib.crtp.radiodriver.set_retries(3)
else:
cflib.crtp.radiodriver.set_retries_before_disconnect(1500) # default
cflib.crtp.radiodriver.set_retries(3)


def _show_connect_dialog(self):
self.logConfigDialogue.show()

Expand Down
15 changes: 14 additions & 1 deletion src/cfclient/ui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<layout class="QHBoxLayout" stretch="0,0,1">
<layout class="QHBoxLayout" stretch="0,0,0,1">
<item>
<widget class="QLabel" name="addressLabel">
<property name="text">
Expand Down Expand Up @@ -220,6 +220,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="keepAliveCheckBox">
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="text">
<string>Keep Alive</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
13 changes: 7 additions & 6 deletions src/cfclient/ui/tabs/FlightTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ def _ring_populate_dropdown(self):
12: "Gravity",
13: "LED tab",
14: "Color fader",
15: "Link quality"}
15: "Link quality",
16: "Lighthouse quality"}

for i in range(nbr + 1):
name = "{}: ".format(i)
Expand All @@ -593,7 +594,7 @@ def _ring_populate_dropdown(self):
self._ring_effect_changed)

self._led_ring_effect.setCurrentIndex(current)
if self.helper.cf.mem.ow_search(vid=0xBC, pid=0x01):
if bool(self.helper.cf.param.values["deck"]["bcLedRing"]):
self._led_ring_effect.setEnabled(True)
self._led_ring_headlight.setEnabled(True)

Expand All @@ -617,20 +618,20 @@ def _populate_assisted_mode_dropdown(self):
heightHoldPossible = False
hoverPossible = False

if self.helper.cf.mem.ow_search(vid=0xBC, pid=0x09):
if bool(self.helper.cf.param.values["deck"]["bcZRanger"]):
heightHoldPossible = True
self.helper.inputDeviceReader.set_hover_max_height(1.0)

if self.helper.cf.mem.ow_search(vid=0xBC, pid=0x0E):
if bool(self.helper.cf.param.values["deck"]["bcZRanger2"]):
heightHoldPossible = True
self.helper.inputDeviceReader.set_hover_max_height(2.0)

if self.helper.cf.mem.ow_search(vid=0xBC, pid=0x0A):
if bool(self.helper.cf.param.values["deck"]["bcFlow"]):
heightHoldPossible = True
hoverPossible = True
self.helper.inputDeviceReader.set_hover_max_height(1.0)

if self.helper.cf.mem.ow_search(vid=0xBC, pid=0x0F):
if bool(self.helper.cf.param.values["deck"]["bcFlow2"]):
heightHoldPossible = True
hoverPossible = True
self.helper.inputDeviceReader.set_hover_max_height(2.0)
Expand Down

0 comments on commit 4af02bb

Please sign in to comment.