# HG changeset patch
# User Jim Unroe <rock.unroe@gmail.com>
# Date 1668732946 18000
#      Thu Nov 17 19:55:46 2022 -0500
# Node ID 9a061f24ae9cb2d2bed7fd5026ea8175911dd65b
# Parent  4884b3e39cb4fa75272e263b426b3125582796e4
[UV-50X2_G2] Add Baofeng Tech UV-50X2_G2

Baofeng Tech is releasing a second generation version of the
BTech UV-50X2. This patch adds support for the BTech UV-50X2_G2.

fixes #10126

diff -r 4884b3e39cb4 -r 9a061f24ae9c chirp/drivers/btech.py
--- a/chirp/drivers/btech.py	Tue Nov 08 10:19:47 2022 -0800
+++ b/chirp/drivers/btech.py	Thu Nov 17 19:55:46 2022 -0500
@@ -64,6 +64,7 @@
                "Purple", "Gray"]
 LIST_COLOR9 = ["Black"] + LIST_COLOR8
 LIST_DTMFST = ["OFF", "Keyboard", "ANI", "Keyboard + ANI"]
+LIST_EARPH = ["Off", "Earphone", "Earphone + Speaker"]
 LIST_EMCTP = ["TX alarm sound", "TX ANI", "Both"]
 LIST_EMCTPX = ["Off"] + LIST_EMCTP
 LIST_LANGUA = ["English", "Chinese"]
@@ -1253,12 +1254,19 @@
                                          LIST_MDF[_mem.settings.cdmdf]))
                 basic.append(cdmdf)
 
-                langua = RadioSetting("settings.langua", "Language",
-                                      RadioSettingValueList(
-                                          LIST_LANGUA,
-                                          LIST_LANGUA[_mem.settings.langua]))
-                basic.append(langua)
-
+                if self.MODEL == "UV-50X2_G2":
+                    vox = RadioSetting("settings.langua", "VOX",
+                                       RadioSettingValueList(
+                                           LIST_VOX,
+                                           LIST_VOX[_mem.settings.langua]))
+                    basic.append(vox)
+                else:
+                    langua = RadioSetting("settings.langua", "Language",
+                                          RadioSettingValueList(
+                                              LIST_LANGUA,
+                                              LIST_LANGUA[
+                                                  _mem.settings.langua]))
+                    basic.append(langua)
         if self.MODEL == "KT-8R":
             voice = RadioSetting("settings.voice", "Voice prompt",
                                  RadioSettingValueList(
@@ -1705,13 +1713,21 @@
 
         if self.MODEL == "KT-8R" or self.MODEL == "UV-25X2" \
                 or self.MODEL == "UV-25X4" or self.MODEL == "UV-50X2" \
-                or self.MODEL == "GMRS-50X1" or self.MODEL == "GMRS-20V2":
+                or self.MODEL == "GMRS-50X1" or self.MODEL == "GMRS-20V2" \
+                or self.MODEL == "UV-50X2_G2":
             tmrtx = RadioSetting("settings.tmrtx", "TX in multi-standby",
                                  RadioSettingValueList(
                                      LIST_TMRTX,
                                      LIST_TMRTX[_mem.settings.tmrtx]))
             basic.append(tmrtx)
 
+        if self.MODEL == "UV-50X2_G2":
+            earpho = RadioSetting("settings.earpho", "Earphone",
+                                  RadioSettingValueList(
+                                      LIST_EARPH,
+                                      LIST_EARPH[_mem.settings.earpho]))
+            basic.append(earpho)
+
         # Advanced
         def _filter(name):
             filtered = ""
@@ -3753,7 +3769,8 @@
   u8 cbmdf;
   u8 ccmdf;
   u8 cdmdf;
-  u8 langua;
+  u8 langua;        // BTech Gen2 radios have removed the Language setting
+                    // use this as the VOX setting
   u8 sync;          // BTech radios use this as the display sync
                     // setting, other radios use this as the auto
                     // keypad lock setting
@@ -3781,6 +3798,7 @@
   u8 skiptx;
   u8 scmode;
   u8 tmrtx;
+  u8 earpho;
 } settings;
 
 #seekto 0x0E80;
@@ -4099,6 +4117,19 @@
 
 
 @directory.register
+class UV50X2_G2(BTechColor):
+    """Baofeng Tech UV50X2_G2"""
+    MODEL = "UV-50X2_G2"
+    BANDS = 2
+    _vhf_range = (130000000, 180000000)
+    _uhf_range = (400000000, 521000000)
+    _magic = MSTRING_UV25X2
+    _fileid = [UV50X2_fp, ]
+    _power_levels = [chirp_common.PowerLevel("High", watts=50),
+                     chirp_common.PowerLevel("Low", watts=10)]
+
+
+@directory.register
 class KT7900D(BTechColor):
     """QYT KT7900D"""
     VENDOR = "QYT"
