A Ruby Gem for communicating with an L8 SmartLight over USB.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install l8
To connect to your L8 Smartlight, determine the serial port it's on and then create a new L8::Smartlight:
require 'l8' l8 = L8::Smartlight.new('/dev/tty.usbmodem1421')
set_led to set one of the LEDs to a color. The arguments are:
- x coordinate of the LED (0..7)
- y coordinate of the LED (0..7)
- red color value (0..15)
- green color value (0..15)
- blue color values (0..15)
For example, to set the 5th LED in the 3rd row to orange:
l8.set_led(2, 4, 15, 7, 0)
Clear the LEDs
Change the Super (Back) LED
set_superled method and pass 3 color values (0..15):
l8.set_superled(0, 0, 15)
Set L8 Brightness
You can control the overall brightness of the L8 using the
set_brightness method with one of the following values:
Disable/Enable Status LEDs
The status LEDs on the top of the L8 can leak light into the LED matrix or just detract from the main LEDs in general, so you can turn them off with the
disable_status_leds method. There is a
enable_status_leds method to turn them back on.
Force L8 Orientation
If you lay the L8 flat or move it around a lot it may lose your preferred orienation in reference to the status lights at the top of the L8.
You can force the orientation using the
set_orientation method and passing one of the following:
To display an alpha-numeric character on the L8, use the
display_character method and send a single Ascii character.
You can turn the L8s off using the
Controlling Groups of L8s
You can control a group of L8s as either a Stack or Row of them. This will give you a
set_led method that treats them as one big matrix of LEDs.
stack = L8::Stack.new('/dev/tty.usbmodem1421', '/dev/tty.usbmodem1422') stack.set_led(7, 15, 0, 15, 0)
The following methods are also available on groups of L8s and affect all L8s in the group.
Identify L8s in a Group
When using a group of L8s you might get your USB ports/wires crossed and need to figure out the correct order to put the L8s in. The
identify method will put a number on each L8 letting you know how to arrange them - left to right or top to bottom, start at 1.
- Fork it ( https://github.com/spilth/l8/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request