From 0e05f94c23f7704745cd1db13f99a35871b3731b Mon Sep 17 00:00:00 2001 From: Mike Zingman Date: Sun, 13 Sep 2020 22:58:08 -0400 Subject: [PATCH 1/2] Toast changes --- pyUC.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/pyUC.py b/pyUC.py index 39a4afa..c60ed74 100755 --- a/pyUC.py +++ b/pyUC.py @@ -97,6 +97,7 @@ transmit_enable = True # Make sure that UC is half duplex useQRZ = True level_every_sample = 1 +NAT_ping_timer = 0 listbox = None # tk object (talkgroup) transmitButton = None # tk object @@ -240,7 +241,10 @@ def showQRZImage( msg, in_label ): current_name.set(msg[3]) ################################################################################### - +def ping_thread(): + while done == False: + sleep(20.0) + sendUSRPCommand(bytes("PING", 'ASCII'), USRP_TYPE_PING) ################################################################################### # Log output to console @@ -943,6 +947,8 @@ def disconnect(): ################################################################################### def popup_toast(msg): global toast_frame + if toast_frame != None: # If a toast is still on the screen, kill it first + toast_frame.destroy() toast_frame = Toplevel() toast_frame.wm_title(msg[1]) toast_frame.overrideredirect(1) @@ -956,13 +962,16 @@ def popup_toast(msg): toast_frame.after(2000, toast_fade_away) def toast_fade_away(): - alpha = toast_frame.attributes("-alpha") - if alpha > 0: - alpha -= .1 - toast_frame.attributes("-alpha", alpha) - toast_frame.after(100, toast_fade_away) - else: - toast_frame.destroy() + global toast_frame + if toast_frame != None: + alpha = toast_frame.attributes("-alpha") + if alpha > 0: + alpha -= .1 + toast_frame.attributes("-alpha", alpha) + toast_frame.after(100, toast_fade_away) + else: + toast_frame.destroy() + toast_frame = None def process_queue(): try: @@ -1559,6 +1568,7 @@ def popupFocusOut(self,event=None): asl_mode = makeTkVar(IntVar, config.get('DEFAULTS', "aslMode").split(None)[0]) useQRZ = bool(readValue(config, 'DEFAULTS', 'useQRZ', True, int)) level_every_sample = int(readValue(config, 'DEFAULTS', 'levelEverySample', 2, int)) + NAT_ping_timer = int(readValue(config, 'DEFAULTS', 'pingTimer', 0, int)) in_index = readValue(config, 'DEFAULTS', 'in_index', None, int) out_index = readValue(config, 'DEFAULTS', 'out_index', None, int) @@ -1611,6 +1621,8 @@ def popupFocusOut(self,event=None): if in_index != -1: # Do not launch the TX thread if the user wants RX only access _thread.start_new_thread( txAudioStream, () ) _thread.start_new_thread( html_thread, () ) # Start up the HTML thread for background image loads +if NAT_ping_timer > 0: + _thread.start_new_thread( ping_thread, () ) disconnect() # Start out in the disconnected state start() # Begin the handshake with AB (register) From dee07711c53bea08971d7746566ac5c355bd5331 Mon Sep 17 00:00:00 2001 From: Forrest Fleming Date: Tue, 13 Oct 2020 13:53:02 -0700 Subject: [PATCH 2/2] Allow devices to be both input and output Audio interfaces (e.g. Scarlett FocusRite serises) act as both input and output, so it is incorrect to assume that they are exclusive categories. --- pyUC.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyUC.py b/pyUC.py index c60ed74..afb4ba4 100755 --- a/pyUC.py +++ b/pyUC.py @@ -691,7 +691,8 @@ def listAudioDevices(want_input): numdevices = info.get('deviceCount') for i in range(0, numdevices): is_input = p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels') > 0 - if (is_input and want_input) or (want_input == False and is_input == False): + is_output = p.get_device_info_by_host_api_device_index(0, i).get('maxOutputChannels') > 0 + if (is_input and want_input) or (want_input == False and is_output): devices.append(p.get_device_info_by_host_api_device_index(0, i).get('name')) logging.info("Device id {} - {}".format(i, p.get_device_info_by_host_api_device_index(0, i).get('name'))) return devices