# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1361772240 28800 # Node ID 84a6dddebc9f88bac90afcd09083fb1665a7ffb4 # Parent 0769d077d73a547e8f0d906f7c78ac8218658f0f [id31] Backport ID-51 mode logic to ID-31. Related to #553
diff -r 0769d077d73a -r 84a6dddebc9f chirp/id31.py --- a/chirp/id31.py Sun Feb 24 10:06:52 2013 -0500 +++ b/chirp/id31.py Sun Feb 24 22:04:00 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; @@ -166,6 +164,8 @@
_ranges = [(0x00000, 0x15500, 32)]
+ MODES = {0: "FM", 1: "NFM", 5: "DV"} + def _get_bank(self, loc): _bank = self._memobj.banks[loc] if _bank.bank == 0xFF: @@ -198,7 +198,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 = self.MODES.values() rf.valid_skips = ["", "S", "P"] rf.valid_characters = chirp_common.CHARSET_ASCII rf.valid_name_length = 16 @@ -218,7 +218,7 @@
bit = (1 << (number % 8))
- if _mem.is_dv: + if self.MODES[int(_mem.mode)] == "DV": mem = chirp_common.DVMemory() else: mem = chirp_common.Memory() @@ -237,16 +237,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 = self.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 +275,8 @@ _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 self.MODES.items() \ + if mode == memory.mode)
if isinstance(memory, chirp_common.DVMemory): _mem.urcall = _encode_call(memory.dv_urcall.ljust(8))