commit a453539160f110b221aec2f07b0f00b4decb4bc2 Author: Jim Unroe Date: Sat Jan 28 17:36:01 2023 -0500 fix UV-9R Pro FM preset bug - fixes #10318 Add support for a 3rd method for storing broadcast FM frequency diff --git a/chirp/drivers/baofeng_common.py b/chirp/drivers/baofeng_common.py index b3d8fa73..f97f9b5b 100644 --- a/chirp/drivers/baofeng_common.py +++ b/chirp/drivers/baofeng_common.py @@ -673,6 +673,8 @@ class BaofengCommonHT(chirp_common.CloneModeRadio, else: value = int(val.get_value() * 10) LOG.debug("Setting fm_presets = %s" % (value)) + if self._bw_shift: + value = ((value & 0x00FF) << 8) | ((value & 0xFF00) >> 8) self._memobj.fm_presets = value except Exception as e: LOG.debug(element.get_name()) diff --git a/chirp/drivers/baofeng_wp970i.py b/chirp/drivers/baofeng_wp970i.py index 0736d0e8..3eb72892 100644 --- a/chirp/drivers/baofeng_wp970i.py +++ b/chirp/drivers/baofeng_wp970i.py @@ -95,6 +95,7 @@ class WP970I(baofeng_common.BaofengCommonHT): _recv_block_size = 0x40 _mem_size = 0x2000 _ack_block = True + _bw_shift = False _ranges = [(0x0000, 0x0DF0), (0x0E00, 0x1800), @@ -770,16 +771,25 @@ class WP970I(baofeng_common.BaofengCommonHT): work.append(rs) # broadcast FM settings - _fm_presets = self._memobj.fm_presets - if _fm_presets <= 108.0 * 10 - 650: - preset = _fm_presets / 10.0 + 65 - elif _fm_presets >= 65.0 * 10 and _fm_presets <= 108.0 * 10: - preset = _fm_presets / 10.0 + value = self._memobj.fm_presets + value_shifted = ((value & 0x00FF) << 8) | ((value & 0xFF00) >> 8) + if value_shifted >= 65.0 * 10 and value_shifted <= 108.0 * 10: + # storage method 3 (discovered 2022) + self._bw_shift = True + preset = value_shifted / 10.0 + elif value >= 65.0 * 10 and value <= 108.0 * 10: + # storage method 2 + preset = value / 10.0 + elif value <= 108.0 * 10 - 650: + # original storage method (2012) + preset = value / 10.0 + 65 else: - preset = 76.0 - rs = RadioSetting("fm_presets", "FM Preset(MHz)", - RadioSettingValueFloat(65, 108.0, preset, 0.1, 1)) - fm_preset.append(rs) + # unknown (undiscovered method or no FM chip?) + preset = nul + if preset: + rs = RadioSettingValueFloat(65, 108.0, preset, 0.1, 1) + rset = RadioSetting("fm_presets", "FM Preset(MHz)", rs) + fm_preset.append(rset) # DTMF settings def apply_code(setting, obj, length):