Created
March 14, 2012 18:02
-
-
Save k0d/2038259 to your computer and use it in GitHub Desktop.
USB Lamp for Artem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import usb.core | |
from binascii import unhexlify as hex2lamp | |
def set_color(color): | |
print 'Attempting to set color to %s' % color | |
colors = dict(red='ff0000', green='00ff00', blue='0000ff') | |
if color not in colors: | |
print 'Color %s not found' % color | |
return False | |
else: | |
hex = colors[color] | |
print 'Color %s found, hex set to %s' % (color, hex) | |
set_hex(hex) | |
return True | |
def set_hex(hex): | |
print 'Set lamp to %s' % hex | |
return send_to_lamp(hex) | |
def send_to_lamp(hex): | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment