<
from
time import sleep
from pynq.overlays.base import BaseOverlay
base = BaseOverlay("base.bit")
Delay1 = 0.3
Delay2 = 0.1
color = 0
rgbled_position = [4,5]
//import PYNQ对开发板的支持文件
for led in base.leds:
led.on() //启动LED都亮起
while (base.buttons[3].read()==0): //按下BTN3时LED全灭
if (base.buttons[0].read()==1): //按下BTN0时LD4/LD5变化
color = (color+1) % 8
for led in rgbled_position:
base.rgbleds[led].write(color)
base.rgbleds[led].write(color)
sleep(Delay1)
elif (base.buttons[1].read()==1): //按下BTN1时LED的变化
for led in base.leds:
led.off()
sleep(Delay2)
for led in base.leds:
led.toggle()
sleep(Delay2)
elif (base.buttons[2].read()==1):
for led in reversed(base.leds):
led.off()
sleep(Delay2)
for led in reversed(base.leds):
led.toggle()
sleep(Delay2)
print('End of this demo ...')
for led in base.leds:
led.off()
for led in rgbled_position:
base.rgbleds[led].off()
>
表面看代码很简单,但是分析内部实现的话估计就复杂了,好了今天就到这,我去寻找他底层的代码,看这些是如何实现的。
`