# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1361483689 28800 # Node ID 169fa6015eb76d265fc24b2f705fcc40f8bac6e5 # Parent 963296a371c6d65359dccc9d6ebf147ed6955f79 [id31] Backport ID-51 mode logic to ID-31. Related to #553
diff -r 963296a371c6 -r 169fa6015eb7 chirp/id31.py --- a/chirp/id31.py Wed Feb 20 19:44:20 2013 -0800 +++ b/chirp/id31.py Thu Feb 21 13:54:49 2013 -0800 @@ -22,9 +22,7 @@ u16 rtone:6, ctone:6, unknown2:1, - is_dv:1, - unknown2_0:1, - is_narrow:1; + mode:3; u8 dtcs; u8 tune_step:4, unknown5:4; @@ -88,6 +86,7 @@
"""
+MODES = {0: "FM", 1: "NFM", 3: "AM", 5: "DV"} TMODES = ["", "Tone", "TSQL", "TSQL", "DTCS", "DTCS", "TSQL-R", "DTCS-R"] DUPLEX = ["", "-", "+"] DTCS_POLARITY = ["NN", "NR", "RN", "RR"] @@ -198,7 +197,7 @@ rf.has_bank_names = True rf.valid_tmodes = list(TMODES) rf.valid_tuning_steps = sorted(list(TUNING_STEPS)) - rf.valid_modes = ["FM", "NFM", "DV"] + rf.valid_modes = MODES.values() rf.valid_skips = ["", "S", "P"] rf.valid_characters = chirp_common.CHARSET_ASCII rf.valid_name_length = 16 @@ -218,7 +217,7 @@
bit = (1 << (number % 8))
- if _mem.is_dv: + if MODES[int(_mem.mode)] == "DV": mem = chirp_common.DVMemory() else: mem = chirp_common.Memory() @@ -237,16 +236,12 @@ mem.dtcs = chirp_common.DTCS_CODES[_mem.dtcs] mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_polarity] mem.tuning_step = TUNING_STEPS[_mem.tune_step] + mem.mode = MODES[int(_mem.mode)]
- if _mem.is_dv: - mem.mode = "DV" + if mem.mode == "DV": mem.dv_urcall = _decode_call(_mem.urcall).rstrip() mem.dv_rpt1call = _decode_call(_mem.rpt1call).rstrip() mem.dv_rpt2call = _decode_call(_mem.rpt2call).rstrip() - elif _mem.is_narrow: - mem.mode = "NFM" - else: - mem.mode = "FM"
if _psk & bit: mem.skip = "P" @@ -279,9 +274,7 @@ _mem.dtcs = chirp_common.DTCS_CODES.index(memory.dtcs) _mem.dtcs_polarity = DTCS_POLARITY.index(memory.dtcs_polarity) _mem.tune_step = TUNING_STEPS.index(memory.tuning_step) - - _mem.is_narrow = memory.mode in ["NFM", "DV"] - _mem.is_dv = memory.mode == "DV" + _mem.mode = next(i for i, mode in MODES.items() if mode == memory.mode)
if isinstance(memory, chirp_common.DVMemory): _mem.urcall = _encode_call(memory.dv_urcall.ljust(8))