blinky 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/blinky/light.rb +2 -1
- data/lib/blinky/version.rb +1 -1
- data/lib/device_recipes/delcom_engineering/visual_indicator_gen_two.rb +3 -0
- data/lib/device_recipes/thing_m/blink_1.rb +19 -16
- data/spec/fixtures/device_recipes/aenima_engineering/model_462.rb +3 -0
- data/spec/fixtures/device_recipes/aenima_engineering/model_eulogy.rb +3 -0
- data/spec/fixtures/device_recipes/fragile_engineering/wretched.rb +3 -0
- data/spec/light_spec.rb +14 -2
- metadata +1 -1
data/lib/blinky/light.rb
CHANGED
data/lib/blinky/version.rb
CHANGED
@@ -9,7 +9,6 @@ module Blinky
|
|
9
9
|
|
10
10
|
def failure!
|
11
11
|
stop
|
12
|
-
set_flash_pattern("\xFF\x00\x00")
|
13
12
|
play
|
14
13
|
end
|
15
14
|
|
@@ -28,32 +27,36 @@ module Blinky
|
|
28
27
|
set_colour("\x00\x00\x00")
|
29
28
|
end
|
30
29
|
|
30
|
+
def init
|
31
|
+
set_flash_pattern("\xFF\x00\x00")
|
32
|
+
end
|
33
|
+
|
31
34
|
private
|
32
35
|
def set_colour colour
|
33
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01\x6E#{colour}\x00\x00\x00\x00",
|
36
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01\x6E#{colour}\x00\x00\x00\x00", 0)
|
34
37
|
end
|
35
38
|
|
36
39
|
def play
|
37
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x01\x01\x00\x00\x00\x00\x00",
|
40
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x01\x01\x00\x00\x00\x00\x00", 0)
|
38
41
|
end
|
39
42
|
|
40
43
|
def stop
|
41
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x00\x01\x00\x00\x00\x00\x00",
|
44
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01p\x00\x01\x00\x00\x00\x00\x00", 0)
|
42
45
|
end
|
43
46
|
|
44
47
|
def set_flash_pattern colour
|
45
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P#{colour}\x00\x0A\x00\x00",
|
46
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x0A\x01\x00",
|
47
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x02\x00",
|
48
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x03\x00",
|
49
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x04\x00",
|
50
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x05\x00",
|
51
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x06\x00",
|
52
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x07\x00",
|
53
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x08\x00",
|
54
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x09\x00",
|
55
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0A\x00",
|
56
|
-
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0B\x00",
|
48
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P#{colour}\x00\x0A\x00\x00", 0)
|
49
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x0A\x01\x00", 0)
|
50
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x02\x00", 0)
|
51
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x03\x00", 0)
|
52
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x04\x00", 0)
|
53
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x05\x00", 0)
|
54
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x06\x00", 0)
|
55
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x07\x00", 0)
|
56
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x08\x00", 0)
|
57
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x09\x00", 0)
|
58
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0A\x00", 0)
|
59
|
+
@handle.usb_control_msg(0x21, 0x09, (3 << 8) | 1, 0, "\x01P\x00\x00\x00\x00\x00\x0B\x00", 0)
|
57
60
|
end
|
58
61
|
|
59
62
|
end
|
data/spec/light_spec.rb
CHANGED
@@ -6,7 +6,12 @@ module Blinky
|
|
6
6
|
module TestModel
|
7
7
|
def success!
|
8
8
|
@handle.indicate_success
|
9
|
-
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def init
|
12
|
+
@handle.init
|
13
|
+
end
|
14
|
+
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
@@ -24,11 +29,18 @@ module Blinky
|
|
24
29
|
|
25
30
|
|
26
31
|
describe "Light" do
|
32
|
+
|
33
|
+
it "will use device recipe to initialise itself on construction" do
|
34
|
+
supported_device = double("supported device",:idVendor => 0x2000, :idProduct => 0x2222)
|
35
|
+
supported_device.should_receive(:init)
|
36
|
+
Light.new(supported_device, TestEngineering::TestModel, [MockCiPlugin, AnotherMockCiPlugin ] )
|
37
|
+
end
|
27
38
|
|
28
39
|
describe "that has been constructed with a device, a device recipe, and some CI plugins" do
|
29
40
|
|
30
41
|
before(:each) do
|
31
|
-
@supported_device = double("supported device",:idVendor => 0x2000, :idProduct => 0x2222)
|
42
|
+
@supported_device = double("supported device",:idVendor => 0x2000, :idProduct => 0x2222)
|
43
|
+
@supported_device.stub(:init)
|
32
44
|
@light = Light.new(@supported_device, TestEngineering::TestModel, [MockCiPlugin, AnotherMockCiPlugin ] )
|
33
45
|
end
|
34
46
|
|