# HG changeset patch
# User Keith Williamson <hkwilliamson@gmail.com>
# Date 1496768767 25200
#      Tue Jun 06 10:06:07 2017 -0700
# Node ID 836aee5575172508d714bcd72b1ecb112812eac9
# Parent  6dd8d0e6c4d83d592b29f82dd221a94c3102f184
[vx8] Simple refactor that moves most VXDRadio class functions to VXRadio parent class. Fixes #4881
This is the first of two groundwork patches for adding Settings support for the VX-8R. This patch
produces no change in functionality.

diff -r 6dd8d0e6c4d8 -r 836aee557517 chirp/drivers/vx8.py
--- a/chirp/drivers/vx8.py	Mon Jun 05 16:45:08 2017 -0700
+++ b/chirp/drivers/vx8.py	Tue Jun 06 10:06:07 2017 -0700
@@ -653,89 +653,6 @@
     def get_bank_model(self):
         return VX8BankModel(self)
 
-
-@directory.register
-class VX8DRadio(VX8Radio):
-    """Yaesu VX-8DR"""
-    MODEL = "VX-8DR"
-    _model = "AH29D"
-    _mem_params = (0xC24A,  # APRS beacon metadata address.
-                   50,      # Number of beacons stored.
-                   0xC6FA,  # APRS beacon content address.
-                   146,     # Length of beacon data stored.
-                   50)      # Number of beacons stored.
-
-    _SG_RE = re.compile(r"(?P<sign>[-+NESW]?)(?P<d>[\d]+)[\s\.,]*"
-                        "(?P<m>[\d]*)[\s\']*(?P<s>[\d]*)")
-
-    _RX_BAUD = ("off", "1200 baud", "9600 baud")
-    _TX_DELAY = ("100ms", "150ms", "200ms", "250ms", "300ms",
-                 "400ms", "500ms", "750ms", "1000ms")
-    _WIND_UNITS = ("m/s", "mph")
-    _RAIN_UNITS = ("mm", "inch")
-    _TEMP_UNITS = ("C", "F")
-    _ALT_UNITS = ("m", "ft")
-    _DIST_UNITS = ("km", "mile")
-    _POS_UNITS = ("dd.mmmm'", "dd mm'ss\"")
-    _SPEED_UNITS = ("km/h", "knot", "mph")
-    _TIME_SOURCE = ("manual", "GPS")
-    _TZ = ("-13:00", "-13:30", "-12:00", "-12:30", "-11:00", "-11:30",
-           "-10:00", "-10:30", "-09:00", "-09:30", "-08:00", "-08:30",
-           "-07:00", "-07:30", "-06:00", "-06:30", "-05:00", "-05:30",
-           "-04:00", "-04:30", "-03:00", "-03:30", "-02:00", "-02:30",
-           "-01:00", "-01:30", "-00:00", "-00:30", "+01:00", "+01:30",
-           "+02:00", "+02:30", "+03:00", "+03:30", "+04:00", "+04:30",
-           "+05:00", "+05:30", "+06:00", "+06:30", "+07:00", "+07:30",
-           "+08:00", "+08:30", "+09:00", "+09:30", "+10:00", "+10:30",
-           "+11:00", "+11:30")
-    _BEACON_TYPE = ("Off", "Interval", "SmartBeaconing")
-    _SMARTBEACON_PROFILE = ("Off", "Type 1", "Type 2", "Type 3")
-    _BEACON_INT = ("30s", "1m", "2m", "3m", "5m", "10m", "15m",
-                   "20m", "30m", "60m")
-    _DIGI_PATHS = ("OFF", "WIDE1-1", "WIDE1-1, WIDE2-1", "Digi Path 4",
-                   "Digi Path 5", "Digi Path 6", "Digi Path 7", "Digi Path 8")
-    _MSG_GROUP_NAMES = ("Message Group 1", "Message Group 2",
-                        "Message Group 3", "Message Group 4",
-                        "Message Group 5", "Message Group 6",
-                        "Message Group 7", "Message Group 8")
-    _POSITIONS = ("GPS", "Manual Latitude/Longitude",
-                  "Manual Latitude/Longitude", "P1", "P2", "P3", "P4",
-                  "P5", "P6", "P7", "P8", "P9")
-    _FLASH = ("OFF", "2 seconds", "4 seconds", "6 seconds", "8 seconds",
-              "10 seconds", "20 seconds", "30 seconds", "60 seconds",
-              "CONTINUOUS", "every 2 seconds", "every 3 seconds",
-              "every 4 seconds", "every 5 seconds", "every 6 seconds",
-              "every 7 seconds", "every 8 seconds", "every 9 seconds",
-              "every 10 seconds", "every 20 seconds", "every 30 seconds",
-              "every 40 seconds", "every 50 seconds", "every minute",
-              "every 2 minutes", "every 3 minutes", "every 4 minutes",
-              "every 5 minutes", "every 6 minutes", "every 7 minutes",
-              "every 8 minutes", "every 9 minutes", "every 10 minutes")
-    _BEEP_SELECT = ("Off", "Key+Scan", "Key")
-    _SQUELCH = ["%d" % x for x in range(0, 16)]
-    _VOLUME = ["%d" % x for x in range(0, 33)]
-    _OPENING_MESSAGE = ("Off", "DC", "Message", "Normal")
-    _SCAN_RESUME = ["%.1fs" % (0.5 * x) for x in range(4, 21)] + \
-                   ["Busy", "Hold"]
-    _SCAN_RESTART = ["%.1fs" % (0.1 * x) for x in range(1, 10)] + \
-                    ["%.1fs" % (0.5 * x) for x in range(2, 21)]
-    _LAMP_KEY = ["Key %d sec" % x for x in range(2, 11)] + \
-                ["Continuous", "OFF"]
-    _LCD_CONTRAST = ["Level %d" % x for x in range(1, 16)]
-    _LCD_DIMMER = ["Level %d" % x for x in range(1, 5)]
-    _TOT_TIME = ["Off"] + ["%.1f min" % (0.5 * x) for x in range(1, 21)]
-    _OFF_ON = ("Off", "On")
-    _VOL_MODE = ("Normal", "Auto Back")
-    _DTMF_MODE = ("Manual", "Auto")
-    _DTMF_SPEED = ("50ms", "100ms")
-    _DTMF_DELAY = ("50ms", "250ms", "450ms", "750ms", "1000ms")
-    _MY_SYMBOL = ("/[ Person", "/b Bike", "/> Car", "User selected")
-
-    def get_features(self):
-        rf = VX8Radio.get_features(self)
-        rf.has_settings = True
-        return rf
-
     @classmethod
     def _digi_path_to_str(cls, path):
         path_cmp = []
