[chirp_devel] def convert_freq_to_bytes(real_freq):

Jim Unroe
Tue Jan 22 02:41:51 PST 2013


Thanks Les and Marc0,

I tried this quickly before work and ran into this problem
"NameError: global name 'convert_freq_to_bytes' is not defined"

I study some other drivers after work to see if I can find something
similar to mimic. Here is how I am trying to use it just in case you can
spot what I am doing wrong.

I've added 2 "elif" bits of code to the set_settings procedure

    def set_settings(self, settings):
        _settings = self._memobj.settings[0]
        for element in settings:
            if not isinstance(element, RadioSetting):
                self.set_settings(element)
                continue
            elif element.get_name() == "vfoa.freq":
                convert_freq_to_bytes(self._memobj.vfoa.freq, element.value)
            elif element.get_name() == "vfob.freq":
                convert_freq_to_bytes(self._memobj.vfob.freq, element.value)
            try:

Then I placed the following just ahead of my menu item

    def convert_freq_to_bytes(real_freq):
        bytes = [ 0 for x in range(0,8) ]   # init list with 8 times 0
        real_freq = int(freq * 100000)      # it has to be integer
        for i in range(7, -1, -1):          # go from 7 to 0
            bytes[i] = real_freq%10         # extract last digit
            real_freq /= 10                 # throw away last digit
        return bytes

When I got the "not defined" error, I moved it above "def
set_settings(self, settings):" but got the same "not defined".

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20130122/fa65cd81/attachment-0001.html 


More information about the chirp_devel mailing list