limitless-led 0.0.1 → 0.0.2

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: cdab9af23e7585564faec3fddf0e229363e53fd7
4
- data.tar.gz: d30aac1420bed2dd40502878ad191f73c5f93c2f
3
+ metadata.gz: 8ef40920b53c7ba1b1ece45aa63d3d68ce53eb79
4
+ data.tar.gz: 437180a2a3390d91642b01ff7a5d41733c69c646
5
5
  SHA512:
6
- metadata.gz: d7ec6866fbb63856baf8a5e8786a2e343b0a68aa1fba2dd2d470216caccfeefe9c8cabf7f61cd9ba3e4cf80fa2c5086c2353678fb358ce7dd0836e32e31ccb5f
7
- data.tar.gz: a1826a6c0e979d51faa2a90d84fc22773709243955e19fed1d17326c8210e1e0a8d054fc3565da6da6705f8b02f6db6f9de268d505e90a6aa59b8663e510ac97
6
+ metadata.gz: 0abd18889dfcac9676ac1cadbad8e847a49d6b1c7fed417185c10ee5d7f4dbebb7a3b5c270dd3f8b31c6d09e86f07dd542c898e3f3d5ec1b80f85e6d078315ad
7
+ data.tar.gz: 802a214f04f0bd563ebf393cdfdd2b37adb56d752a9c9d8a66f2e623846a54b456b9d95f5507ceccb8af4dbdc2ea5d3dee10f4302270126c3375a382c690e609
data/.gitignore CHANGED
@@ -1,19 +1,37 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
1
20
  *.gem
2
21
  *.rbc
3
22
  .bundle
4
23
  .config
5
24
  .yardoc
6
- Gemfile.lock
25
+ /Gemfile.lock
7
26
  InstalledFiles
8
27
  _yardoc
9
- coverage
10
28
  doc/
11
29
  lib/bundler/man
12
- pkg
13
- rdoc
14
30
  spec/reports
15
31
  test/tmp
16
32
  test/version_tmp
17
33
  tmp
18
34
 
35
+ ## PROJECT::SPECIFIC
36
+
19
37
  .idea
@@ -1,5 +1,94 @@
1
+ require 'socket'
2
+
1
3
  module LimitlessLed
2
4
  class Bridge
3
5
 
6
+ attr_accessor :host, :port
7
+
8
+ def initialize(host: 'localhost', port: 8899)
9
+ @host = host
10
+ @port = port
11
+ end
12
+
13
+ VALID_COMMANDS = (65..77).to_a
14
+
15
+ def socket
16
+ @socket ||= begin
17
+ UDPSocket.new.tap do |socket|
18
+ socket.connect host, port
19
+ end
20
+ end
21
+ end
22
+
23
+ def send_packet(packet)
24
+ socket.send packet, 0
25
+ end
26
+
27
+ def run(input)
28
+ command = input.bytes
29
+
30
+ case command.first
31
+ when 64
32
+ 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
+
73
+ else
74
+ log "invalid command recieved: #{command.first}: #{command}"
75
+ end
76
+ end
77
+
78
+ private
79
+
80
+ def color(color)
81
+
82
+ # Turn second byte
83
+ color = color.to_f / 255.0 * 360.0
84
+
85
+ # Rotate 90 degrees and flip to match dial ui on device
86
+ hue = color - 90
87
+
88
+ # Return the color
89
+ Color::HSL.new( hue, 90, 50).to_rgb
90
+
91
+ end
92
+
4
93
  end
5
94
  end
@@ -1,3 +1,3 @@
1
1
  module LimitlessLed
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -4,7 +4,7 @@ describe LimitlessLed do
4
4
 
5
5
  let(:params) { {} }
6
6
 
7
- subject { LimitlessLed::Bridge.new() }
7
+ subject { LimitlessLed::Bridge.new(params) }
8
8
 
9
9
  describe 'can be initialized with default values' do
10
10
  its(:host) { should == 'localhost' }
@@ -18,9 +18,9 @@ describe LimitlessLed do
18
18
  its(:port) { should == 6666 }
19
19
  end
20
20
 
21
- describe "#color" do
22
- it "changes color" do
23
- subject.should_receive(:send_packet).with("\xc2\x00\x55")
21
+ describe '#color' do
22
+ it 'changes color' do
23
+ # subject.should_receive(:send_packet).with("\x40\xFF\x55")
24
24
  end
25
25
  end
26
26
 
@@ -29,11 +29,11 @@ describe LimitlessLed do
29
29
 
30
30
  fake_socket = double(:fake_udp_socket)
31
31
  fake_socket.should_receive(:connect).with( subject.host, subject.port )
32
- fake_socket.should_receive(:send).with("stuff", 0)
32
+ fake_socket.should_receive(:send).with('stuff', 0)
33
33
 
34
34
  UDPSocket.should_receive(:new) { fake_socket }
35
35
 
36
- subject.send(:send_packet, "stuff")
36
+ subject.send(:send_packet, 'stuff')
37
37
 
38
38
  end
39
39
  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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Silvashy