from ctypes import *
from aecg100 import *
import sys
import time

device = AECG100(get_lib_path())
if device.connect(-1, 5000) == False:
    print('Error: device is not connected')
    device.free()
    sys.exit()

print('device is connected... ({} / {})'.format(
    device.get_serial_number(),
    device.get_ppg_serial_number()))
sys.stdout.flush()

time.sleep(5)

print('output PPG frequency scan (0.5Hz-3Hz, 10sec) ...')
sys.stdout.flush()

scan = FREQUENCY_SCAN_PPG()
scan.Amplitude = 1
scan.DC = 625
scan.SyncPulse = SyncPulse.SyncOn.value
scan.FrequencyStart = 0.5
scan.FrequencyFinish = 3
scan.Duration = 10

device.output_ppg_frequency_scan(PPGChannel.Channel1.value, pointer(scan), OutputSignalCallback(0))

time.sleep(11)

device.stop_output()
device.free()
