[chirp_devel] [PATCH] [UV-3R] Add VFO Presets

Jim Unroe
Wed Nov 27 07:00:34 PST 2013


# HG changeset patch
# User Jim Unroe <rock.unroe at gmail.com>
# Date 1385557681 18000
# Node ID eba9762c517bde2cf8490a7177fabe9bdb7c056e
# Parent  9e619f3e597cec611e1bfb9ae673321ec0c849f7
[UV-3R] Add VFO Presets
expose vfo presets fields in memmap
add VFO Presets tab
add vfo presets
related to #1267

diff -r 9e619f3e597c -r eba9762c517b chirp/baofeng_uv3r.py
--- a/chirp/baofeng_uv3r.py	Tue Nov 26 16:52:40 2013 -0500
+++ b/chirp/baofeng_uv3r.py	Wed Nov 27 08:08:01 2013 -0500
@@ -101,6 +101,26 @@
   lbcd upper_uhf[2];
 } limits;
 
+struct vfosettings {
+  lbcd freq[4];
+  u8   rxtone;
+  u8   unknown1;
+  lbcd offset[3];
+  u8   txtone;
+  u8   power:1,
+       bandwidth:1,
+       unknown2:4,
+       duplex:2;
+  u8   step;
+  u8   unknown3[4];
+};
+
+#seekto 0x0790;
+struct {
+  struct vfosettings uhf;
+  struct vfosettings vhf;
+} vfo;
+
 #seekto 0x07C2;
 struct {
   u8 squelch;
@@ -435,6 +455,103 @@
         rs.set_apply_callback(apply_limit, self._memobj.limits)
         basic.append(rs)
 
+        vfo_preset = RadioSettingGroup("vfo_preset", "VFO Presets")
+        group.append(vfo_preset)
+
+        def convert_bytes_to_freq(bytes):
+           real_freq = 0
+           real_freq = bytes
+           return chirp_common.format_freq(real_freq * 10)
+
+        def apply_vhf_freq(setting, obj):
+            value = chirp_common.parse_freq(str(setting.value)) / 10
+            obj.vhf.freq = value
+
+        val = RadioSettingValueString(0, 10,
+            convert_bytes_to_freq(int(self._memobj.vfo.vhf.freq)))
+        rs = RadioSetting("vfo.vhf.freq", "VHF RX Frequency (115.00000-236.00000)", val)
+        rs.set_apply_callback(apply_vhf_freq, self._memobj.vfo)
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.vhf.duplex", "Shift Direction",
+                          RadioSettingValueList(DUPLEX_LIST,
+                                        DUPLEX_LIST[self._memobj.vfo.vhf.duplex]))
+        vfo_preset.append(rs)
+
+        #rs = RadioSetting("vfo.vhf.offset", "Offset (0-37995)",
+        #                  RadioSettingValueInteger(0, 37995, self._memobj.vfo.vhf.offset))
+        #vfo_preset.append(rs)
+
+        def convert_bytes_to_offset(bytes):
+           real_offset = 0
+           real_offset = bytes
+           return chirp_common.format_freq(real_offset * 10000)
+
+        def apply_vhf_offset(setting, obj):
+            value = chirp_common.parse_freq(str(setting.value)) / 10000
+            obj.vhf.offset = value
+
+        val = RadioSettingValueString(0, 10,
+            convert_bytes_to_offset(int(self._memobj.vfo.vhf.offset)))
+        rs = RadioSetting("vfo.vhf.offset", "Offset (0.00-37.995)", val)
+        rs.set_apply_callback(apply_vhf_offset, self._memobj.vfo)
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.vhf.power", "Power Level",
+                          RadioSettingValueList(POWER_LIST,
+                                        POWER_LIST[self._memobj.vfo.vhf.power]))
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.vhf.bandwidth", "Bandwidth",
+                          RadioSettingValueList(BANDWIDTH_LIST,
+                                        BANDWIDTH_LIST[self._memobj.vfo.vhf.bandwidth]))
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.vhf.step", "Step",
+                          RadioSettingValueList(STEP_LIST,
+                                        STEP_LIST[self._memobj.vfo.vhf.step]))
+        vfo_preset.append(rs)
+
+        def apply_uhf_freq(setting, obj):
+            value = chirp_common.parse_freq(str(setting.value)) / 10
+            obj.uhf.freq = value
+
+        val = RadioSettingValueString(0, 10,
+            convert_bytes_to_freq(int(self._memobj.vfo.uhf.freq)))
+        rs = RadioSetting("vfo.uhf.freq", "UHF RX Frequency (200.00000-529.00000)", val)
+        rs.set_apply_callback(apply_uhf_freq, self._memobj.vfo)
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.uhf.duplex", "Shift Direction",
+                          RadioSettingValueList(DUPLEX_LIST,
+                                        DUPLEX_LIST[self._memobj.vfo.uhf.duplex]))
+        vfo_preset.append(rs)
+
+        def apply_uhf_offset(setting, obj):
+            value = chirp_common.parse_freq(str(setting.value)) / 10000
+            obj.uhf.offset = value
+
+        val = RadioSettingValueString(0, 10,
+            convert_bytes_to_offset(int(self._memobj.vfo.uhf.offset)))
+        rs = RadioSetting("vfo.uhf.offset", "Offset (0.00-69.995)", val)
+        rs.set_apply_callback(apply_uhf_offset, self._memobj.vfo)
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.uhf.power", "Power Level",
+                          RadioSettingValueList(POWER_LIST,
+                                        POWER_LIST[self._memobj.vfo.uhf.power]))
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.uhf.bandwidth", "Bandwidth",
+                          RadioSettingValueList(BANDWIDTH_LIST,
+                                        BANDWIDTH_LIST[self._memobj.vfo.uhf.bandwidth]))
+        vfo_preset.append(rs)
+
+        rs = RadioSetting("vfo.uhf.step", "Step",
+                          RadioSettingValueList(STEP_LIST,
+                                        STEP_LIST[self._memobj.vfo.uhf.step]))
+        vfo_preset.append(rs)
+
         fm_preset = RadioSettingGroup("fm_preset", "FM Radio Presets")
         group.append(fm_preset)
 



More information about the chirp_devel mailing list