From 60e748eabe2fafe16f43ad75fe619f87af368332 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 9 Nov 2016 14:53:45 +0800 Subject: [PATCH] drtio: better LED demo --- artiq/examples/drtio/device_db.pyon | 37 ++++++++++++++++++- .../drtio/repository/blink_forever.py | 15 ++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/artiq/examples/drtio/device_db.pyon b/artiq/examples/drtio/device_db.pyon index 5db8d5e20..7696aacce 100644 --- a/artiq/examples/drtio/device_db.pyon +++ b/artiq/examples/drtio/device_db.pyon @@ -32,7 +32,42 @@ "module": "artiq.coredevice.ttl", "class": "TTLOut", "arguments": {"channel": 1}, - "comment": "Hello World" + }, + "rled2": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 2}, + }, + "rled3": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 3}, + }, + "rled4": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 4}, + }, + "rled5": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 5}, + }, + "rled6": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 6}, + }, + "rled7": { + "type": "local", + "module": "artiq.coredevice.ttl", + "class": "TTLOut", + "arguments": {"channel": 7}, }, "rsmap": { diff --git a/artiq/examples/drtio/repository/blink_forever.py b/artiq/examples/drtio/repository/blink_forever.py index 0d6fa8ff8..589d389cb 100644 --- a/artiq/examples/drtio/repository/blink_forever.py +++ b/artiq/examples/drtio/repository/blink_forever.py @@ -4,11 +4,18 @@ from artiq.experiment import * class BlinkForever(EnvExperiment): def build(self): self.setattr_device("core") - self.setattr_device("rled0") + self.leds = [self.get_device("rled" + str(i)) for i in range(8)] @kernel def run(self): - self.core.reset() + #self.core.reset() + self.core.break_realtime() + while True: - self.rled0.pulse(100*ms) - delay(100*ms) + for led in self.leds: + led.pulse(250*ms) + t = now_mu() + for led in self.leds: + at_mu(t) + led.pulse(500*ms) + delay(250*ms)