Skip to content

Commit

Permalink
additional type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
john committed Mar 6, 2024
1 parent 27aef92 commit 74fecec
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 74 deletions.
22 changes: 11 additions & 11 deletions apps/cursesgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ class SpectrumWindow(object):
screen (object): a curses screen object
Attributes:
max_db (float): Top of window in dB
min_db (float): Bottom of window in dB
threshold_db (float): Threshold horizontal line
max_db (int): Top of window in dB
min_db (int): Bottom of window in dB
threshold_db (int): Threshold horizontal line
"""
def __init__(self, screen):
self.screen = screen

# Set default values
self.max_db = 50.0
self.min_db = -20.0
self.threshold_db = 20.0
self.max_db = 50
self.min_db = -20
self.threshold_db = 20

# Create a window object in top half of the screen, within the border
screen_dims = screen.getmaxyx()
Expand Down Expand Up @@ -137,7 +137,7 @@ def draw_spectrum(self, data):
# Update virtual window
self.win.noutrefresh()

def proc_keyb(self, keyb):
def proc_keyb(self, keyb: int):
"""Process keystrokes
Args:
Expand Down Expand Up @@ -305,7 +305,7 @@ def draw_channels(self, gui_lockout_channels, channels: list[Channel]):
# Update virtual window
self.win.noutrefresh()

def proc_keyb_set_lockout(self, keyb):
def proc_keyb_set_lockout(self, keyb: int):
"""Process keystrokes to lock out channels 0 - 9
Args:
Expand All @@ -322,7 +322,7 @@ def proc_keyb_set_lockout(self, keyb):
else:
return False

def proc_keyb_clear_lockout(self, keyb):
def proc_keyb_clear_lockout(self, keyb: int):
"""Process keystrokes to clear lockout with "l"
Args:
Expand Down Expand Up @@ -541,7 +541,7 @@ def draw_rx(self):
# Update virtual window
self.win.noutrefresh()

def proc_keyb_hard(self, keyb):
def proc_keyb_hard(self, keyb: int):
"""Process keystrokes to adjust hard receiver settings
Tune center_freq in 100 MHz steps with 'x' and 'c'
Expand Down Expand Up @@ -612,7 +612,7 @@ def proc_keyb_hard(self, keyb):
else:
return False

def proc_keyb_soft(self, keyb):
def proc_keyb_soft(self, keyb: int):
"""Process keystrokes to adjust soft receiver settings
Tune gain_db in 10 dB steps with 'g' and 'f'
Expand Down
10 changes: 5 additions & 5 deletions apps/h2m_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CLParser(object):
hw_args (string): Argument string to pass to harwdare
num_demod (int): Number of parallel demodulators
center_freq (float): Hardware RF center frequency in Hz
ask_samp_rate (float): Asking sample rate of hardware in sps (1E6 min)
ask_samp_rate (int): Asking sample rate of hardware in sps (1E6 min)
gains : Enumerated gain types and values
squelch_db (int): Squelch in dB
volume_dB (int): Volume in dB
Expand Down Expand Up @@ -61,7 +61,7 @@ def __init__(self):
default=146E6,
help="Hardware RF center frequency in Hz")

parser.add_argument("-r", "--rate", type=str, dest="ask_samp_rate",
parser.add_argument("-r", "--rate", type=float, dest="ask_samp_rate",
default=4E6,
help="Hardware ask sample rate in sps (1E6 minimum)")

Expand Down Expand Up @@ -103,7 +103,7 @@ def __init__(self):
dest="volume_db", default=0,
help="Volume in dB")

parser.add_argument("-t", "--threshold", type=float,
parser.add_argument("-t", "--threshold", type=int,
dest="threshold_db", default=10,
help="Threshold in dB")

Expand Down Expand Up @@ -183,7 +183,7 @@ def __init__(self):
self.num_demod = int(options.num_demod)
self.type_demod = int(options.type_demod)
self.center_freq = float(options.center_freq)
self.ask_samp_rate = float(options.ask_samp_rate)
self.ask_samp_rate = int(options.ask_samp_rate)
self.gains = [
{ "name": "RF", "value": float(options.rf_gain_db) },
{ "name": "LNA","value": float(options.lna_gain_db) },
Expand All @@ -198,7 +198,7 @@ def __init__(self):
]
self.squelch_db = int(options.squelch_db)
self.volume_db = int(options.volume_db)
self.threshold_db = float(options.threshold_db)
self.threshold_db = int(options.threshold_db)
self.record = bool(options.record)
self.play = bool(options.play)
self.lockout_file_name = str(options.lockout_file_name)
Expand Down
5 changes: 0 additions & 5 deletions apps/lockout-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ frequencies:
- 450.225 # unknown data
- 451.125
- 460.4
- 460.725
- 467.710
- 467.715
ranges:
- min: 460.4
max: 460.8
- min: 124.125
max: 134.625
- min: 467.0 # subset of FRS
max: 468.0
3 changes: 2 additions & 1 deletion apps/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ def __init__(self, ask_samp_rate: int=int(4E6), num_demod: int=4, type_demod: in
raise

# Default values
self.center_freq = int(144E6)
self.center_freq: int = int(144E6)
self.samp_rate: int
self.squelch_db = -60
self.volume_db = 0
audio_rate = 8000
Expand Down
Loading

0 comments on commit 74fecec

Please sign in to comment.