######################################## oscopeLJU3.py ##################################
# Example oscilloscope program that reads FIO0

import sys
mypath=sys.path[0]
if mypath.find('my_python') == -1:       #If true, then "my_python" could not be found
  print "Sorry.  You need to be in my_python for Halverson's program to work."
  print "(That''s because I am assuming that the oscopegraphlib.py and ezu3.py libraries are there.)"
  exit()
sys.path[0]=mypath[0:mypath.find('my_python')]+'my_python'

from oscopegraphlib import *
import math
import u3
from ezu3 import *
from time import sleep

d = u3.U3() # Opens the first LabJackU3 found on the USB
u3setup(d,['ain','ain','din','din','ain','ain','ain','ain'])

print
print "Press buttons 2 and 3 to quit."
my_sample_period=0.01
while True:
  y=ain6(d)       #Read analog input
  print "%5.3f" % y
  oscope(y,smallest_y=0.0,biggest_y=2.5,sample_period=my_sample_period)
  if din2(d) and din3(d):
    break;
  else:
    sleep(my_sample_period)
