diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-06-06 18:15:26 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-06-06 18:15:26 +0200 |
commit | 28c0ca2514219752c2f045d0933d5aad13a08f0b (patch) | |
tree | 13762bb960b5923f883965a52008925274d4e580 /sw | |
parent | 2eaaba31201bb8483c46f2e3e6195d14d1dae8e2 (diff) | |
download | picardy-28c0ca2514219752c2f045d0933d5aad13a08f0b.tar.gz picardy-28c0ca2514219752c2f045d0933d5aad13a08f0b.tar.bz2 picardy-28c0ca2514219752c2f045d0933d5aad13a08f0b.zip |
Improve gui
Diffstat (limited to 'sw')
-rwxr-xr-x | sw/eval-clock-cw-tx/gui.py | 30 |
1 files changed, 16 insertions, 14 deletions
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) |