<html><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:10pt"><div><span>Not that this fixes your specific problem, but I have run into a few different settings which have this sort of "inverted" logic.</span></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">To keep things simple in the rest of the code, I just name the setting appropriately so that the logic in the rest of the program need not be inverted, e.g., name your setting foo_disable if value of True/1 disables foo, and foo_enable if True/1 enables foo.</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style:
normal;">I think it makes it easier to read.</div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">"beep_tone" is a boolean? </div><div style="color: rgb(0, 0, 0); font-size: 13px; font-family: 'lucida console', sans-serif; background-color: transparent; font-style: normal;">If I'm reading that "beep_tone_disabled" seems like it would be a much more meaningful name for the setting field.</div><div><br></div> <div style="font-family: 'lucida console', sans-serif; font-size: 10pt;"> <div style="font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1"> <font size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Jim Unroe <rock.unroe@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> chirp-devel
<chirp_devel@intrepid.danplanet.com> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, January 20, 2014 8:53 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> [chirp_devel] Inverted Boolean Help Needed<br> </font> </div> <div class="y_msg_container"><br><div id="yiv5148303201"><div dir="ltr"><div><div><div><div><div><div>The UV-B5/B6 has a ON/OFF setting that is inverted. 0 = ON and 1 = OFF.<br><br></div>I was using a list to get around it. Then I saw in the h777.py driver there were a pair of inverted settings. It thought I replicated this for my needs but apparently I didn't do enough testing and what I have is broken. This is in the uvb5.py driver.<br>
<br></div>Here is the setting...<br><br> rs = RadioSetting("beep_tone", "Beep Prompt",<br> RadioSettingValueBoolean(not _settings.beep_tone))<br> basic.append(rs)<br>
<br></div>And here is the rest...<br><br> if element.has_apply_callback():<br> print "Using apply callback"<br> element.run_apply_callback()<br> elif setting == "beep_tone":<br>
print "Setting %s = %s" % (setting, not (element.value))<br> setattr(obj, setting, not (element.value))<br> else:<br> print "Setting %s = %s" % (setting, element.value)<br>
setattr(obj, setting, element.value)<br> except Exception, e:<br> print element.get_name()<br> raise<br><br></div>No matter if the setting is enabled or disabled, FALSE is always returned so the Beep Prompt is always enabled.<br>
<br></div>Can somebody spot what I am doing wrong?<br><br></div>Thanks,<br>Jim<br></div>
</div><br>_______________________________________________<br>chirp_devel mailing list<br><a ymailto="mailto:chirp_devel@intrepid.danplanet.com" href="mailto:chirp_devel@intrepid.danplanet.com">chirp_devel@intrepid.danplanet.com</a><br><a href="http://intrepid.danplanet.com/mailman/listinfo/chirp_devel" target="_blank">http://intrepid.danplanet.com/mailman/listinfo/chirp_devel</a><br>Developer docs: <a href="http://chirp.danplanet.com/projects/chirp/wiki/Developers" target="_blank">http://chirp.danplanet.com/projects/chirp/wiki/Developers</a><br><br></div> </div> </div> </div></body></html>