def test_switch(): data_test = [120,120,120,120, 120,120,120,120,0,0,131,260] dcapi.init() dcapi.ppm_update(data_test) dcapi.enable_control(1) try: while dcapi.read_button() == 0: time.sleep(1) if dcapi.read_ch1() == 1 : print 'CH1 on' else: print 'CH1 off' if dcapi.read_ch2() == 1: print 'CH2 on' else: print 'CH2 off' print "exiting.." finally: dcapi.enable_control(0) print "script termine, controle rendu" dcapi.free_pi()
def test_switch(): data_test = [120, 120, 120, 120, 120, 120, 120, 120, 0, 0, 131, 260] dcapi.init() dcapi.ppm_update(data_test) dcapi.enable_control(1) try: while dcapi.read_button() == 0: time.sleep(1) if dcapi.read_ch1() == 1: print 'CH1 on' else: print 'CH1 off' if dcapi.read_ch2() == 1: print 'CH2 on' else: print 'CH2 off' print "exiting.." finally: dcapi.enable_control(0) print "script termine, controle rendu" dcapi.free_pi()
import time import dcapi dcapi.init() try: dcapi.enable_control(1) print 'ch1:' + str(dcapi.read_ch1()) print 'enable:' + str(dcapi.ENABLE_STATE) print str(dcapi.calibration_acc()) time.sleep(3) print str(dcapi.arm()) time.sleep(3) print str(dcapi.disarm()) time.sleep(3) while dcapi.read_button() == 0: time.sleep(1) print str(dcapi.write_channel(11, 200, 1)) finally: # quand on quitte, normalement ou pas dcapi.enable_control(0) print "script termine, controle rendu" dcapi.free_pi()