Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- sys.path.insert(0, "/srv/hacksense/lib")
- import hacksense
- import logging
- import time
- units = range(0, 18)
- logging.basicConfig()
- logging.getLogger().setLevel(logging.INFO)
- conn = hacksense.AMQPTopic()
- def msg(data):
- body = "".join(map(lambda x: "%02x" % (x), data))
- # print body
- conn.publish("dali.command", {}, body)
- def simple_count():
- msg([0xfe, 0x01])
- time.sleep(1)
- for unit in units:
- msg([unit<<1, 254])
- time.sleep(0.5)
- msg([unit<<1, 1])
- time.sleep(1)
- msg([0xfe, 254])
- def chase(t=0.25):
- while True:
- for i in range(0, len(units)):
- a = units[i]
- b = units[i % len(units)-1]
- msg([a << 1, 254, b << 1, 1])
- time.sleep(t)
- def row_chase(t=0.5):
- rows = [
- [0, 1, 2, 9, 10, 11],
- [3, 4, 5, 12, 13, 14],
- [6, 7, 8, 15, 16, 17]
- ]
- while True:
- for row in range(0, len(rows)):
- #print "row", row, rows[row]
- output = []
- for unit in rows[row]:
- #print " unit", unit
- output.append(unit << 1)
- output.append(254)
- for unit in rows[(row-1) % len(rows)]:
- #print " prev", unit
- output.append(unit << 1)
- output.append(1)
- msg(output)
- time.sleep(t)
- def setlamp(unit, value):
- msg([unit << 1, value])
- try:
- #simple_count()
- row_chase()
- except KeyboardInterrupt:
- msg([0xfe, 254])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement