Various stuff

This commit is contained in:
Ian Renton
2025-09-30 20:51:56 +01:00
parent 280749919d
commit 37692f41a8
9 changed files with 100 additions and 56 deletions

View File

@@ -7,28 +7,28 @@ SOFTWARE_VERSION = "0.1"
# Modes
CW_MODES = ["CW"]
PHONE_MODES = ["PHONE", "SSB", "USB", "LSB", "AM", "FM", "DV", "DMR", "DSTAR", "C4FM", "M17"]
DATA_MODES = ["DIGI", "DATA", "FT8", "FT4", "RTTY", "SSTV", "JS8", "HELL", "BPSK", "PSK", "BPSK31", "OLIVIA"]
DATA_MODES = ["DIGI", "DATA", "DIGITAL", "FT8", "FT4", "RTTY", "SSTV", "JS8", "HELL", "BPSK", "PSK", "BPSK31", "OLIVIA"]
ALL_MODES = CW_MODES + PHONE_MODES + DATA_MODES
# Band definitions
BANDS = [
Band(name="160m", start_freq=1800, end_freq=2000),
Band(name="80m", start_freq=3500, end_freq=4000),
Band(name="60m", start_freq=5250, end_freq=5410),
Band(name="40m", start_freq=7000, end_freq=7300),
Band(name="30m", start_freq=10100, end_freq=10150),
Band(name="20m", start_freq=14000, end_freq=14350),
Band(name="17m", start_freq=18068, end_freq=18168),
Band(name="15m", start_freq=21000, end_freq=21450),
Band(name="12m", start_freq=24890, end_freq=24990),
Band(name="10m", start_freq=28000, end_freq=29700),
Band(name="6m", start_freq=50000, end_freq=54000),
Band(name="4m", start_freq=70000, end_freq=70500),
Band(name="2m", start_freq=144000, end_freq=148000),
Band(name="70cm", start_freq=420000, end_freq=450000),
Band(name="23cm", start_freq=1240000, end_freq=1325000),
Band(name="13cm", start_freq=2300000, end_freq=2450000)]
UNKNOWN_BAND = Band(name="Unknown", start_freq=0, end_freq=0)
Band(name="160m", start_freq=1800, end_freq=2000, color="#7cfc00", contrast_color="black"),
Band(name="80m", start_freq=3500, end_freq=4000, color="#e550e5", contrast_color="black"),
Band(name="60m", start_freq=5250, end_freq=5410, color="#00008b", contrast_color="white"),
Band(name="40m", start_freq=7000, end_freq=7300, color="#5959ff", contrast_color="white"),
Band(name="30m", start_freq=10100, end_freq=10150, color="#62d962", contrast_color="black"),
Band(name="20m", start_freq=14000, end_freq=14350, color="#f2c40c", contrast_color="black"),
Band(name="17m", start_freq=18068, end_freq=18168, color="#f2f261", contrast_color="black"),
Band(name="15m", start_freq=21000, end_freq=21450, color="#cca166", contrast_color="black"),
Band(name="12m", start_freq=24890, end_freq=24990, color="#b22222", contrast_color="white"),
Band(name="10m", start_freq=28000, end_freq=29700, color="#ff69b4", contrast_color="black"),
Band(name="6m", start_freq=50000, end_freq=54000, color="#FF0000", contrast_color="white"),
Band(name="4m", start_freq=70000, end_freq=70500, color="#cc0044", contrast_color="white"),
Band(name="2m", start_freq=144000, end_freq=148000, color="#FF1493", contrast_color="black"),
Band(name="70cm", start_freq=420000, end_freq=450000, color="#999900", contrast_color="white"),
Band(name="23cm", start_freq=1240000, end_freq=1325000, color="#5AB8C7", contrast_color="black"),
Band(name="13cm", start_freq=2300000, end_freq=2450000, color="#FF7F50", contrast_color="black")]
UNKNOWN_BAND = Band(name="Unknown", start_freq=0, end_freq=0, color="black", contrast_color="white")
# DXCC flags (borrowed from https:#github.com/wavelog/wavelog/blob/master/application/libraries/DxccFlag.php)
DXCC_FLAGS = {

View File

@@ -3,6 +3,7 @@ from datetime import datetime
from diskcache import Cache
from pyhamtools import LookupLib, Callinfo
from pyhamtools.frequency import freq_to_band
from pyhamtools.locator import latlong_to_locator
from core.config import config
@@ -25,7 +26,7 @@ def infer_mode_from_comment(comment):
return None
# Infer a "mode family" from a mode.
def infer_mode_family_from_mode(mode):
def infer_mode_type_from_mode(mode):
if mode.upper() in CW_MODES:
return "CW"
elif mode.upper() in PHONE_MODES:
@@ -137,6 +138,11 @@ def infer_grid_from_callsign_dxcc(call):
return latlong_to_locator(latlon[0], latlon[1], 8)
# Infer a mode from the frequency according to the band plan. Just a guess really.
def infer_mode_from_frequency(freq):
return freq_to_band(freq)["mode"]
# Convert objects to serialisable things. Used by JSON serialiser as a default when it encounters unserializable things.
# Converts datetimes to ISO.
# Anything else it tries to convert to a dict.