By creating the
fpga = py_fpga(i2c_bus=i2c_bus, py_audio=p, spi_bus=spi)
Choosing the timings of the board: initial delay, pHV is positive HV length, PnHV is the negative one, PDamp the time to dampen the signal (unit being 1/64 of a microsecond //note to self, check if that's right, and not 1/32). All of this is happenning during the acquisition window that is 128us long.
fpga.set_waveform(pdelay=1, PHV_time=11, PnHV_time=1, PDamp_time=100)
The VGA can be set up by tranches of 8us, so with 16 values out of the 128us acquisition window. Values from 0 to 511.
startVal,nPtsDAC = 250, 16
for i in range(nPtsDAC):
fpga.set_dac(int(startVal + (i*(455-startVal))/nPtsDAC), mem=i)
Now we setup the HILO value, and setting the gain outside of the acquisition window.
hiloVal = 1 # High or low.
dacVal = 250 # on a range from 0 to 512
fpga.set_HILO(hiloVal)
fpga.set_dac(dacVal)
Each is spaced by approx 1ms (time taken to do the FFT+filtering) + transfert through i2s (//note to self, check again :).
dataI2S = fpga.read_fft_through_i2s(10)
dataSPI = fpga.read_signal_through_spi()
fpga.calc_fft()
time.sleep(3/1000.0) # normally takes ~800us to compute 8192pts
dataFFT = fpga.read_fft_through_spi()
Let me know if there's something else to add.