litex/examples/de0_nano/client/test_miio.py

50 lines
1.1 KiB
Python
Raw Normal View History

2013-03-18 18:57:51 -04:00
from miscope import miio
from miscope.bridges.uart2csr.tools.uart2Csr import *
#==============================================================================
# P A R A M E T E R S
#==============================================================================
2013-03-18 18:57:51 -04:00
csr = Uart2Csr(3,115200)
# Csr Addr
2013-03-21 07:23:44 -04:00
MIIO_ADDR = 0x00
2013-02-26 17:14:09 -05:00
# Miscope Configuration
2013-03-18 18:57:51 -04:00
miio = miio.MiIo(MIIO_ADDR, 8, "IO", csr)
def led_anim0():
for i in range(10):
2013-03-22 07:35:12 -04:00
miio.set(0xA5)
time.sleep(0.1)
2013-03-22 07:35:12 -04:00
miio.set(0x5A)
time.sleep(0.1)
def led_anim1():
for j in range(4):
2013-03-18 18:57:51 -04:00
#Led <<
ledData = 1
for i in range(8):
2013-03-22 07:35:12 -04:00
miio.set(ledData)
time.sleep(i*i*0.0020)
ledData = (ledData<<1)
#Led >>
ledData = 128
for i in range(8):
2013-03-22 07:35:12 -04:00
miio.set(ledData)
time.sleep(i*i*0.0020)
ledData = (ledData>>1)
#==============================================================================
# T E S T M I G I O
#==============================================================================
2013-03-22 07:35:12 -04:00
print("- Led Animation...")
led_anim0()
time.sleep(1)
led_anim1()
time.sleep(1)
print("- Read Switch: ",end=' ')
2013-03-22 07:35:12 -04:00
print("%02X" %miio.get())