c994406
#!/usr/bin/wish
c994406
# Matt Willis - simple tk interface to fmtools 
c994406
# The radio keeps on after leaving.
c994406
# -*- tcl -*-
c994406
c994406
# These are stations in the Rio de Janeiro area. Customize for your own locale.
c994406
set stations \
c994406
        "
c994406
	MPB          90.3 
c994406
        CBN          92.5 
c994406
	BandNews     94.9
c994406
        PARADISO     95.7
c994406
	Nativa       96.5
c994406
	98FM         98.0 
c994406
	MEC          98.9 
c994406
	JBFM         99.7
c994406
	O_Dia        100.5
c994406
	Transamerica 101.3
c994406
	JovenPan     102.1
c994406
	Oi           102.9
c994406
	Antena1	     103.7
c994406
	"
c994406
c994406
# intial volume
c994406
set volume 100
c994406
set n [expr [llength $stations]/2]
c994406
# default radio station
c994406
set radbut 3
c994406
c994406
# make tuner buttons
c994406
frame .labels
c994406
for {set i 0} {$i<$n} {incr i 1} {
c994406
    radiobutton .r$i -value $i -variable radbut \
c994406
	    -text [lindex $stations [expr $i *2]] -command setstation
c994406
    pack .r$i -anchor w -in .labels
c994406
}
c994406
c994406
# turns the radio on
c994406
eval exec fm on
c994406
c994406
frame .rhs
c994406
scale .vol -orient horizontal -from 0 -to 100 -showvalue 0 \
c994406
	-variable volume -label Volume:
c994406
entry .stn -bg black -fg yellow -font "-*-helvetica-*-r-*-*-60-*-*-*-*-*-*-*" \
c994406
	-width 6 -justify right -state disabled
c994406
button .exit -command exit -text exit
c994406
pack .vol .stn .exit -in .rhs
c994406
c994406
pack .labels .rhs -side left
c994406
.vol configure -command setvolume
c994406
c994406
proc setstation {} {
c994406
    global stations radbut volume
c994406
#   roma 20091221
c994406
#   eval exec fm [lindex $stations [expr $radbut*2+1]] $volume
c994406
    eval exec fm [lindex $stations [expr $radbut*2+1]]
c994406
    eval exec amixer -q -c 0 set PCM $volume%
c994406
    .stn configure -state normal
c994406
    .stn delete 0 end
c994406
    .stn insert 0  [lindex $stations [expr $radbut*2+1]]
c994406
    .stn configure -state disabled
c994406
}
c994406
c994406
proc setvolume {sliderval} {
c994406
    setstation
c994406
}