def main(adc, plt=None): # Assume adc is already loaded # Establish various parameters fs = adc.sample_rate # Arm the ADC adc.ready_pruss_for_burst() # Loop sample collection and processing while True: # Exit gracefully on CTRL-D try: # capture a set of samples y, _ = adc.burst() # process simultaneous channels angle = get_heading.calculate_heading(TARGET_FREQ, fs, y[0], y[1]) # print computation to the user logging.info("pinger is %d degrees right" % angle) except KeyboardInterrupt: print("Quitting program") break boot.dearm()
def main(adc, plt): # Initialize plotting environment fig,axes = plt.subplots(2,1) axes[0].hold(True) axes[1].hold(True) # Query user to select a channel adc.adc_status() s = raw_input("Please enter a comma-separated list of channels" + " you want to watch (any # from 0 - 3): ") ch_list = map(int, s.split(',')) # low hanging variables fs = adc.sample_rate M = adc.sample_length / adc.n_channels f_delta = fs / M f = np.arange(0, M * f_delta, f_delta) # Arm the ADC adc.ready_pruss_for_burst() # Loop sample collection and processing while True: # Stop gracefully on CTRL+D try: # Capture a set of samples y, _ = adc.burst() # Process simultaneous channels for ch in ch_list: print("Plotting #1") axes[0].plot(y[ch]) print("Done. Plotting #2") axes[1].plot(f, abs(fft(y[ch]))) plt.pause(0.01) #import pdb; pdb.set_trace() print("Done Plotting") axes[0].cla() axes[1].cla() except KeyboardInterrupt: print("Quitting program") break boot.dearm()
def main(adc, plt): adc.ready_pruss_for_burst() print("ADC is armed and ready.") raw_input("Press enter when ready...") # grab data (y, _) = adc.burst() if plt: user_input = raw_input("Would you like to plot the data?") if "y" == user_input: plot_output(adc, y, plt) boot.dearm() return y
def main(adc): # config the ADC for success adc.config([0x100]) adc.ready_pruss_for_burst() # config burning maching msk = Mask() # print("normal or burn?") user_input = raw_input(" >> ") # Creates a function that will return true if user_input matches # any of the provided variable arguments input_matches = functools.partial(match_against, user_input) # Some error handling if input_matches('burn'): print("What value should burn (1 or 0)?") msk.burn_bit = raw_input(" >> ") elif user_input != 'normal': print("I don't recognize that. Quitting program.") user_input = 'q' while user_input != 'q': try: # Capture Data y, _ = adc.burst(raw=1) # Parse The Data if user_input == 'burn': msk.burn(y[0], .1) elif user_input == 'normal': msk.normal(y[0], .1) # Uncomment to allow for user loop control # user_input = raw_input('Press enter to continue...') except KeyboardInterrupt: print("Quitting program") break boot.dearm()