@@ -1162,61 +1079,6 @@
 
         return menu
 
-    def _get_aprs_smartbeacon(self):
-        menu = RadioSettingGroup("aprs_smartbeacon", "APRS SmartBeacon")
-        aprs = self._memobj.aprs
-
-        val = RadioSettingValueList(
-            self._SMARTBEACON_PROFILE,
-            self._SMARTBEACON_PROFILE[aprs.active_smartbeaconing])
-        rs = RadioSetting("aprs.active_smartbeaconing", "SmartBeacon profile",
-                          val)
-        menu.append(rs)
-
-        for profile in range(3):
-            pfx = "type%d" % (profile + 1)
-            path = "aprs.smartbeaconing_profile[%d]" % profile
-            prof = aprs.smartbeaconing_profile[profile]
-
-            low_val = RadioSettingValueInteger(2, 30, prof.low_speed_mph)
-            high_val = RadioSettingValueInteger(3, 70, prof.high_speed_mph)
-            low_val.get_max = lambda: min(30, int(high_val.get_value()) - 1)
-
-            rs = RadioSetting("%s.low_speed_mph" % path,
-                              "%s Low Speed (mph)" % pfx, low_val)
-            menu.append(rs)
-
-            rs = RadioSetting("%s.high_speed_mph" % path,
-                              "%s High Speed (mph)" % pfx, high_val)
-            menu.append(rs)
-
-            val = RadioSettingValueInteger(1, 100, prof.slow_rate_min)
-            rs = RadioSetting("%s.slow_rate_min" % path,
-                              "%s Slow rate (minutes)" % pfx, val)
-            menu.append(rs)
-
-            val = RadioSettingValueInteger(10, 180, prof.fast_rate_sec)
-            rs = RadioSetting("%s.fast_rate_sec" % path,
-                              "%s Fast rate (seconds)" % pfx, val)
-            menu.append(rs)
-
-            val = RadioSettingValueInteger(5, 90, prof.turn_angle)
-            rs = RadioSetting("%s.turn_angle" % path,
-                              "%s Turn angle (degrees)" % pfx, val)
-            menu.append(rs)
-
-            val = RadioSettingValueInteger(1, 255, prof.turn_slop)
-            rs = RadioSetting("%s.turn_slop" % path,
-                              "%s Turn slop" % pfx, val)
-            menu.append(rs)
-
-            val = RadioSettingValueInteger(5, 180, prof.turn_time_sec)
-            rs = RadioSetting("%s.turn_time_sec" % path,
-                              "%s Turn time (seconds)" % pfx, val)
-            menu.append(rs)
-
-        return menu
-
     def _get_dtmf_settings(self):
         menu = RadioSettingGroup("dtmf_settings", "DTMF")
         dtmf = self._memobj.scan_settings
