Created
August 20, 2015 11:34
-
-
Save DanielHeath/c5d73e710ce21809d8cf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'digiusb' | |
usage = "Usage: digicolor light_number #hex_color" | |
raise usage unless ARGV[1] | |
idx = ARGV[0].to_i | |
hex = ARGV[1] | |
raise usage if hex[0] != "#" | |
rgb = hex[1..-1].scan(/../).map {|str| str.hex} | |
light = DigiUSB.sparks[idx] | |
raise "There are only #{DigiUSB.sparks.length} lights" unless light | |
light.putc(115) # start character | |
light.putc(rgb[0]) # red value | |
light.putc(rgb[1]) # green value | |
light.putc(rgb[2]) # blue value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment