Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

accept color objs

  • Loading branch information...
commit f8662aaaa1a5831a91ef1a65bba6dc37f5d0ab70 1 parent adb4fae
@kballenegger authored
Showing with 12 additions and 0 deletions.
  1. +1 −0  Gemfile
  2. +2 −0  Gemfile.lock
  3. +9 −0 lib/hue.rb
View
1  Gemfile
@@ -3,6 +3,7 @@ source "https://rubygems.org"
gem 'curb'
gem 'nokogiri'
+gem 'color'
gem 'upnp', path: './upnp'
View
2  Gemfile.lock
@@ -16,6 +16,7 @@ GEM
gyoku (>= 0.4.0)
nokogiri (>= 1.4.0)
builder (3.1.4)
+ color (1.4.1)
cookiejar (0.3.0)
curb (0.8.3)
em-http-request (1.0.3)
@@ -52,6 +53,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ color
curb
nokogiri
upnp!
View
9 lib/hue.rb
@@ -4,6 +4,7 @@
require 'nokogiri'
require 'json'
require 'digest/sha1'
+require 'color'
class Hue
@@ -91,4 +92,12 @@ def on(light)
def cycle_thru_colors(sleep_between_steps = 1)
(0..65535).step(5000).each {|n| self.each_light {|id| self.write(id, :hue => n) }; sleep sleep_between_steps } while true
end
+
+ # color should be a color object from the color gem
+ # it must implement to_hsl, which must return something that implements .h,
+ # .l, and .s.
+ def set_color(light, color)
+ hsl = color.to_hsl
+ write(light, bri: (hsl.l * 255).to_i, sat: (hsl.s * 255).to_i, hue: (hsl.h * 182).to_i)
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.