Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Dec 19th, 2011  |  syntax: None  |  size: 1.21 KB  |  hits: 48  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. REQUIREMENTS = File.dirname(__FILE__)
  2.  
  3. require REQUIREMENTS + "/../../libcombustd/libcombustd"
  4.  
  5. puts "\nboblight - a small tool to listen to the output of boblight popen to control a set of Philips Ambx lights.\n"
  6. puts "See README and docs/ for faq, usage and support.\n\n"
  7. puts "Looking for support ?\nChat: irc.oceanius.com #dev\nMail: combustd@sexybiggetje.nl\n\n"
  8. puts "Format: ruby boblight.rb r1 g1 b1 r2 g2 b2 r3 g3 b3 r4 g4 b4 r5 g5 b5\n\n"
  9.  
  10. if Ambx.connect
  11.   if Ambx.open
  12.       while true
  13.                 r1, g1, b1, r2, g2, b2, r3, g3, b3, r4, g4, b4, r5, g5, b5 = gets.split(" ", 15)
  14.         Ambx.write([0xA1, Lights::LEFT, 0x03, Float(r1) * 255, Float(g1) * 255, Float(b1) * 255])
  15.         Ambx.write([0xA1, Lights::RIGHT, 0x03, Float(r2) * 255, Float(g2) * 255, Float(b2) * 255])
  16.         Ambx.write([0xA1, Lights::WWLEFT, 0x03, Float(r3) * 255, Float(g3) * 255, Float(b3) * 255])
  17.         Ambx.write([0xA1, Lights::WWRIGHT, 0x03, Float(r4) * 255, Float(g4) * 255, Float(b4) * 255])
  18.         Ambx.write([0xA1, Lights::WWCENTER, 0x03, Float(r5) * 255, Float(g5) * 255, Float(b5) * 255])
  19.       end
  20.       Ambx.close
  21.   else
  22.     puts "Unable to open the discovered device"
  23.   end
  24. else
  25.   puts "Unable to find a ambx device"
  26. end