Added a simple GUI. Made it so you can toggle on/off "Rig-to-GQRX" and "GQRX-to-Rig". Some of the cases aren't quite right, however. Need to separate out the LNB frequency, and make LNB frequency ALWAYS get updated based on the rig frequency, regardless of whether the the rig frequency is being used to set the GQRX frequency.
This commit is contained in:
parent
df4b6e419c
commit
769e1ca274
@ -23,6 +23,9 @@ import argparse
|
||||
import socket
|
||||
import time
|
||||
|
||||
import Tkinter
|
||||
from Tkinter import *
|
||||
|
||||
DEBUG=True
|
||||
|
||||
# States
|
||||
@ -41,6 +44,62 @@ lsb_if_offset = -1000 #0
|
||||
rs = 0
|
||||
gs = 0
|
||||
|
||||
#class TmpSettings:
|
||||
# def __init__(self):
|
||||
# self.RIG_TO_GQRX = IntVar(1)
|
||||
# self.GQRX_TO_RIG = IntVar(1)
|
||||
|
||||
def freq_to_string(freq):
|
||||
freq_str = str(freq).rjust(9)
|
||||
return freq_str[0:3] + "." + freq_str[3:6] + "." + freq_str[6:9]
|
||||
#MHz = int(freq/1000000)
|
||||
#kHz = int(freq/1000)-(MHz*1000)
|
||||
#Hz = freq - ((MHz*1000000)+(kHz*1000))
|
||||
#return str(MHz) + "." + str(kHz) + "." + str(Hz)
|
||||
|
||||
class MainWindow:
|
||||
def __init__(self, root, rig_name="uBITX"):
|
||||
self.__root = root
|
||||
self.__root.title("Gqrx Panadapter - " + rig_name)
|
||||
|
||||
self.rig_to_gqrx = IntVar()
|
||||
self.gqrx_to_rig = IntVar()
|
||||
self.rig_freq = StringVar()
|
||||
self.gqrx_freq = StringVar()
|
||||
self.rig_mode = StringVar()
|
||||
|
||||
self.__rig_frame = Frame(self.__root, relief=GROOVE, bd=3)
|
||||
self.__rig_frame.grid(row=0, column=0)
|
||||
|
||||
self.__rig_freq_lbl = Label(self.__rig_frame, text="Rig Freq: ")
|
||||
self.__rig_freq_lbl.grid(row=0, column=0, padx=5)
|
||||
|
||||
self.__rig_freq_val = Label(self.__rig_frame, textvariable=self.rig_freq)
|
||||
self.__rig_freq_val.grid(row=0, column=1, padx=5)
|
||||
|
||||
self.__rig_mode_lbl = Label(self.__rig_frame, text="Mode: ")
|
||||
self.__rig_mode_lbl.grid(row=0, column=2, padx=5)
|
||||
|
||||
self.__rig_mode_val = Label(self.__rig_frame, textvariable=self.rig_mode)
|
||||
self.__rig_mode_val.grid(row=0, column=3, padx=5)
|
||||
|
||||
self.__r2g_ctrl = Checkbutton(self.__rig_frame, text="Rig-to-Gqrx", variable=self.rig_to_gqrx)
|
||||
self.__r2g_ctrl.grid(row=0, column=4, padx=5)
|
||||
self.rig_to_gqrx.set(1)
|
||||
|
||||
self.__gqrx_frame = Frame(self.__root, relief=GROOVE, bd=3)
|
||||
self.__gqrx_frame.grid(row=0, column=1)
|
||||
|
||||
self.__gqrx_freq_lbl = Label(self.__gqrx_frame, text="Gqrx Freq: ")
|
||||
self.__gqrx_freq_lbl.grid(row=0, column=0, padx=5)
|
||||
|
||||
self.__gqrx_freq_val = Label(self.__gqrx_frame, textvariable=self.gqrx_freq)
|
||||
self.__gqrx_freq_val.grid(row=0, column=1, padx=5)
|
||||
|
||||
self.__g2r_ctrl = Checkbutton(self.__gqrx_frame, text="Gqrx-to-Rig", variable=self.gqrx_to_rig)
|
||||
self.__g2r_ctrl.grid(row=0, column=2, padx=5)
|
||||
self.gqrx_to_rig.set(1)
|
||||
|
||||
def calc_lnb_lo(freq, ifreq, isusb=True):
|
||||
if DEBUG:
|
||||
print('Freq: ' + str(freq))
|
||||
@ -138,31 +197,43 @@ def main():
|
||||
if_freq = int(args.ifreq * 1e6)
|
||||
old_is_usb = True
|
||||
tmp_is_usb = True
|
||||
old_rig_freq = 0
|
||||
old_gqrx_freq = 0
|
||||
old_rig_freq = -1 # force initial update
|
||||
old_gqrx_freq = -1 # force initial update
|
||||
|
||||
(rig_freq, is_usb) = get_rig_freq(rs)
|
||||
gqrx_freq = get_gqrx_freq(gs)
|
||||
|
||||
state = WAITING
|
||||
|
||||
tk = Tk()
|
||||
window = MainWindow(tk)
|
||||
|
||||
while True:
|
||||
old_is_usb = is_usb
|
||||
old_rig_freq = rig_freq
|
||||
old_gqrx_freq = gqrx_freq
|
||||
allow_rig_to_gqrx = window.rig_to_gqrx.get()
|
||||
allow_gqrx_to_rig = window.gqrx_to_rig.get()
|
||||
|
||||
(rig_freq, is_usb) = get_rig_freq(rs)
|
||||
gqrx_freq = get_gqrx_freq(gs)
|
||||
|
||||
if rig_freq != old_rig_freq:
|
||||
window.rig_freq.set(freq_to_string(rig_freq))
|
||||
if is_usb:
|
||||
window.rig_mode.set("USB")
|
||||
else:
|
||||
window.rig_mode.set("LSB")
|
||||
|
||||
if gqrx_freq != old_gqrx_freq:
|
||||
window.gqrx_freq.set(freq_to_string(gqrx_freq))
|
||||
|
||||
if state == WAITING:
|
||||
if rig_freq != old_rig_freq or is_usb != old_is_usb:
|
||||
if (rig_freq != old_rig_freq or is_usb != old_is_usb) and allow_rig_to_gqrx:
|
||||
set_gqrx_freq(gs, rig_freq, if_freq, is_usb)
|
||||
timeout = time.time() + delay_secs
|
||||
state = RIG_CMD
|
||||
if DEBUG:
|
||||
print("\nNew state: RIG_CMD\n");
|
||||
|
||||
elif gqrx_freq != old_gqrx_freq:
|
||||
elif (gqrx_freq != old_gqrx_freq) and allow_gqrx_to_rig:
|
||||
tmp_is_usb = is_usb
|
||||
set_rig_freq(rs, gs, gqrx_freq, if_freq, tmp_is_usb)
|
||||
timeout = time.time() + delay_secs
|
||||
@ -170,7 +241,7 @@ def main():
|
||||
if DEBUG:
|
||||
print("\nNew state: GQRX_CMD\n");
|
||||
|
||||
elif rig_freq != gqrx_freq:
|
||||
elif (rig_freq != gqrx_freq) and allow_rig_to_gqrx and allow_gqrx_to_rig:
|
||||
set_gqrx_freq(gs, rig_freq, if_freq, is_usb)
|
||||
timeout = time.time() + delay_secs
|
||||
state = RIG_CMD
|
||||
@ -199,7 +270,13 @@ def main():
|
||||
else:
|
||||
pass
|
||||
|
||||
tk.update_idletasks()
|
||||
tk.update()
|
||||
time.sleep(args.interval / 1000.0)
|
||||
|
||||
old_is_usb = is_usb
|
||||
old_rig_freq = rig_freq
|
||||
old_gqrx_freq = gqrx_freq
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user