[chirp_devel] [PATCH] Settings support added to IC-V85 driver. Fixes #276

Kosta A.
Tue Sep 28 13:07:57 PDT 2021


# HG changeset patch
# User Kosta A. <ve7kcy at gmail.com>
# Date 1632859668 25200
#      Tue Sep 28 13:07:48 2021 -0700
# Branch icom
# Node ID 0863be4a9a51b3f4d40604569814e7588125750d
# Parent  8a801f6e14388614d4456466af77f847d52cac27
Settings support added to IC-V85 driver. Fixes #276

diff --git a/chirp/drivers/icv85.py b/chirp/drivers/icv85.py
--- a/chirp/drivers/icv85.py
+++ b/chirp/drivers/icv85.py
@@ -60,6 +60,53 @@
      bank:4;
 } flags[108];
 
+#seekto 0x0870;
+struct {
+  u8 unknown1:6,
+     beep:2;
+  u8 unknown2:3,
+     tot:5;
+  u8 unknown3:6,
+     unknown4:2;
+  u8 unknown5:6,
+     auto_pwr_off:2;
+  u8 unknown6:6,
+     lockout:2;
+  u8 unknown7:7,
+     squelch_delay:1;
+  u8 unknown8[2];
+  u8 unknown9:6,
+     mem_display:2;
+  u8 unknown10:7,
+     dial_func:1;
+  u8 unknown11:6,
+     lcd:2;
+  u8 unknown12:5,
+     pwr_save:3;
+  u8 unknown13:7,
+     monitor:1;
+  u8 unknown14:7,
+     sel_speed:1;
+  u8 unknown15:6,
+     mic_func:2;
+  u8 unknown16[4];
+  u8 unknown17:7,
+     battery_save:1;
+  u8 unknown18;
+  u8 unknown19:6,
+     resume:2;
+  u8 unknown20:5,
+     func_mode:3;
+  u8 unknown21:6,
+     backlight:2;
+  u8 unknown22:6,
+     bank_link:2;
+  u8 unknown23[15];
+  u8 unknown:6,
+     edge:2;
+  u8 unknown24[7];
+} settings;
+
 
 """
 
@@ -119,7 +166,7 @@
         rf.has_ctone = True
         rf.has_offset = True
         rf.has_bank = True
-        rf.has_settings = False
+        rf.has_settings = True
 
         return rf
 
@@ -135,6 +182,157 @@
     def process_mmap(self):
         self._memobj = bitwise.parse(ICV85_MEM_FORMAT, self._mmap)
 
+    def get_settings(self):
+        _settings = self._memobj.settings
+
+        general = RadioSettingGroup("general", "General")
+        display = RadioSettingGroup("display", "Display")
+        timer = RadioSettingGroup("timer", "Timer")
+        scan = RadioSettingGroup("scan", "Scan")
+        settings = RadioSettings(general, display, timer, scan)
+
+        # Backlight
+        opts = ["Off", "On", "Auto"]
+        display.append(
+            RadioSetting(
+                "backlight", "Backlight",
+                RadioSettingValueList(opts, opts[_settings.backlight])))
+
+        # LCD Contrast
+        opts = ["Low", "High", "Auto"]
+        display.append(
+            RadioSetting(
+                "lcd", "LCD Contrast",
+                RadioSettingValueList(opts, opts[_settings.lcd])))
+
+        # Beep
+        opts = ["Off", "1", "2", "3"]
+        display.append(
+            RadioSetting(
+                "beep", "Beep",
+                RadioSettingValueList(opts, opts[_settings.beep])))
+
+        # TOT
+        opts = ["Off"] + ["%d min" % t for t in range(1, 31)]
+        timer.append(
+            RadioSetting(
+                "tot", "Time out Timer",
+                RadioSettingValueList(opts, opts[_settings.tot])))
+
+        # Auto Power Off
+        opts = ["Off", "30 min", "1 hr", "2 hrs"]
+        timer.append(
+            RadioSetting(
+                "auto_pwr_off", "Auto Power Off",
+                RadioSettingValueList(opts, opts[_settings.auto_pwr_off])))
+
+        # Edge
+        opts = ["All", "P1", "P2", "P3"]
+        scan.append(
+            RadioSetting(
+                "edge", "Edge",
+                RadioSettingValueList(opts, opts[_settings.edge])))
+
+        # Resume
+        opts = ["T-5", "T-10", "T-15", "Pause"]
+        scan.append(
+            RadioSetting(
+                "resume", "Resume",
+                RadioSettingValueList(opts, opts[_settings.resume])))
+
+        # Lockout
+        opts = ["Off", "Rpt", "Busy"]
+        general.append(
+            RadioSetting(
+                "lockout", "Lockout",
+                RadioSettingValueList(opts, opts[_settings.lockout])))
+
+        # Squelch Delay
+        opts = ["Short", "Long"]
+        general.append(
+            RadioSetting(
+                "squelch_delay", "Squelch Delay",
+                RadioSettingValueList(opts, opts[_settings.squelch_delay])))
+
+        # Memory Display
+        opts = ["Frequency", "Channel", "Name"]
+        general.append(
+            RadioSetting(
+                "mem_display", "Memory Display",
+                RadioSettingValueList(opts, opts[_settings.mem_display])))
+
+        # Function Mode
+        opts = ["0 sec", "1 sec", "2 sec", "3 sec", "Manual"]
+        general.append(
+            RadioSetting(
+                "func_mode", "Function Mode",
+                RadioSettingValueList(opts, opts[_settings.func_mode])))
+
+        # Battery Save
+        opts = ["Off", "Li-Ion"]
+        general.append(
+            RadioSetting(
+                "battery_save", "Battery Save",
+                RadioSettingValueList(opts, opts[_settings.battery_save])))
+
+        # Power Save
+        opts = ["Off", "1:2", "1:8", "1:16", "Auto"]
+        general.append(
+            RadioSetting(
+                "pwr_save", "Power Save",
+                RadioSettingValueList(opts, opts[_settings.pwr_save])))
+
+        # Monitor
+        opts = ["Push", "Hold"]
+        general.append(
+            RadioSetting(
+                "monitor", "Monitor",
+                RadioSettingValueList(opts, opts[_settings.monitor])))
+
+        # Select Speed
+        opts = ["Manual", "Auto"]
+        general.append(
+            RadioSetting(
+                "sel_speed", "Select Speed",
+                RadioSettingValueList(opts, opts[_settings.sel_speed])))
+
+        # Mic Function
+        opts = ["Simple", "Normal 1", "Normal 2"]
+        general.append(
+            RadioSetting(
+                "mic_func", "Mic Function",
+                RadioSettingValueList(opts, opts[_settings.mic_func])))
+
+        # Dial Function
+        opts = ["Audio Volume", "Tuning Dial"]
+        general.append(
+            RadioSetting(
+                "dial_func", "Dial Function",
+                RadioSettingValueList(opts, opts[_settings.dial_func])))
+
+        return settings
+
+    def set_settings(self, settings):
+        _settings = self._memobj.settings
+        for element in settings:
+            if not isinstance(element, RadioSetting):
+                self.set_settings(element)
+                continue
+            if not element.changed():
+                continue
+
+            try:
+                if element.has_apply_callback():
+                    LOG.debug("Using apply callback")
+                    element.run_apply_callback()
+                else:
+                    setting = element.get_name()
+                    LOG.debug("Setting %s = %s" % (setting, element.value))
+                    setattr(_settings, setting, element.value)
+            except Exception, e:
+                LOG.debug(element.get_name())
+                raise
+
     def _get_bank(self, number):
         _flag = self._memobj.flags[number]
         if _flag.bank == 0x0a:



More information about the chirp_devel mailing list