[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Working radio Knob
From: |
cswiger |
Subject: |
[Discuss-gnuradio] Working radio Knob |
Date: |
Wed, 9 Feb 2005 15:39:53 -0500 (EST) |
Gang - Just for the record, one of the Griffin "Power Mate"
knobs looked like a good way to control a radio (for those
of us who enjoy searching for old fashioned dx) as it has
Python script support:
http://www.sowerbutts.com/powermate/powermate.py
and is supported out-of-box in Fedora Core 3.
This quickie script uses the knob to control frequency, volume and
time (file position), the mode being signaled by the light in the
base of the knob. No light means it is in tune mode, solid light is
volume mode, and pulsing light is for time control. Pushing down on
the knob switches modes. One benefit is you can control the radio
while staying focused on another window, plus twisting a knob is just
plain fun.
Sample script schematic:
import pm # powermate.py saved as pm.py
def build_graph (freq,scale)
fg = flow_graph () # create graph
src = gr.file_source () # time controlled with file position
xlate = gr.freq_xlating_fir_filter_XXX () # tune your radio here
scale = gr.multiply_const_ff () # set volume
return fg, xlate, scale, src
def main ()
freq = 3900e3 # initial settings
scale = .5
fg = build_graph (freq,scale)
fg[0].start ()
pause = 0
knob = pm.PowerMate() # get instance
knob_state = "freq" # knob mode
pm.PowerMate.SetLEDState(knob,0,255,1,0,0) # turn on freq mode lite
while 1:
control = pm.PowerMate.WaitForEvent(knob,30) # wait 30s for event
if control != None: # something happened
if control[3] == 256: # button pushed, change
if control[4] == 1: # mode.
if knob_state == "freq": # cycle thru modes
knob_state = "volume" # light on solid
pm.PowerMate.SetLEDState(knob,255,255,1,0,0)
else:
if knob_state == "volume":
knob_state = "time" # pulsing light
pm.PowerMate.SetLEDState(knob,255,264,1,0,1)
else:
if knob_state == "time":
knob_state = "freq" # light off
pm.PowerMate.SetLEDState(knob,0,255,1,0,0)
if control[3] == 7: # knob was turned
if knob_state == "freq": # check knob mode
if control[4] == 1:
freq += 100 # up 100 hz
fg[1].set_center_freq(3.8e6 - freq + 2.5e3)
print "Listening to", freq
if control[4] == -1:
freq -= 100 # down 100 hz
fg[1].set_center_freq(3.8e6 - freq + 2.5e3)
print "Listening to", freq
if knob_state == "volume":
if control[4] == 1:
scale += .1 # up one volume unit
fg[2].set_k(scale)
print "Volume", scale
if control[4] == -1:
scale -= .1 # down one volume unit
if scale <= 0: # unless at zero
scale = 0
fg[2].set_k(scale)
print "Volume", scale
if knob_state == "time":
if control[4] == 1:
fg[3].seek(1000000,gr.SEEK_CUR) # fwd in time
if control[4] == -1:
fg[3].seek(-1000000,gr.SEEK_CUR) # go back in time
Critique of python style always welcome - Sorry if it looks like BASIC ;)
but it does work.
--Chuck
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Discuss-gnuradio] Working radio Knob,
cswiger <=