/usr/share/expeyes/eyes/interference-sound.py is in expeyes 3.1.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | '''
expEYES program
Author : Ajith Kumar B.P, bpajith@gmail.com
License : GNU GPL version 3
'''
import gettext
gettext.bindtextdomain("expeyes")
gettext.textdomain('expeyes')
_ = gettext.gettext
from Tkinter import *
import expeyes.eyes as eyes, expeyes.eyeplot as eyeplot, expeyes.eyemath as eyemath, time, math
TIMER = 10
WIDTH = 800 # width of drawing canvas
HEIGHT = 400 # height
delay = 50 # Time interval between samples
NP = 500 # Number of samples
data = [] # Of the form, [ [x1,y1], [x2,y2],....] where x and y are vectors
outmask = 1
looping = False
def update():
global data, looping, NP, delay
if looping == False:
return
data = []
t,v = p.capture(0,NP,delay)
g.delete_lines()
g.line(t,v)
data.append([t,v])
fa = eyemath.fit_sine(t, v)
if fa != None:
#g.line(t,fa[0], 8)
rms = p.rms(v)
f0 = fa[1][1] * 1000
s = _('Freq = %5.0f Hz')%(fa[1][1]*1000)
else:
s = _('No Signal')
msgwin.config(text=s) # CRO part over
root.after(TIMER, update)
def start():
global looping, NP, delay
p.disable_actions()
n = int(Nsam.get())
if 100 <= n <=1800: # Number of samples
NP = n
g.setWorld(0,-5, NP * delay * 0.001, 5,_('mS'),_('V'))
print NP
if RUN.get() == 1:
if A0.get() == 1:
f = float(Freq0.get())
fr = p.set_sqr0(f-1)
Freq0.delete(0,END)
Freq0.insert(0,'%5.1f'%fr)
else:
p.set_sqr0(0)
if A1.get() == 1:
f = float(Freq.get())
fr = p.set_sqr1(f-1)
Freq.delete(0,END)
Freq.insert(0,'%5.1f'%fr)
else:
p.set_sqr1(0)
looping = True
p.set_upv(5)
#p.adc2cmp(7)
#p.enable_wait_rising(4)
RS.config(text=_('STOP'))
root.after(TIMER, update)
else:
RS.config(text=_('START'))
looping = False
p.set_sqr1(0)
p.set_sqr0(0)
def do_fft():
global data, delay, NP
if data == []: return
fr,tr = eyemath.fft(data[0][1], delay * 0.001)
p.save([ [fr,tr] ], 'FFT.dat')
p.grace([ [fr,tr] ], _('freq'), _('power'))
msgwin.config(text = _('Fourier transform Saved to FFT.dat.'))
def save():
global data
s = fn.get()
if s == '':
return
p.save(data, s)
msgwin.config(text = _('Data saved to file ')+s)
def xmgrace(): # Send the data to Xmgrace
global data
p.grace(data, _('milliSeconds'), _('Volts'))
def quit():
p.write_outputs(0)
sys.exit()
p = eyes.open()
p.loadall_calib()
p.set_sqr1(0)
root = Tk()
Canvas(root, width = WIDTH, height = 5).pack(side=TOP) # Some space at the top
g = eyeplot.graph(root, width=WIDTH, height=HEIGHT) # make plot objects using draw.disp
g.setWorld(0,-5, NP * delay * 0.001, 5,_('mS'),_('V'))
if p == None:
g.text(0, 0,_('EYES Hardware Not Found. Check Connections and restart the program'),1)
root.mainloop()
sys.exit()
p.set_voltage(1,5)
cf = Frame(root, width = WIDTH, height = 10)
cf.pack(side=TOP, fill = BOTH, expand = 1)
l = Label(cf,text=_('NS ='))
l.pack(side=LEFT, anchor=SW)
Nsam = Entry(cf,width = 4, bg = 'white')
Nsam.pack(side=LEFT, anchor = SW)
Nsam.insert(END,'200')
A0 = IntVar()
cb1 = Checkbutton(cf,text =_('PULSE='), variable=A0, fg = 'blue')
cb1.pack(side=LEFT, anchor = SW)
A0.set(0)
Freq0 = Entry(cf,width = 10, bg = 'white')
Freq0.pack(side=LEFT, anchor = SW)
Freq0.insert(END,'4000')
A1 = IntVar()
cb1 = Checkbutton(cf,text =_('SQR1='), variable=A1, fg = 'blue')
cb1.pack(side=LEFT, anchor = SW)
A1.set(0)
Freq = Entry(cf,width = 10, bg = 'white')
Freq.pack(side=LEFT, anchor = SW)
Freq.insert(END,'3800')
RUN = IntVar()
RS = Checkbutton(cf,text =_('START'), command = start, variable= RUN, fg = 'blue')
RS.pack(side=LEFT, anchor = SW)
RUN.set(0)
b = Button(cf,text =_('Xmgrace'), command=xmgrace)
b.pack(side=LEFT, anchor = SW)
b = Button(cf,text =_('FFT'), command=do_fft)
b.pack(side=LEFT, anchor = SW)
b = Button(cf,text =_('Save to'), command=save)
b.pack(side=LEFT, anchor = SW)
fn = Entry(cf,width = 10, bg = 'white')
fn.pack(side=LEFT, anchor = SW)
fn.insert(END,'sound.dat')
b = Button(cf,text =_('QUIT'), command=quit)
b.pack(side=RIGHT, anchor = SW)
mf = Frame(root) # Message Frame below command frame.
mf.pack(side=TOP, anchor = SW)
msgwin = Label(mf,text = _('Messages'), fg = 'blue')
msgwin.pack(side=LEFT, anchor = SW)
eyeplot.pop_image('pics/sound-beats.png', _('Sound Interference'))
root.title(_('EYES: Interference of Sound'))
root.mainloop()
|