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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8ef40920b53c7ba1b1ece45aa63d3d68ce53eb79
4
- data.tar.gz: 437180a2a3390d91642b01ff7a5d41733c69c646
3
+ metadata.gz: 79fdd2b7849500142c83049d528d96c85bc6450d
4
+ data.tar.gz: c3f1a3a2a356accbef89eeecbdfa5a0cf7cc6d6b
5
5
  SHA512:
6
- metadata.gz: 0abd18889dfcac9676ac1cadbad8e847a49d6b1c7fed417185c10ee5d7f4dbebb7a3b5c270dd3f8b31c6d09e86f07dd542c898e3f3d5ec1b80f85e6d078315ad
7
- data.tar.gz: 802a214f04f0bd563ebf393cdfdd2b37adb56d752a9c9d8a66f2e623846a54b456b9d95f5507ceccb8af4dbdc2ea5d3dee10f4302270126c3375a382c690e609
6
+ metadata.gz: 759e47a5212ecca64decf8626c2472229c954ba50e0ee4ed364f97fe0d1143417a52d70d78153faaf1d5b021cb994bf3860584f05fae52fa1e3eca545b1792f5
7
+ data.tar.gz: 0c0814ac3636e313641004b00d5bdeda731dc219bf71777b284b91bb2ac8b3ce2507b19bd6db525edb8d3c1b18c8f0641cdf790ba2a11d96c819f7d5986634d1
@@ -1,11 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 1.9.2
5
- - jruby-18mode
6
- - jruby-19mode
7
- - rbx-2.1.1
3
+ # - 1.9.3
4
+ # - 1.9.2
5
+ # - jruby-18mode
6
+ # - jruby-19mode
7
+ # - rbx-2.1.1
8
8
  - ruby-head
9
9
  - jruby-head
10
- - 1.8.7
11
- - ree
10
+ # - 1.8.7
11
+ # - ree
@@ -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
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'limitless_led'
4
+
5
+ # You can start the proxy server bin/server
6
+ bridge = LimitlessLed::Bridge.new
7
+
8
+ (0..255).each do |int|
9
+ bridge.send_packet "\x40#{ int.to_s(16).hex.chr }\x55"
10
+ sleep 0.025
11
+ end
@@ -1,6 +1,7 @@
1
- require "limitless_led/bridge"
1
+ #!/usr/bin/ruby
2
2
  require "limitless_led/version"
3
3
 
4
- module LimitlessLed
4
+ require "limitless_led/logger"
5
+ require "limitless_led/bridge"
6
+ require "limitless_led/server"
5
7
 
6
- end
@@ -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
- when 65
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 recieved: #{command.first}: #{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).to_rgb
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
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/ruby
2
+
1
3
  module LimitlessLed
2
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
3
5
  end
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "rake"
22
22
  spec.add_development_dependency "rspec"
23
23
 
24
+ spec.add_runtime_dependency "eventmachine"
24
25
  spec.add_runtime_dependency "color"
25
26
  spec.add_runtime_dependency "rainbow"
26
27
 
@@ -20,6 +20,7 @@ describe LimitlessLed do
20
20
 
21
21
  describe '#color' do
22
22
  it 'changes color' do
23
+ true.should be_true
23
24
  # subject.should_receive(:send_packet).with("\x40\xFF\x55")
24
25
  end
25
26
  end
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.2
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