[chirp_devel] [PATCH] [UV-B5] Add Broadcast FM Radio Presets for Baofeng UV-B5/B6

Jim Unroe
Mon Jul 22 19:46:46 PDT 2013


# HG changeset patch
# User Jim Unroe <rock.unroe at gmail.com>
# Date 1374547368 14400
# Node ID d6e861a71154d0eb983a3ec5407668223a0949c4
# Parent  d5095e3a1c506a93d9933646353f22ac34050607
[UV-B5] Add Broadcast FM Radio Presets for Baofeng UV-B5/B6
#995

diff -r d5095e3a1c50 -r d6e861a71154 chirp/uvb5.py
--- a/chirp/uvb5.py	Sun Jul 14 23:42:23 2013 -0700
+++ b/chirp/uvb5.py	Mon Jul 22 22:42:48 2013 -0400
@@ -48,6 +48,11 @@
 #seekto 0x0850;
 struct memory vfo2;
 
+#seekto 0x09D0;
+struct {
+  u16 freq;
+} broadcastfm[16];
+
 #seekto 0x0A30;
 struct {
   u8 name[5];
@@ -512,6 +517,29 @@
         rs.set_apply_callback(apply_limit, self._memobj.limits)
         basic.append(rs)
 
+        bcastfm = RadioSettingGroup("bcastfm", "FM Radio Presets")
+        group.append(bcastfm)
+
+        def convert_bytes_to_freq(bytes):
+            real_freq = int(bytes) + 650
+            if real_freq > 1080:
+                real_freq = 0
+            return chirp_common.format_freq(real_freq * 100000)
+
+        def apply_freq(setting, obj):
+            value = chirp_common.parse_freq(str(setting.value)) / 100000
+            if value < 650 or value > 1080:
+                value = 65535 + 650
+            obj.freq = value - 650
+
+        for i in range(0, 16):
+            _freq = RadioSettingValueString(0, 10,
+               convert_bytes_to_freq(self._memobj.broadcastfm[i].freq))
+            rs = RadioSetting("broadcastfm/%i.freq" % i,
+                              "Channel %i (65.0-108.0)" % (i + 1), _freq)
+            rs.set_apply_callback(apply_freq, self._memobj.broadcastfm[i])
+            bcastfm.append(rs)
+
         return group
 
     def set_settings(self, settings):



More information about the chirp_devel mailing list