From 28c0ca2514219752c2f045d0933d5aad13a08f0b Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 6 Jun 2021 18:15:26 +0200 Subject: Improve gui --- sw/eval-clock-cw-tx/gui.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'sw') diff --git a/sw/eval-clock-cw-tx/gui.py b/sw/eval-clock-cw-tx/gui.py index 4efde84..2e268e1 100755 --- a/sw/eval-clock-cw-tx/gui.py +++ b/sw/eval-clock-cw-tx/gui.py @@ -22,6 +22,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import os import socket import serial from tkinter import * @@ -59,6 +60,12 @@ class GUI(Frame): if self.last_serial_message.endswith(b"\n"): print(f"< {self.last_serial_message.decode().strip()}") self.set_status(f"Received: {self.last_serial_message.decode().strip()}") + if self.last_serial_message == b"Switch RX\n": + os.system("pactl set-sink-mute 0 0") + elif self.last_serial_message == b"Switch TX\n": + os.system("pactl set-sink-mute 0 1") + elif self.last_serial_message.startswith(b"FH sent"): + self.send_serial(b'rx\n') self.last_serial_message = bytes() except serial.SerialException as e: self.set_status(f"Serial read failed: {e:!r}") @@ -68,6 +75,8 @@ class GUI(Frame): else: self.root.after(1000, self.read_serial) + # For GQRX remote control commands see https://github.com/csete/gqrx/blob/master/resources/remote-control.txt + def fetch_gqrx_freq(self): gqrx_sock = socket.socket() gqrx_sock.settimeout(100) @@ -95,6 +104,9 @@ class GUI(Frame): def terminate(self): print("Terminate: send RX") + self.toggle_to_rx() + + def toggle_to_rx(self): self.send_serial(b'rx\n') def load_macro(self, i): @@ -114,17 +126,8 @@ class GUI(Frame): def send_tx_message(self): msg = self.tx_message.get() - print(f"Send '{msg}'") - self.send_serial('m{}\n'.format(msg).encode("ascii")) - - def toggle_tx_enabled(self): - transmit = self.tx_enabled_var.get() - if transmit: - print("Enable TX") - self.send_serial(b'tx\n') - else: - print("Disable TX") - self.send_serial(b'rx\n') + print(f"TX and Send '{msg}'") + self.send_serial('tx\nm{}\n'.format(msg).encode("ascii")) def create_widgets(self): self.root.columnconfigure(0, weight=1) @@ -185,9 +188,8 @@ class GUI(Frame): self.tx_frame = Frame(self.control_frame, borderwidth=1, relief="ridge") self.tx_frame.grid(column=0, row=2, sticky=(N, S, E, W)) - self.tx_enabled_var = IntVar() - self.tx_checkbutton = Checkbutton(self.tx_frame, text="Transmit", variable=self.tx_enabled_var, command=self.toggle_tx_enabled) - self.tx_checkbutton.grid(column=0, row=0, columnspan=2) + self.tx_button = Button(self.tx_frame, text="Receive!", command=self.toggle_to_rx) + self.tx_button.grid(column=0, row=0, columnspan=2) self.transmit_frame = Frame(self.top_frame, borderwidth=1, relief="ridge") self.transmit_frame.grid(column=0, row=1, columnspan=2) -- cgit v1.2.3