limitless-led 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +7 -7
- data/bin/server +25 -0
- data/examples/demo.rb +11 -0
- data/lib/limitless_led.rb +4 -3
- data/lib/limitless_led/bridge.rb +11 -43
- data/lib/limitless_led/logger.rb +26 -0
- data/lib/limitless_led/server.rb +22 -0
- data/lib/limitless_led/version.rb +3 -1
- data/limitless_led.gemspec +1 -0
- data/spec/limitless_led_spec.rb +1 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79fdd2b7849500142c83049d528d96c85bc6450d
|
4
|
+
data.tar.gz: c3f1a3a2a356accbef89eeecbdfa5a0cf7cc6d6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 759e47a5212ecca64decf8626c2472229c954ba50e0ee4ed364f97fe0d1143417a52d70d78153faaf1d5b021cb994bf3860584f05fae52fa1e3eca545b1792f5
|
7
|
+
data.tar.gz: 0c0814ac3636e313641004b00d5bdeda731dc219bf71777b284b91bb2ac8b3ce2507b19bd6db525edb8d3c1b18c8f0641cdf790ba2a11d96c819f7d5986634d1
|
data/.travis.yml
CHANGED
data/bin/server
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'eventmachine'
|
5
|
+
require 'limitless_led'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
|
9
|
+
optparse = OptionParser.new do|opts|
|
10
|
+
opts.banner = "Usage: server [options]"
|
11
|
+
|
12
|
+
options[:port] = 8899
|
13
|
+
|
14
|
+
opts.on( '-p', '--port [PORT]', "Optional port" ) do|f|
|
15
|
+
options[:port] = f
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
optparse.parse!
|
20
|
+
|
21
|
+
puts ">> Starting Limitless LED Server running on port: #{options[:port]}"
|
22
|
+
|
23
|
+
EM.run do
|
24
|
+
EM.open_datagram_socket('0.0.0.0', options[:port], LimitlessLed::Server)
|
25
|
+
end
|
data/examples/demo.rb
ADDED
data/lib/limitless_led.rb
CHANGED
data/lib/limitless_led/bridge.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
1
3
|
require 'socket'
|
2
4
|
|
3
5
|
module LimitlessLed
|
4
6
|
class Bridge
|
5
|
-
|
7
|
+
include LimitlessLed::Logger
|
6
8
|
attr_accessor :host, :port
|
7
9
|
|
8
10
|
def initialize(host: 'localhost', port: 8899)
|
@@ -30,53 +32,17 @@ module LimitlessLed
|
|
30
32
|
case command.first
|
31
33
|
when 64
|
32
34
|
color command[1]
|
33
|
-
|
34
|
-
|
35
|
-
raise "Not implemented"
|
36
|
-
|
37
|
-
when 66
|
38
|
-
raise "Not implemented"
|
39
|
-
|
40
|
-
when 67
|
41
|
-
raise "Not implemented"
|
42
|
-
|
43
|
-
when 68
|
44
|
-
raise "Not implemented"
|
45
|
-
|
46
|
-
when 69
|
47
|
-
raise "Not implemented"
|
48
|
-
|
49
|
-
when 70
|
50
|
-
raise "Not implemented"
|
51
|
-
|
52
|
-
when 71
|
53
|
-
raise "Not implemented"
|
54
|
-
|
55
|
-
when 72
|
56
|
-
raise "Not implemented"
|
57
|
-
|
58
|
-
when 73
|
59
|
-
raise "Not implemented"
|
60
|
-
|
61
|
-
when 74
|
62
|
-
raise "Not implemented"
|
63
|
-
|
64
|
-
when 75
|
65
|
-
raise "Not implemented"
|
66
|
-
|
67
|
-
when 76
|
68
|
-
raise "Not implemented"
|
69
|
-
|
70
|
-
when 77
|
71
|
-
raise "Not implemented"
|
72
|
-
|
35
|
+
when 65..77
|
36
|
+
raise 'command not implemented'
|
73
37
|
else
|
74
|
-
log "invalid command
|
38
|
+
log "invalid command received: #{command.first}: #{command}"
|
75
39
|
end
|
40
|
+
|
76
41
|
end
|
77
42
|
|
78
43
|
private
|
79
44
|
|
45
|
+
#
|
80
46
|
def color(color)
|
81
47
|
|
82
48
|
# Turn second byte
|
@@ -86,7 +52,9 @@ module LimitlessLed
|
|
86
52
|
hue = color - 90
|
87
53
|
|
88
54
|
# Return the color
|
89
|
-
Color::HSL.new( hue, 90, 50)
|
55
|
+
color = Color::HSL.new( hue, 90, 50)
|
56
|
+
|
57
|
+
log_color color
|
90
58
|
|
91
59
|
end
|
92
60
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
module LimitlessLed
|
4
|
+
module Logger
|
5
|
+
|
6
|
+
def log(message)
|
7
|
+
puts "#{DateTime.now.to_s} : #{message}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def log_color(color)
|
11
|
+
|
12
|
+
#
|
13
|
+
color = color.to_rgb
|
14
|
+
|
15
|
+
# Get each channel and prepare for loggers output
|
16
|
+
red = color.r * 255
|
17
|
+
green = color.g * 255
|
18
|
+
blue = color.b * 255
|
19
|
+
|
20
|
+
# Log the color and the hex of the color
|
21
|
+
log "████████ ".color(red, green, blue) + color.html
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'eventmachine'
|
4
|
+
|
5
|
+
require 'date'
|
6
|
+
require 'rainbow'
|
7
|
+
require 'color'
|
8
|
+
|
9
|
+
module LimitlessLed
|
10
|
+
class Server < EM::Connection
|
11
|
+
include LimitlessLed::Logger
|
12
|
+
|
13
|
+
def initialize(host: 'localhost', port: 8899)
|
14
|
+
@bridge = LimitlessLed::Bridge.new(host: host, port: port)
|
15
|
+
end
|
16
|
+
|
17
|
+
def receive_data(command)
|
18
|
+
@bridge.run command
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/limitless_led.gemspec
CHANGED
data/spec/limitless_led_spec.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.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joseph Silvashy
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: eventmachine
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: color
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,7 +83,8 @@ dependencies:
|
|
69
83
|
description: ''
|
70
84
|
email:
|
71
85
|
- jpsilvashy@gmail.com
|
72
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- server
|
73
88
|
extensions: []
|
74
89
|
extra_rdoc_files: []
|
75
90
|
files:
|
@@ -80,8 +95,12 @@ files:
|
|
80
95
|
- LICENSE.txt
|
81
96
|
- README.md
|
82
97
|
- Rakefile
|
98
|
+
- bin/server
|
99
|
+
- examples/demo.rb
|
83
100
|
- lib/limitless_led.rb
|
84
101
|
- lib/limitless_led/bridge.rb
|
102
|
+
- lib/limitless_led/logger.rb
|
103
|
+
- lib/limitless_led/server.rb
|
85
104
|
- lib/limitless_led/version.rb
|
86
105
|
- limitless_led.gemspec
|
87
106
|
- spec/limitless_led_spec.rb
|