[chirp_devel] [h777] Enable sidekey configuration for Radioddity GA-2S
Hi All,
This is my first patch submission for CHIRP. :)
I am open to suggestions on the global variable hack. If more of these variables were inside a class then it would be trivial to update it in the __init__() method using self.SIDEKEYFUNCTION_LIST
I tried to minimize the amount of code I touched. This patch works with both of my Radioddity GA-2S units (ordered as a pair). Changing the sidekey to "TX Power" (as defined by Baofeng 888) seemed to disable the sidekey.
Thanks, Tony
# HG changeset patch # User Tony F goldstar611@hotmail.com # Date 1565919586 18000 # Thu Aug 15 20:39:46 2019 -0500 # Node ID a4de835cd49d431e81c906b62aac28fd87f4a268 # Parent 42b4bb639fb6892826091a8a86bf9347b116fe51 [h777] Enable sidekey configuration for Radioddity GA-2S Issue #6217 https://chirp.danplanet.com/issues/6217 NOTE: TX Power cannot be adjusted using the sidekey
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py --- a/chirp/drivers/h777.py +++ b/chirp/drivers/h777.py @@ -618,9 +618,13 @@ VENDOR = "Radioddity" MODEL = "GA-2S" _has_fm = False - _has_sidekey = False
@classmethod def match_model(cls, filedata, filename): # This model is only ever matched via metadata return False + + def get_settings(self): + globals()["SIDEKEYFUNCTION_LIST"] = ["Off", "Monitor", "Unused", "Alarm"] + return super(ROGA2SRadio, self).get_settings() +
I am open to suggestions on the global variable hack. If more of these variables were inside a class then it would be trivial to update it in the __init__() method using self.SIDEKEYFUNCTION_LIST
Yeah, just move that list definition into the parent class, and override it in the appropriate subclass. Minimizing impact to existing code is good, but do as much as you need to make it _right_ :) You definitely can't modify the global, because if I'm using two radios together, one of which is a GA-2S, after I've used the driver to work with it, it's broken until restart for another variant :)
--Dan
Dan,
Thank you for your valuable insight and I'm glad we are on the same page. Here is take 2 on that GA-2S patch.
It would be great if others could test that their 666/777/888 radios aren't affected.
Thanks, Tony
--- # HG changeset patch # User Tony F goldstar611@hotmail.com # Date 1565994341 18000 # Fri Aug 16 17:25:41 2019 -0500 # Branch issue_6217 # Node ID 454ca84be9ac05fbc32a224325142f9561a9c2ac # Parent 42b4bb639fb6892826091a8a86bf9347b116fe51 [h777] Enable sidekey for Radioddity GA-2S Issue #6217 https://chirp.danplanet.com/issues/6217 NOTE: Setting side key to "TX Power" has no affect on radio
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py --- a/chirp/drivers/h777.py +++ b/chirp/drivers/h777.py @@ -82,7 +82,6 @@ H777_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00), chirp_common.PowerLevel("High", watts=5.00)] VOICE_LIST = ["English", "Chinese"] -SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit Power", "Alarm"] TIMEOUTTIMER_LIST = ["Off", "30 seconds", "60 seconds", "90 seconds", "120 seconds", "150 seconds", "180 seconds", "210 seconds", "240 seconds", "270 seconds", @@ -288,6 +287,10 @@ _has_fm = True _has_sidekey = True
+ def __init__(self, *args, **kwargs): + super(H777Radio, self).__init__(*args, **kwargs) + self.SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit Power", "Alarm"] + def get_features(self): rf = chirp_common.RadioFeatures() rf.has_settings = True @@ -521,8 +524,8 @@ if self._has_sidekey: rs = RadioSetting("settings2.sidekeyfunction", "Side key function", RadioSettingValueList( - SIDEKEYFUNCTION_LIST, - SIDEKEYFUNCTION_LIST[ + self.SIDEKEYFUNCTION_LIST, + self.SIDEKEYFUNCTION_LIST[ self._memobj.settings2.sidekeyfu nction])) basic.append(rs)
@@ -618,9 +621,12 @@ VENDOR = "Radioddity" MODEL = "GA-2S" _has_fm = False - _has_sidekey = False
@classmethod def match_model(cls, filedata, filename): # This model is only ever matched via metadata return False + + def __init__(self, *args, **kwargs): + super(ROGA2SRadio, self).__init__(*args, **kwargs) + self.SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Unused", "Alarm"]
On Fri, 2019-08-16 at 08:14 -0700, Dan Smith via chirp_devel wrote:
I am open to suggestions on the global variable hack. If more of these variables were inside a class then it would be trivial to update it in the __init__() method using self.SIDEKEYFUNCTION_LIST
Yeah, just move that list definition into the parent class, and override it in the appropriate subclass. Minimizing impact to existing code is good, but do as much as you need to make it _right_ :) You definitely can't modify the global, because if I'm using two radios together, one of which is a GA-2S, after I've used the driver to work with it, it's broken until restart for another variant :)
--Dan _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
@@ -288,6 +287,10 @@ _has_fm = True _has_sidekey = True
- def __init__(self, *args, **kwargs):
super(H777Radio, self).__init__(*args, **kwargs)
self.SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit
Power", "Alarm"]
You don't need to do this. Just put SIDEKEYFUNCTION_LIST in the class definition (like _has_sidekey) and use it as self.SIDEKEYFUNCTION_LIST as you do below. Then in the GA-2S class definition, just define it there as well and it will win over the parent's definition as appropriate. Should be two new lines, and the one changed one to use the instance-local version. What you have here is better than the global of course, but if anyone subclasses it and doesn't run super(), then they'd break.
I have some clones of this radio and can test when I go to apply the final one.
--Dan
Dan,
Thanks for the quick reply. Here goes #3. I tested it out with my GA-2S by downloading as both a GA-2S and also downloading as a Baofeng 888 in separate tabs and the settings menu looks to be correct.
Tony.
---
# HG changeset patch # User Tony F goldstar611@hotmail.com # Date 1565994341 18000 # Fri Aug 16 17:25:41 2019 -0500 # Branch issue_6217 # Node ID c52a31f7fee79b5c3f83b9adc52f61434d18800f # Parent 42b4bb639fb6892826091a8a86bf9347b116fe51 [h777] Enable sidekey for Radioddity GA-2S Issue #6217 https://chirp.danplanet.com/issues/6217 NOTE: Setting side key to "TX Power" has no affect on radio
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py --- a/chirp/drivers/h777.py +++ b/chirp/drivers/h777.py @@ -82,7 +82,6 @@ H777_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00), chirp_common.PowerLevel("High", watts=5.00)] VOICE_LIST = ["English", "Chinese"] -SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit Power", "Alarm"] TIMEOUTTIMER_LIST = ["Off", "30 seconds", "60 seconds", "90 seconds", "120 seconds", "150 seconds", "180 seconds", "210 seconds", "240 seconds", "270 seconds", @@ -268,6 +267,7 @@
ALIASES = [ArcshellAR5, ArcshellAR6, GV8SAlias, GV9SAlias, A8SAlias, TenwayTW325Alias] + SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit Power", "Alarm"]
# This code currently requires that ranges start at 0x0000 # and are continious. In the original program 0x0388 and 0x03C8 @@ -521,8 +521,8 @@ if self._has_sidekey: rs = RadioSetting("settings2.sidekeyfunction", "Side key function", RadioSettingValueList( - SIDEKEYFUNCTION_LIST, - SIDEKEYFUNCTION_LIST[ + self.SIDEKEYFUNCTION_LIST, + self.SIDEKEYFUNCTION_LIST[ self._memobj.settings2.sidekeyfu nction])) basic.append(rs)
@@ -618,9 +618,10 @@ VENDOR = "Radioddity" MODEL = "GA-2S" _has_fm = False - _has_sidekey = False + SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Unused", "Alarm"]
@classmethod def match_model(cls, filedata, filename): # This model is only ever matched via metadata return False +
On Fri, 2019-08-16 at 15:42 -0700, Dan Smith via chirp_devel wrote:
@@ -288,6 +287,10 @@ _has_fm = True _has_sidekey = True
- def __init__(self, *args, **kwargs):
super(H777Radio, self).__init__(*args, **kwargs)
self.SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Transmit
Power", "Alarm"]
You don't need to do this. Just put SIDEKEYFUNCTION_LIST in the class definition (like _has_sidekey) and use it as self.SIDEKEYFUNCTION_LIST as you do below. Then in the GA-2S class definition, just define it there as well and it will win over the parent's definition as appropriate. Should be two new lines, and the one changed one to use the instance-local version. What you have here is better than the global of course, but if anyone subclasses it and doesn't run super(), then they'd break.
I have some clones of this radio and can test when I go to apply the final one.
--Dan _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
Thanks for the quick reply. Here goes #3. I tested it out with my GA-2S by downloading as both a GA-2S and also downloading as a Baofeng 888 in separate tabs and the settings menu looks to be correct.
Cool, that looks better, except:
@@ -618,9 +618,10 @@ VENDOR = "Radioddity" MODEL = "GA-2S" _has_fm = False
- _has_sidekey = False
SIDEKEYFUNCTION_LIST = ["Off", "Monitor", "Unused", "Alarm"]
@classmethod def match_model(cls, filedata, filename): # This model is only ever matched via metadata return False
You're adding random space here. But, I'll let it slide :)
Also note that your mailer wrapped all the long lines, which ruins the diff. I hand edited it to make it apply, but if you're going to send more you might check out the patchbomb extension so you can email straight from hg.
Thanks!
--Dan
participants (2)
-
Dan Smith
-
Tony Fuller