Skip to content

Instantly share code, notes, and snippets.

@DanielHeath
Created August 20, 2015 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielHeath/c5d73e710ce21809d8cf to your computer and use it in GitHub Desktop.
Save DanielHeath/c5d73e710ce21809d8cf to your computer and use it in GitHub Desktop.
#!/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