Re: [chirp_devel] Mods for the UV-5R
Since this is new-plans stuff, I'm going to drag you over to the devel mailing list. Let's continue the discussion there.
Unfortunately Baofeng didn't just tack new settings on the end. They inserted 20.0K in between 12.5K and 25.0K. I can easily change it by adding the 2 additional selections, but I'm afraid someone selecting 20.0K on an older firmware will actually get 25.0K. I would need help knowing how to make two lists and then selecting the correct one based on the firmware version being used.
Right, so there's a method on the driver called "_is_orig()" that will return True if it is the "original" style of firmware, or False if it's the newer kind. So, you can do something like this:
tuning_steps = list(STEP_LIST) # Make a copy of the main list if not self._is_orig(): tuning_steps.insert(5, 20.0) # Insert 20.0 at index 5 tuning_steps.insert(...)
Then just change the initialization of the setting to use the tuning_steps list instead of the global constant one.
I would like to add most of the rest of the settings that would go on the Settings tabs. That should be fairly easy for me to do. I believe that, with your excellent guidence, I have a good start on that.
Yep, sounds like you've got a good handle on that part.
Then what I would like to do is tackle some of the 'per channel' settings like Busy Channel Lockout, S-CODE, PTT-ID (if that is even possible).
Yep, that's good. Anything that the Memory class has in it should be supported that way (i.e. the Memory class in chirp_common.py). However, features not supported there can be added to the "extra" field in Memory. This field lets you stuff settings (just like you've been doing for the radio-wide settings) that are specific to a memory channel in there, which are exposed to the user via the Right-click->Edit dialog box. See the ft817.py driver for an example. Look in get_memory() and set_memory() for where mem.extra is manipulated.
Thanks Jim!
Unfortunately Baofeng didn't just tack new settings on the end. They inserted 20.0K in between 12.5K and 25.0K. I can easily change it by adding the 2 additional selections, but I'm afraid someone selecting 20.0K on an older firmware will actually get 25.0K. I would need help knowing how to make two lists and then selecting the correct one based on the firmware version being used.
Right, so there's a method on the driver called "_is_orig()" that will return True if it is the "original" style of firmware, or False if it's the newer kind. So, you can do something like this:
tuning_steps = list(STEP_LIST) # Make a copy of the main list if not self._is_orig(): tuning_steps.insert(5, 20.0) # Insert 20.0 at index 5 tuning_steps.insert(...)
Then just change the initialization of the setting to use the tuning_steps list instead of the global constant one.
OK. That should work for STEP because it changed with BFB291. But other menus that need attention, like VOICE, changed at BFB251. That will probably require a different type of check. For pre-BFB251 the selection is OFF or ON, which is what CHIRP currently supports. But for BFB251 and later the selection is OFF, ENGlish or CHInese. Fortunately most want OFF or ENG so the existing code probably works fine for most users. I'd still like to see it support the menu fully though.
Then what I would like to do is tackle some of the 'per channel'
settings like Busy Channel Lockout, S-CODE, PTT-ID (if that is even possible).
Yep, that's good. Anything that the Memory class has in it should be supported that way (i.e. the Memory class in chirp_common.py). However, features not supported there can be added to the "extra" field in Memory. This field lets you stuff settings (just like you've been doing for the radio-wide settings) that are specific to a memory channel in there, which are exposed to the user via the Right-click->Edit dialog box. See the ft817.py driver for an example. Look in get_memory() and set_memory() for where mem.extra is manipulated.
I'll study this a bit before I do anything. I'll probably have questions.
Thanks Jim!
Thank you. I appreciate the guidance and the willingness to let me help out.
-- Dan Smith www.danplanet.com KK7DS
Jim
OK. That should work for STEP because it changed with BFB291. But other menus that need attention, like VOICE, changed at BFB251. That will probably require a different type of check. For pre-BFB251 the selection is OFF or ON, which is what CHIRP currently supports. But for BFB251 and later the selection is OFF, ENGlish or CHInese. Fortunately most want OFF or ENG so the existing code probably works fine for most users. I'd still like to see it support the menu fully though.
Okay, so lets add another method called _my_version() that returns the integer firmware version:
def _my_version(self): version_tag = _firmware_version_from_image(self) if 'BFB' in version_tag: idx = version_tag.index("BFB") + 3 return int(version_tag[idx:idx+3]) raise Exception("Unrecognized firmware version string")
Then you can check this in other parts of the code, like this:
if self._my_version() >= 251: # do something special
Could also change the other uses of _is_orig() to be something like the above to keep the pattern the same and then nix the actual _is_orig() method once they're all converted. That would make the other special cases more clearly tied to a specific firmware version.
I'll study this a bit before I do anything. I'll probably have questions.
We'll answer 'em!
Thanks :)
See the ft817.py driver for an example. Look in get_memory() and
set_memory() for where mem.extra is manipulated.
I'll study this a bit before I do anything. I'll probably have questions.
Feel free to ask for any detail :)
73 de IZ3GME Marco
participants (3)
-
Dan Smith
-
Jim Unroe
-
Marco IZ3GME