In [ ]:
%matplotlib inline
import box0
import time
import numpy as np
from pylab import *
from IPython import display
SAMPLE_BITSIZE = 12
SAMPLE_SPEED = 10000
SAMPLE_COUNT = 500
dev = box0.usb.open_supported()
ain0 = dev.ain(0)
ain0.snapshot_prepare()
while True:
xlabel('time (s)')
ylabel('voltage (V)')
title('About as simple as it gets, folks')
grid(True)
ain0.bitsize_speed_set(SAMPLE_BITSIZE, SAMPLE_SPEED)
s = np.empty(SAMPLE_COUNT, dtype=np.float64)
ain0.snapshot_start(s)
t = arange(0.0, float(SAMPLE_COUNT) / float(SAMPLE_SPEED), 1 / float(SAMPLE_SPEED))
clf()
grid(True)
#print("s is" + str(s))
#print("t is" + str(t))
#~ fill(t, s, 'r.-')
plot(t, s, 'r.-')
display.clear_output(wait=True)
display.display(plt.gcf())
time.sleep(0.001)
ain0.close()
dev.close()