@@ -1384,24 +1246,6 @@
 
         return menu
 
-    def _get_settings(self):
-        top = RadioSettings(self._get_aprs_general_settings(),
-                            self._get_aprs_rx_settings(),
-                            self._get_aprs_tx_settings(),
-                            self._get_aprs_smartbeacon(),
-                            self._get_dtmf_settings(),
-                            self._get_misc_settings(),
-                            self._get_scan_settings())
-        return top
-
-    def get_settings(self):
-        try:
-            return self._get_settings()
-        except:
-            import traceback
-            LOG.error("Failed to parse settings: %s", traceback.format_exc())
-            return None
-
     @staticmethod
     def apply_custom_symbol(setting, obj):
         # Ensure new value falls within known bounds, otherwise leave it as
@@ -1549,6 +1393,162 @@
 
 
 @directory.register
+class VX8DRadio(VX8Radio):
+    """Yaesu VX-8DR"""
+    MODEL = "VX-8DR"
+    _model = "AH29D"
+    _mem_params = (0xC24A,  # APRS beacon metadata address.
+                   50,      # Number of beacons stored.
+                   0xC6FA,  # APRS beacon content address.
+                   146,     # Length of beacon data stored.
+                   50)      # Number of beacons stored.
+
+    _SG_RE = re.compile(r"(?P<sign>[-+NESW]?)(?P<d>[\d]+)[\s\.,]*"
+                        "(?P<m>[\d]*)[\s\']*(?P<s>[\d]*)")
+
+    _RX_BAUD = ("off", "1200 baud", "9600 baud")
+    _TX_DELAY = ("100ms", "150ms", "200ms", "250ms", "300ms",
+                 "400ms", "500ms", "750ms", "1000ms")
+    _WIND_UNITS = ("m/s", "mph")
+    _RAIN_UNITS = ("mm", "inch")
+    _TEMP_UNITS = ("C", "F")
+    _ALT_UNITS = ("m", "ft")
+    _DIST_UNITS = ("km", "mile")
+    _POS_UNITS = ("dd.mmmm'", "dd mm'ss\"")
+    _SPEED_UNITS = ("km/h", "knot", "mph")
+    _TIME_SOURCE = ("manual", "GPS")
+    _TZ = ("-13:00", "-13:30", "-12:00", "-12:30", "-11:00", "-11:30",
+           "-10:00", "-10:30", "-09:00", "-09:30", "-08:00", "-08:30",
+           "-07:00", "-07:30", "-06:00", "-06:30", "-05:00", "-05:30",
+           "-04:00", "-04:30", "-03:00", "-03:30", "-02:00", "-02:30",
+           "-01:00", "-01:30", "-00:00", "-00:30", "+01:00", "+01:30",
+           "+02:00", "+02:30", "+03:00", "+03:30", "+04:00", "+04:30",
+           "+05:00", "+05:30", "+06:00", "+06:30", "+07:00", "+07:30",
+           "+08:00", "+08:30", "+09:00", "+09:30", "+10:00", "+10:30",
+           "+11:00", "+11:30")
+    _BEACON_TYPE = ("Off", "Interval", "SmartBeaconing")
+    _SMARTBEACON_PROFILE = ("Off", "Type 1", "Type 2", "Type 3")
+    _BEACON_INT = ("30s", "1m", "2m", "3m", "5m", "10m", "15m",
+                   "20m", "30m", "60m")
+    _DIGI_PATHS = ("OFF", "WIDE1-1", "WIDE1-1, WIDE2-1", "Digi Path 4",
+                   "Digi Path 5", "Digi Path 6", "Digi Path 7", "Digi Path 8")
+    _MSG_GROUP_NAMES = ("Message Group 1", "Message Group 2",
+                        "Message Group 3", "Message Group 4",
+                        "Message Group 5", "Message Group 6",
+                        "Message Group 7", "Message Group 8")
+    _POSITIONS = ("GPS", "Manual Latitude/Longitude",
+                  "Manual Latitude/Longitude", "P1", "P2", "P3", "P4",
+                  "P5", "P6", "P7", "P8", "P9")
+    _FLASH = ("OFF", "2 seconds", "4 seconds", "6 seconds", "8 seconds",
+              "10 seconds", "20 seconds", "30 seconds", "60 seconds",
+              "CONTINUOUS", "every 2 seconds", "every 3 seconds",
+              "every 4 seconds", "every 5 seconds", "every 6 seconds",
+              "every 7 seconds", "every 8 seconds", "every 9 seconds",
+              "every 10 seconds", "every 20 seconds", "every 30 seconds",
+              "every 40 seconds", "every 50 seconds", "every minute",
+              "every 2 minutes", "every 3 minutes", "every 4 minutes",
+              "every 5 minutes", "every 6 minutes", "every 7 minutes",
+              "every 8 minutes", "every 9 minutes", "every 10 minutes")
+    _BEEP_SELECT = ("Off", "Key+Scan", "Key")
+    _SQUELCH = ["%d" % x for x in range(0, 16)]
+    _VOLUME = ["%d" % x for x in range(0, 33)]
+    _OPENING_MESSAGE = ("Off", "DC", "Message", "Normal")
+    _SCAN_RESUME = ["%.1fs" % (0.5 * x) for x in range(4, 21)] + \
+                   ["Busy", "Hold"]
+    _SCAN_RESTART = ["%.1fs" % (0.1 * x) for x in range(1, 10)] + \
+                    ["%.1fs" % (0.5 * x) for x in range(2, 21)]
+    _LAMP_KEY = ["Key %d sec" % x for x in range(2, 11)] + \
+                ["Continuous", "OFF"]
+    _LCD_CONTRAST = ["Level %d" % x for x in range(1, 16)]
+    _LCD_DIMMER = ["Level %d" % x for x in range(1, 5)]
+    _TOT_TIME = ["Off"] + ["%.1f min" % (0.5 * x) for x in range(1, 21)]
+    _OFF_ON = ("Off", "On")
+    _VOL_MODE = ("Normal", "Auto Back")
+    _DTMF_MODE = ("Manual", "Auto")
+    _DTMF_SPEED = ("50ms", "100ms")
+    _DTMF_DELAY = ("50ms", "250ms", "450ms", "750ms", "1000ms")
+    _MY_SYMBOL = ("/[ Person", "/b Bike", "/> Car", "User selected")
+
+    def get_features(self):
+        rf = VX8Radio.get_features(self)
+        rf.has_settings = True
+        return rf
+
+    def _get_aprs_smartbeacon(self):
+        menu = RadioSettingGroup("aprs_smartbeacon", "APRS SmartBeacon")
+        aprs = self._memobj.aprs
+
+        val = RadioSettingValueList(
+            self._SMARTBEACON_PROFILE,
+            self._SMARTBEACON_PROFILE[aprs.active_smartbeaconing])
+        rs = RadioSetting("aprs.active_smartbeaconing", "SmartBeacon profile",
+                          val)
+        menu.append(rs)
+
+        for profile in range(3):
+            pfx = "type%d" % (profile + 1)
+            path = "aprs.smartbeaconing_profile[%d]" % profile
+            prof = aprs.smartbeaconing_profile[profile]
+
+            low_val = RadioSettingValueInteger(2, 30, prof.low_speed_mph)
+            high_val = RadioSettingValueInteger(3, 70, prof.high_speed_mph)
+            low_val.get_max = lambda: min(30, int(high_val.get_value()) - 1)
+
+            rs = RadioSetting("%s.low_speed_mph" % path,
+                              "%s Low Speed (mph)" % pfx, low_val)
+            menu.append(rs)
+
+            rs = RadioSetting("%s.high_speed_mph" % path,
+                              "%s High Speed (mph)" % pfx, high_val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(1, 100, prof.slow_rate_min)
+            rs = RadioSetting("%s.slow_rate_min" % path,
+                              "%s Slow rate (minutes)" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(10, 180, prof.fast_rate_sec)
+            rs = RadioSetting("%s.fast_rate_sec" % path,
+                              "%s Fast rate (seconds)" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(5, 90, prof.turn_angle)
+            rs = RadioSetting("%s.turn_angle" % path,
+                              "%s Turn angle (degrees)" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(1, 255, prof.turn_slop)
+            rs = RadioSetting("%s.turn_slop" % path,
+                              "%s Turn slop" % pfx, val)
+            menu.append(rs)
+
+            val = RadioSettingValueInteger(5, 180, prof.turn_time_sec)
+            rs = RadioSetting("%s.turn_time_sec" % path,
+                              "%s Turn time (seconds)" % pfx, val)
+            menu.append(rs)
+
+        return menu
+
+    def _get_settings(self):
+        top = RadioSettings(self._get_aprs_general_settings(),
+                            self._get_aprs_rx_settings(),
+                            self._get_aprs_tx_settings(),
+                            self._get_aprs_smartbeacon(),
+                            self._get_dtmf_settings(),
+                            self._get_misc_settings(),
+                            self._get_scan_settings())
+        return top
+
+    def get_settings(self):
+        try:
+            return self._get_settings()
+        except:
+            import traceback
+            LOG.error("Failed to parse settings: %s", traceback.format_exc())
+            return None
+
+
+@directory.register
 class VX8GERadio(VX8DRadio):
     """Yaesu VX-8GE"""
     MODEL = "VX-8GE"
