limitless-led 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -4
- data/examples/demo.rb +12 -0
- data/examples/skycolor.rb +19 -0
- data/lib/limitless_led.rb +2 -2
- data/lib/limitless_led/bridge.rb +28 -1
- data/lib/limitless_led/logger.rb +28 -1
- data/lib/limitless_led/server.rb +11 -1
- data/lib/limitless_led/version.rb +1 -1
- data/spec/bridge_spec.rb +0 -8
- data/spec/logger_spec.rb +1 -1
- data/spec/server_spec.rb +8 -3
- data/spec/spec_helper.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2493a478e96a65a5874432d0c460c7c2fe93d701
|
4
|
+
data.tar.gz: 168bc9cec555559dbd1865da74dbc7bef7e894f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c1804293d1663fd6c9d9440178dd19b44e0ad0cdcb7b6e8cbe185a5b667ca4b774b5391cfa404b8d6b3b06f959cd7632caf47fdd6bd8468f66cf722515bc8d0
|
7
|
+
data.tar.gz: 07ce2abed795a7564a6f3bf066c30b8ac240b8359f791c9d5938f3474b009fed94fbd92ae55f5d8cb0a62dcc259746368db93c7621e15e471478b0de62d45807
|
data/README.md
CHANGED
@@ -2,11 +2,15 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/jpsilvashy/limitless-led.png?branch=master)](https://travis-ci.org/jpsilvashy/limitless-led)
|
4
4
|
|
5
|
+
A Ruby gem for controlling the [LimitlessLED v3.0 RGBW color-changing light bulbs](http://www.limitlessled.com/), based on the official [LimitlessLED API documentation](http://www.limitlessled.com/dev/).
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
9
|
-
|
11
|
+
``` ruby
|
12
|
+
gem 'limitless-led'
|
13
|
+
```
|
10
14
|
|
11
15
|
And then execute:
|
12
16
|
|
@@ -31,19 +35,45 @@ bridge.color "#ff0000"
|
|
31
35
|
# You can send a triple
|
32
36
|
bridge.color "#f00"
|
33
37
|
|
38
|
+
# Send data straight to the bridge:
|
39
|
+
bridge.send_packet "\x40\x00\x55"
|
40
|
+
|
41
|
+
# Send a lot of data to the bridge very quickly:
|
42
|
+
10.times do
|
43
|
+
(0..255).each do |int|
|
44
|
+
bridge.send_packet "\x40#{ int.chr }\x55"
|
45
|
+
sleep 0.005
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
34
50
|
# Again if you don't have the LimitlessLED, you can create an instance
|
35
|
-
# of the development server
|
36
|
-
# in bin/server
|
51
|
+
# of the development server
|
37
52
|
server = LimitlessLed::Server.new(host: 'localhost', port: 8899)
|
38
53
|
|
39
54
|
# Then you can see what the server does when it receives messages
|
40
55
|
server.receive_data("\x40\x00\xff")
|
41
56
|
```
|
42
57
|
|
43
|
-
|
58
|
+
_View more demos in the [/examples](https://github.com/jpsilvashy/limitless-led/tree/master/examples) directory_
|
59
|
+
|
60
|
+
If you are using the development server you should see this output:
|
44
61
|
|
62
|
+
![Output](https://www.evernote.com/shard/s5/sh/df5047a2-faa4-4985-98a7-63d86d8a131d/e45fb64438bc946c37c13d88c2dd412d/deep/0/output.jpg)
|
63
|
+
|
64
|
+
**As a note,** since we are transforming the colors from RGB to HSL and then back for representing the color in the console (which additionally is more limiting than the true color space offered by the LED) some of the hex values may not exactly match, especially near the dark limit. Since we are controlling the the brightness of the LED separately, and do not have access to the saturation some colors maybe be harder to reproduce than others, especially dark colors.
|
65
|
+
|
66
|
+
## Contributors
|
67
|
+
|
68
|
+
- [Nate Clark](https://github.com/heythisisnate)
|
69
|
+
- [Curtis Gagliardi](https://github.com/cgag)
|
70
|
+
|
71
|
+
*_This originally was a fork of [hired/limitless-led](https://github.com/hired/limitless-led) but quickly grew larger in scope so I decided to move it to a new repo._
|
72
|
+
|
73
|
+
## Contributing
|
45
74
|
1. Fork it ( http://github.com/jpsilvashy/limitless-led/fork )
|
46
75
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
76
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
48
77
|
4. Push to the branch (`git push origin my-new-feature`)
|
49
78
|
5. Create new Pull Request
|
79
|
+
|
data/examples/demo.rb
CHANGED
@@ -12,6 +12,18 @@ bridge.color "#ff0000"
|
|
12
12
|
# You can send a triple
|
13
13
|
bridge.color "#f00"
|
14
14
|
|
15
|
+
# Send data straight to the bridge:
|
16
|
+
bridge.send_packet "\x40\x00\x55"
|
17
|
+
|
18
|
+
# Send a lot of data to the bridge very quickly:
|
19
|
+
10.times do
|
20
|
+
(0..255).each do |int|
|
21
|
+
bridge.send_packet "\x40#{ int.chr }\x55"
|
22
|
+
sleep 0.005
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
15
27
|
# Again if you don't have the LimitlessLED, you can create an instance
|
16
28
|
# of the development server
|
17
29
|
server = LimitlessLed::Server.new(host: 'localhost', port: 8899)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# This example takes a photo and approximates the most dominant color in the image and changes
|
4
|
+
# the LED to match. Our example is using a remote image from a webcam, but you can put any
|
5
|
+
# image source uri.
|
6
|
+
|
7
|
+
# Install miro gem first
|
8
|
+
# https://github.com/jonbuda/miro
|
9
|
+
require 'miro'
|
10
|
+
require 'limitless_led'
|
11
|
+
|
12
|
+
# Source of image
|
13
|
+
colors = Miro::DominantColors.new('http://cdn.abclocal.go.com/three/kgo/webcam/tahoecam.jpg')
|
14
|
+
|
15
|
+
# Connect to bridge
|
16
|
+
bridge = LimitlessLed::Bridge.new(host: 'localhost', port: 8899)
|
17
|
+
|
18
|
+
# Send send most dominant color from image to the LED
|
19
|
+
bridge.color colors.to_hex[0]
|
data/lib/limitless_led.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/ruby
|
2
2
|
require "limitless_led/version"
|
3
3
|
|
4
4
|
require "limitless_led/logger"
|
@@ -8,4 +8,4 @@ require "limitless_led/server"
|
|
8
8
|
module LimitlessLed
|
9
9
|
class CommandNotImplemented < StandardError; end
|
10
10
|
class UnknownCommand < StandardError; end
|
11
|
-
end
|
11
|
+
end
|
data/lib/limitless_led/bridge.rb
CHANGED
@@ -22,16 +22,43 @@ module LimitlessLed
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
#
|
25
|
+
# Sends the actual bytes to the real bridge/led over the UDP socket method.
|
26
|
+
#
|
27
|
+
# Usage:
|
28
|
+
#
|
29
|
+
# # Default
|
30
|
+
# send_packet "\x40\xff\x55"
|
31
|
+
#
|
32
|
+
# Options:
|
33
|
+
#
|
34
|
+
# +packet+:: the bytes to send to the device
|
35
|
+
#
|
26
36
|
def send_packet(packet)
|
27
37
|
socket.send packet, 0
|
28
38
|
end
|
29
39
|
|
30
40
|
# This sets the color of the LED with a hex value for the color the packets
|
31
41
|
# are sent to the socket for the command
|
42
|
+
#
|
43
|
+
# Usage:
|
44
|
+
#
|
45
|
+
# # Default
|
46
|
+
# color '#ff0000'
|
47
|
+
#
|
48
|
+
# # Triplet
|
49
|
+
# color '#f00'
|
50
|
+
#
|
51
|
+
# # Optional "#"
|
52
|
+
# color 'ff0000'
|
53
|
+
#
|
54
|
+
# Options:
|
55
|
+
#
|
56
|
+
# +color+:: The color in the hex format rrggbb or rgb
|
57
|
+
#
|
32
58
|
def color(color)
|
33
59
|
|
34
60
|
# receive color as string like #ff0000 or a triplet
|
61
|
+
# transform to HSL color
|
35
62
|
color = Color::RGB.from_html(color).to_hsl
|
36
63
|
|
37
64
|
# Transform color into value out of 255
|
data/lib/limitless_led/logger.rb
CHANGED
@@ -3,15 +3,42 @@
|
|
3
3
|
module LimitlessLed
|
4
4
|
module Logger
|
5
5
|
|
6
|
+
# Logs timestamp and message
|
7
|
+
#
|
8
|
+
# Usage:
|
9
|
+
#
|
10
|
+
# # Default
|
11
|
+
# log "something happend"
|
12
|
+
#
|
13
|
+
# Options:
|
14
|
+
#
|
15
|
+
# +message+:: any string for the message you want to log
|
16
|
+
#
|
6
17
|
def log(message)
|
7
18
|
puts "#{DateTime.now.to_s} : #{message}"
|
8
19
|
end
|
9
20
|
|
10
|
-
#
|
21
|
+
# This receives and integer as the color value from 0-255, this value
|
11
22
|
# maps directly to the dial on the limitless-led controller and app where
|
12
23
|
# the color at 12 o'clock is 0, the colors are mapped clockwise around
|
13
24
|
# the dial with 255 being almost the same color as 0, this is because the
|
14
25
|
# color space we are using is HSL.
|
26
|
+
#
|
27
|
+
# Usage:
|
28
|
+
#
|
29
|
+
# # Default
|
30
|
+
# log_color 0
|
31
|
+
#
|
32
|
+
# # Different color
|
33
|
+
# log_color 120
|
34
|
+
#
|
35
|
+
# # HSL hue is radial so 255 is the same as 0
|
36
|
+
# log_color 255
|
37
|
+
#
|
38
|
+
# Options:
|
39
|
+
#
|
40
|
+
# +color+:: color 0-255
|
41
|
+
#
|
15
42
|
def log_color(color)
|
16
43
|
|
17
44
|
# Turn second byte int a value out of 360, this is because HSL color maps
|
data/lib/limitless_led/server.rb
CHANGED
@@ -16,8 +16,18 @@ module LimitlessLed
|
|
16
16
|
|
17
17
|
# This method dispatches the raw command in bytes to the proper method used
|
18
18
|
# to run commands for the led the first byte in the command code tells the
|
19
|
-
# real led which command to expect, most commands are 3
|
19
|
+
# real led which command to expect, most commands are 3 bytes long total
|
20
20
|
# and always end with 0x55
|
21
|
+
#
|
22
|
+
# Usage:
|
23
|
+
#
|
24
|
+
# # Default
|
25
|
+
# receive_data "\x40\xff\x55"
|
26
|
+
#
|
27
|
+
# Options:
|
28
|
+
#
|
29
|
+
# +input+:: bytes used to run the commands
|
30
|
+
#
|
21
31
|
def receive_data(input)
|
22
32
|
command = input.bytes
|
23
33
|
|
data/spec/bridge_spec.rb
CHANGED
@@ -70,14 +70,6 @@ describe LimitlessLed::Bridge do
|
|
70
70
|
subject.send(:send_packet, "\x40\xFF\x55")
|
71
71
|
|
72
72
|
end
|
73
|
-
|
74
|
-
it 'should raise an exception when improperly formed commands are sent' do
|
75
|
-
# subject.send(:send_packet, "\x40\xFF\x55")
|
76
|
-
# subject.should_receive(:new) { fake_socket }
|
77
|
-
should raise_error(HipChat::UnknownResponseCode)
|
78
|
-
end
|
79
73
|
end
|
80
74
|
|
81
75
|
end
|
82
|
-
|
83
|
-
|
data/spec/logger_spec.rb
CHANGED
data/spec/server_spec.rb
CHANGED
@@ -33,9 +33,14 @@ require 'spec_helper'
|
|
33
33
|
|
34
34
|
describe LimitlessLed::Server do
|
35
35
|
|
36
|
-
let(:params) { {} }
|
36
|
+
let(:params) { { host: 'localhost', port: 6666 } }
|
37
37
|
subject { LimitlessLed::Server.new(params) }
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
describe '#receive_data' do
|
40
|
+
it 'should raise an exception when improperly formed commands are sent' do
|
41
|
+
#subject.send(:receive_data, "\xFF\x55")
|
42
|
+
#subject.should raise_error(LimitlessLed::CommandNotImplemented)
|
43
|
+
end
|
44
|
+
end
|
41
45
|
|
46
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: limitless-led
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Silvashy
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- Rakefile
|
98
98
|
- bin/server
|
99
99
|
- examples/demo.rb
|
100
|
+
- examples/skycolor.rb
|
100
101
|
- lib/limitless_led.rb
|
101
102
|
- lib/limitless_led/bridge.rb
|
102
103
|
- lib/limitless_led/logger.rb
|