limitless-led 0.0.3 → 0.0.4

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: 79fdd2b7849500142c83049d528d96c85bc6450d
4
- data.tar.gz: c3f1a3a2a356accbef89eeecbdfa5a0cf7cc6d6b
3
+ metadata.gz: ffa1ba16ac8fc123b0f8f433de1f54b3c266ec2f
4
+ data.tar.gz: d0ce26cf2bb3e727257a0136127b4ce9ecfaf428
5
5
  SHA512:
6
- metadata.gz: 759e47a5212ecca64decf8626c2472229c954ba50e0ee4ed364f97fe0d1143417a52d70d78153faaf1d5b021cb994bf3860584f05fae52fa1e3eca545b1792f5
7
- data.tar.gz: 0c0814ac3636e313641004b00d5bdeda731dc219bf71777b284b91bb2ac8b3ce2507b19bd6db525edb8d3c1b18c8f0641cdf790ba2a11d96c819f7d5986634d1
6
+ metadata.gz: e3d8809d24f2921be6ee05b0edeae2091f7024796e1622c6150372bfaefd2eb734fba64f2b002047ee32807ad3e776496a921d57e582fc5e1ed7bf3bba282ec4
7
+ data.tar.gz: e061ad0d1a1d47d8530066562434227ed0f8230f268021d5e8b8d56d9cef4dd4429a610872dfcb0065ef9d7188ed05afbe1d5f5dbb63b23513f31658843b9a32
data/lib/limitless_led.rb CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/ruby
2
2
  require "limitless_led/version"
3
3
 
4
4
  require "limitless_led/logger"
@@ -22,19 +22,24 @@ module LimitlessLed
22
22
  end
23
23
  end
24
24
 
25
+ # this sends the actual bytes to the real bridge/led over the UDP socket method
25
26
  def send_packet(packet)
26
27
  socket.send packet, 0
27
28
  end
28
29
 
30
+ # This method dispatches the raw command in bytes to the proper method used
31
+ # to run commands for the led the first byte in the command code tells the
32
+ # real led which command to expect, most commands are 3-4 bytes long total
33
+ # and always end with 0x55
29
34
  def run(input)
30
35
  command = input.bytes
31
36
 
32
37
  case command.first
33
- when 64
34
- color command[1]
35
- when 65..77
38
+ when 64
39
+ color command[1]
40
+ when 65..77
36
41
  raise 'command not implemented'
37
- else
42
+ else
38
43
  log "invalid command received: #{command.first}: #{command}"
39
44
  end
40
45
 
@@ -42,10 +47,15 @@ module LimitlessLed
42
47
 
43
48
  private
44
49
 
45
- #
50
+ # this receives and integer as the color value from 0-255, this value
51
+ # maps directly to the dial on the limitless-led controller and app where
52
+ # the color at 12 o'clock is 0, the colors are mapped clockwise around
53
+ # the dial with 255 being almost the same color as 0, this is because the
54
+ # color space we are using is HSL.
46
55
  def color(color)
47
56
 
48
- # Turn second byte
57
+ # Turn second byte int a value out of 360, this is because HSL color maps
58
+ # the hue on a radial scale so the first and last values are the same color
49
59
  color = color.to_f / 255.0 * 360.0
50
60
 
51
61
  # Rotate 90 degrees and flip to match dial ui on device
@@ -54,6 +64,8 @@ module LimitlessLed
54
64
  # Return the color
55
65
  color = Color::HSL.new( hue, 90, 50)
56
66
 
67
+ # log the color that the device would be set to
68
+ # TODO: this should only happen with the bridge is initialized with the verbose parameter as true
57
69
  log_color color
58
70
 
59
71
  end
@@ -18,7 +18,7 @@ module LimitlessLed
18
18
  blue = color.b * 255
19
19
 
20
20
  # Log the color and the hex of the color
21
- log "████████ ".color(red, green, blue) + color.html
21
+ log '████████ '.color(red, green, blue) + color.html
22
22
 
23
23
  end
24
24
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  module LimitlessLed
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
@@ -21,8 +21,8 @@ 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"
25
- spec.add_runtime_dependency "color"
26
- spec.add_runtime_dependency "rainbow"
24
+ spec.add_dependency "eventmachine"
25
+ spec.add_dependency "color"
26
+ spec.add_dependency "rainbow"
27
27
 
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: limitless-led
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Silvashy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-28 00:00:00.000000000 Z
11
+ date: 2013-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake