# HG changeset patch # User Ran Katz rankatz@gmail.com # Date 1660474607 -10800 # Sun Aug 14 13:56:47 2022 +0300 # Node ID 3eb8629bf6d76415605f6dc9004226c42d1bf55f # Parent d0caf6c542c5cbe33cfb69e9edd978f4fdbad8e1 [tg_uv2p] (revised) Inhibit keypad lock when in dual watch or crossmode. Fixes forth issue in #9939 Per Dan's suggestions, implemented with an exception (rather than a flag/basd on set_settings order)
diff --git a/chirp/drivers/tg_uv2p.py b/chirp/drivers/tg_uv2p.py --- a/chirp/drivers/tg_uv2p.py +++ b/chirp/drivers/tg_uv2p.py @@ -27,6 +27,7 @@ RadioSettingValueFloat, RadioSettingValueMap, RadioSettings from textwrap import dedent
+ LOG = logging.getLogger(__name__)
mem_format = """ @@ -703,14 +704,35 @@ LOG.debug("using apply callback") element.run_apply_callback() elif setting == "beep_tone_disabled": - LOG.debug("Setting %s = %s" % (setting, not int(element.value))) + LOG.debug("Setting %s = %s" % (setting, + not int(element.value))) setattr(obj, setting, not int(element.value)) elif setting == "busy_lockout": - LOG.debug("Setting %s = %s" % (setting, not int(element.value))) + LOG.debug("Setting %s = %s" % (setting, + not int(element.value))) setattr(obj, setting, not int(element.value)) elif setting == "keyunlocked": - LOG.debug("Setting %s = %s" % (setting, not int(element.value))) + if int(element.value): + if (getattr(obj, "rxmode") != 0x02): + LOG.debug("Setting %s = %s" % (setting, True)) + setattr(obj, setting, True) + raise errors.InvalidValueError( + "Keypad lock not allowed in " + "Dual-Watch or CrossMode") + LOG.debug("Setting %s = %s" % (setting, + not int(element.value))) setattr(obj, setting, not int(element.value)) + elif setting == "rxmode": + if int(element.value) != 2: + if not (getattr(obj, "keyunlocked")): + LOG.debug("Setting %s = %s" % (setting, + "Normal")) + setattr(obj, setting, 0x02) + raise errors.InvalidValueError( + "Dual-Watch or CrossMode can not be set " + "when keypad is locked") + LOG.debug("Setting %s = %s" % (setting, element.value)) + setattr(obj, setting, element.value) elif element.value.get_mutable(): LOG.debug("Setting %s = %s" % (setting, element.value)) setattr(obj, setting, element.value)