diff --git a/gex/units/ADC.py b/gex/units/ADC.py index 660b0dd..980ad97 100644 --- a/gex/units/ADC.py +++ b/gex/units/ADC.py @@ -273,9 +273,9 @@ class ADC(gex.Unit): """ nedge = 0 - if edge == 'rising': + if edge == 'rising' or edge == 'up': nedge = 1 - elif edge == 'falling': + elif edge == 'falling' or edge == 'down': nedge = 2 elif edge == 'both': nedge = 3 diff --git a/test_adc2.py b/test_adc2.py index 685267b..32ccbf8 100644 --- a/test_adc2.py +++ b/test_adc2.py @@ -10,6 +10,8 @@ from scipy.io import wavfile with gex.Client(gex.TrxRawUSB()) as client: adc = gex.ADC(client, 'adc') - for i in range(1000): - print(adc.read_raw()) + print(adc.capture(100)) + + # for i in range(1000): + # print(adc.read_raw()) diff --git a/test_adc_trig.py b/test_adc_trig.py new file mode 100644 index 0000000..45a4793 --- /dev/null +++ b/test_adc_trig.py @@ -0,0 +1,32 @@ +#!/bin/env python3 +import time + +import gex +import numpy as np +from matplotlib import pyplot as plt + +from scipy.io import wavfile + +# def show(tr): +# data = tr.data +# data = np.add(data / 4096, -0.5) +# plt.plot(data, 'r-', lw=1) +# plt.show() + +with gex.Client(gex.TrxRawUSB()) as client: + adc = gex.ADC(client, 'adc') + + adc.on_trigger(lambda tr: print(tr.data)) + adc.setup_trigger(1, + level=3500, + count=500, + edge='rising', + pretrigger=100, + holdoff=100, + auto=True) + + adc.arm() + + while True: + print('tick') + time.sleep(1)