Skip to content

Commit 6fec273

Browse files
authored
Merge pull request #46 from ke5gdb/pyqt6
Update Horus GUI to PyQt6
2 parents a9d5033 + c415802 commit 6fec273

File tree

13 files changed

+1487
-1613
lines changed

13 files changed

+1487
-1613
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ $ cd horusdemodlib && mkdir build && cd build
5656
$ cmake ..
5757
$ make
5858
$ sudo make install
59+
$ sudo ldconfig
5960
```
6061

6162
### Grab this Repo

horusgui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.19"
1+
__version__ = "0.4.0"

horusgui/audio.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Audio Interfacing
22
import logging
33
import pyaudio
4+
import time
45

56

67
# Global PyAudio object
@@ -125,8 +126,14 @@ def __init__(self, audio_device, fs, block_size=8192, fft_input=None, modem=None
125126
self.modem = modem
126127
self.stats_callback = stats_callback
127128

128-
# Start audio stream
129+
self.audio_thread_running = True
130+
129131
self.audio = pyaudio.PyAudio()
132+
133+
def start_stream(self, info_callback=None):
134+
if info_callback:
135+
self.stats_callback = info_callback
136+
130137
self.stream = self.audio.open(
131138
format=pyaudio.paInt16,
132139
channels=1,
@@ -138,6 +145,11 @@ def __init__(self, audio_device, fs, block_size=8192, fft_input=None, modem=None
138145
stream_callback=self.handle_samples,
139146
)
140147

148+
while self.audio_thread_running:
149+
time.sleep(0.5)
150+
151+
logging.debug("Stopped audio stream thread")
152+
141153
def handle_samples(self, data, frame_count, time_info="", status_flags=""):
142154
""" Handle incoming samples from pyaudio """
143155

@@ -151,10 +163,11 @@ def handle_samples(self, data, frame_count, time_info="", status_flags=""):
151163
# Send any stats data back to the stats callback
152164
if _stats:
153165
if self.stats_callback:
154-
self.stats_callback(_stats)
166+
self.stats_callback.emit(_stats)
155167

156168
return (None, pyaudio.paContinue)
157169

158170
def stop(self):
159171
""" Halt stream """
160-
self.stream.close()
172+
self.audio_thread_running = False
173+
self.stream.close()

horusgui/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
"rotator_type": "rotctld",
3535
"rotator_host": "localhost",
3636
"rotator_port": 4533,
37+
"rotator_rangeinhibit": True,
3738
"logging_enabled": False,
3839
"log_format": "CSV",
3940
"log_directory": "",
41+
"fft_smoothing": False,
4042
"payload_list": json.dumps(horusdemodlib.payloads.HORUS_PAYLOAD_LIST),
4143
"custom_field_list": json.dumps({})
4244
}
@@ -76,7 +78,7 @@ def read_config(widgets):
7678
global qt_settings, default_config
7779

7880
# This is getting a bit ridiculous, need to re-think this approach.
79-
OK_VERSIONS = [__version__, '0.3.18', '0.3.17', '0.3.16', '0.3.15', '0.3.14', '0.3.13', '0.3.12', '0.3.11', '0.3.10', '0.3.9', '0.3.8', '0.3.7', '0.3.6', '0.3.5', '0.3.4', '0.3.1', '0.2.1']
81+
OK_VERSIONS = [__version__,'0.3.19', '0.3.18', '0.3.17', '0.3.16', '0.3.15', '0.3.14', '0.3.13', '0.3.12', '0.3.11', '0.3.10', '0.3.9', '0.3.8', '0.3.7', '0.3.6', '0.3.5', '0.3.4', '0.3.1', '0.2.1']
8082

8183
# Try and read in the version parameter from QSettings
8284
if qt_settings.value("version") not in OK_VERSIONS:
@@ -124,12 +126,15 @@ def read_config(widgets):
124126
widgets["rotatorTypeSelector"].setCurrentText(default_config["rotator_type"])
125127
widgets["rotatorHostEntry"].setText(str(default_config["rotator_host"]))
126128
widgets["rotatorPortEntry"].setText(str(default_config["rotator_port"]))
129+
widgets["rotatorRangeInhibit"].setChecked(ValueToBool(default_config["rotator_rangeinhibit"]))
127130

128131
# Logging Settings
129132
widgets["loggingPathEntry"].setText(str(default_config["log_directory"]))
130133
widgets["loggingFormatSelector"].setCurrentText(default_config["log_format"])
131134
widgets["enableLoggingSelector"].setChecked(ValueToBool(default_config["logging_enabled"]))
132135

136+
widgets["fftSmoothingSelector"].setChecked(ValueToBool(default_config["fft_smoothing"]))
137+
133138
if default_config['baud_rate'] != -1:
134139
widgets["horusModemRateSelector"].setCurrentText(str(default_config['baud_rate']))
135140

@@ -173,9 +178,11 @@ def save_config(widgets):
173178
default_config["rotator_type"] = widgets["rotatorTypeSelector"].currentText()
174179
default_config["rotator_host"] = widgets["rotatorHostEntry"].text()
175180
default_config["rotator_port"] = int(widgets["rotatorPortEntry"].text())
181+
default_config["rotator_rangeinhibit"] = widgets["rotatorRangeInhibit"].isChecked()
176182
default_config["logging_enabled"] = widgets["enableLoggingSelector"].isChecked()
177183
default_config["log_directory"] = widgets["loggingPathEntry"].text()
178184
default_config["log_format"] = widgets["loggingFormatSelector"].currentText()
185+
default_config["fft_smoothing"] = widgets["fftSmoothingSelector"].isChecked()
179186

180187
default_config["payload_list"] = json.dumps(horusdemodlib.payloads.HORUS_PAYLOAD_LIST)
181188
default_config["custom_field_list"] = json.dumps(horusdemodlib.payloads.HORUS_CUSTOM_FIELDS)

horusgui/fft.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import time
44
import numpy as np
55
from queue import Queue
6-
from threading import Thread
6+
#from threading import Thread
77

88

99
class FFTProcess(object):
@@ -37,8 +37,8 @@ def __init__(
3737

3838
self.processing_thread_running = True
3939

40-
self.t = Thread(target=self.processing_thread)
41-
self.t.start()
40+
#self.t = Thread(target=self.processing_thread)
41+
#self.t.start()
4242

4343
def init_window(self):
4444
""" Initialise Window functions and FFT scales. """
@@ -74,7 +74,7 @@ def perform_fft(self):
7474

7575
if self.callback != None:
7676
if self.update_counter % self.update_decimation == 0:
77-
self.callback({"fft": _fft[self.mask], "scale": self.fft_scale[self.mask], 'dbfs': _dbfs})
77+
self.callback.emit({"fft": _fft[self.mask], "scale": self.fft_scale[self.mask], 'dbfs': _dbfs})
7878

7979
self.update_counter += 1
8080

@@ -86,7 +86,9 @@ def process_block(self, samples):
8686
while len(self.sample_buffer) > self.nfft * self.sample_width:
8787
self.perform_fft()
8888

89-
def processing_thread(self):
89+
def processing_thread(self, info_callback=None):
90+
if info_callback:
91+
self.callback = info_callback
9092

9193
while self.processing_thread_running:
9294
if self.input_queue.qsize() > 0:
@@ -95,6 +97,8 @@ def processing_thread(self):
9597
else:
9698
time.sleep(0.01)
9799

100+
logging.debug("Stopped FFT processing thread")
101+
98102
def add_samples(self, samples):
99103
""" Add a block of samples to the input queue """
100104
try:

0 commit comments

Comments
 (0)