############################################ #create two instances of plot windows qtPanningPlot1 = QtPanningPlot("Input Signal") qtPanningPlot2 = QtPanningPlot("Output Frequency") #create a thread which gets the data from the USB-DUX t = threading.Thread(target=getDataThread, args=(qtPanningPlot1, qtPanningPlot2, ringbuffer, frequency, n)) ############################################ # start data acquisition c.start(8, 1345) # start the thread getting the data t.start() # showing all the windows app.exec_() # no more data from the USB-DUX c.stop() # Signal the Thread to stop running = False # Waiting for the thread to stop t.join()
#!/usr/bin/python3 import pyusbdux as dux dux.open() dux.start(8) while True: sample = dux.getSampleFromBuffer() print(sample)
data = [] # Let's create two instances of plot windows qtPanningPlot1 = QtPanningPlot("Unfiltered") qtPanningPlot2 = QtPanningPlot("Filtered") # create a thread which gets the data from the USB-DUX t = threading.Thread(target=getDataThread, args=( qtPanningPlot1, qtPanningPlot2, )) # start data acquisition c.start(8, 250) # start the thread getting the data t.start() # showing all the windows app.exec_() # no more data from the USB-DUX c.stop() # Signal the Thread to stop running = False # Waiting for the thread to stop t.join()
def data_gen(): #endless loop which gets data # filter = MyAmazingFilter(...) while True: data = np.zeros(0) while c.hasSampleAvailable(): sample = c.getSampleFromBuffer() data = np.append(data,sample[0]) # for filtering add here: # data = filter.dofilter(data) yield data c.open() print("ADC board:",c.get_board_name()) c.start(1,8000) print("Actual samplingrate =",c.getSamplingRate(),"Hz") # now let's plot the data fig, ax = plt.subplots() # that's our plotbuffer plotbuffer = np.zeros(500) # plots an empty line line, = ax.plot(plotbuffer) # axis ax.set_ylim(-1.5, 1.5) # start the animation ani = animation.FuncAnimation(fig, update, data_gen, interval=100)