from math import *

from recent_avglib import *  

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'

def square_wave(t):
  period = 40
  if (t % period) > (period/2) :
    return 1
  else:
    return -1

from oscopegraphlibyy import *

list_for_averaging=setup_data_list(10,0.0)
for i in range(0,50):
  a=square_wave(i)
  #a=sin(i/20.0)
  list_for_averaging=update_list(list_for_averaging,a)
  averaged_a = sum(list_for_averaging[0])/float(len(list_for_averaging[0]))
  print a, averaged_a
  y_values_for_scope=[a,averaged_a]
  #def oscope(user_y,smallest_y=0.0,biggest_y=2.5,sample_period=0.1,samples_per_sweep=20,record_for_xgraph=False):
  oscope(y_values_for_scope,smallest_y=-1.1,biggest_y=1.1,sample_period=0.1,samples_per_sweep=100,record_for_xgraph=True)
waiting=raw_input("Press Enter to finish...")  
