[chirp_devel] [PATCH] Add import logic helper to convert odd split to offset. #185
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1360301793 28800 # Node ID 4c529f3129e5346243bdecc6fc14b91e4e409191 # Parent 6f916d8e23236ed702344ec05c4d32df5b9640a7 Add import logic helper to convert odd split to offset. #185
diff -r 6f916d8e2323 -r 4c529f3129e5 chirp/import_logic.py --- a/chirp/import_logic.py Thu Feb 07 19:49:21 2013 -0800 +++ b/chirp/import_logic.py Thu Feb 07 21:36:33 2013 -0800 @@ -144,6 +144,34 @@ if mem.mode == "Auto" and mem.mode not in dstrf.valid_modes: mem.mode = _guess_mode_by_frequency(mem.freq)
+def _make_offset_with_split(rxfreq, txfreq): + offset = txfreq - rxfreq + + if offset == 0: + return "", offset + elif offset > 0: + return "+", offset + elif offset < 0: + return "-", offset * -1 + +def _import_duplex(dst_radio, srcrf, mem): + dstrf = dst_radio.get_features() + + # If a radio does not support odd split, we can use an equivalent offset + if mem.duplex == "split" and mem.duplex not in dstrf.valid_duplexes: + mem.duplex, mem.offset = _make_offset_with_split(mem.freq, mem.offset) + + # Enforce maximum offset + ranges = [ + ( 0, 500000000, 7000000), + (500000000, 3000000000, 50000000), + ] + for lo, hi, limit in ranges: + if lo < mem.freq <= hi: + if abs(mem.offset) > limit: + raise DestNotCompatible("Unable to create import memory: " + "offset is abnormally large.") + def import_mem(dst_radio, src_features, src_mem, overrides={}): """Perform import logic to create a destination memory from src_mem that will be compatible with @dst_radio""" @@ -165,6 +193,7 @@ _import_tone, _import_dtcs, _import_mode, + _import_duplex, ]
for helper in helpers:
participants (1)
-
Tom Hayward