rb-blink1 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.
data/README.rdoc CHANGED
@@ -1 +1,70 @@
1
- = blink1.rb
1
+ = rb-blink1
2
+
3
+ The Ruby interface for blink(1)
4
+
5
+ == Install
6
+
7
+ gem install rb-blink1
8
+
9
+ == Usage
10
+
11
+ === Set RGB
12
+
13
+ require 'blink1'
14
+
15
+ blink1 = Blink1.new
16
+ blink1.open
17
+ blink1.set_rgb(255, 255, 255)
18
+ blink1.close
19
+
20
+ === Fade to RGB
21
+
22
+ require 'blink1'
23
+
24
+ blink1 = Blink1.new
25
+ blink1.open
26
+ blink1.set_rgb(0, 0, 0)
27
+ blink1.fade_to_rgb(100, 255, 255, 255)
28
+ blink1.close
29
+
30
+ === Create and play pattern line
31
+
32
+ require 'blink1'
33
+
34
+ blink1 = Blink1.new
35
+ blink1.open
36
+ blink1.write_pattern_line(100, 255, 255, 255, 0)
37
+ blink1.write_pattern_line(100, 0, 255, 255, 1)
38
+ blink1.write_pattern_line(100, 255, 255, 0, 2)
39
+ blink1.write_pattern_line(100, 255, 0, 255, 3)
40
+ blink1.write_pattern_line(100, 255, 255, 255, 4)
41
+ blink1.write_pattern_line(100, 0, 255, 255, 5)
42
+ blink1.write_pattern_line(100, 255, 255, 0, 6)
43
+ blink1.write_pattern_line(100, 255, 0, 255, 7)
44
+ blink1.write_pattern_line(100, 255, 255, 255, 8)
45
+ blink1.write_pattern_line(100, 0, 255, 255, 9)
46
+ blink1.write_pattern_line(100, 255, 255, 0, 10)
47
+ blink1.play(0)
48
+ blink1.close
49
+
50
+ === Blink with specified color
51
+
52
+ require 'blink1'
53
+
54
+ blink1 = Blink1.new
55
+ blink1.open
56
+ blink1.blink(255, 255, 0, 5)
57
+ blink1.close
58
+
59
+ === Random color
60
+
61
+ require 'blink1'
62
+
63
+ blink1 = Blink1.new
64
+ blink1.open
65
+ blink1.randoom(25)
66
+ blink1.close
67
+
68
+ == Author
69
+
70
+ - {Atsushi Nagase}[http://ngs.io/]
@@ -30,10 +30,10 @@ when 'Windows_NT'
30
30
  when 'Linux'
31
31
 
32
32
  $CFLAGS <<
33
- `pkg-config libusb-1.0 --cflags`
33
+ " #{ `pkg-config libusb-1.0 --cflags` } "
34
34
 
35
- $LIBS <<
36
- `pkg-config libusb-1.0 --libs` <<
35
+ $LIBS <<
36
+ " #{ `pkg-config libusb-1.0 --libs` }"
37
37
  ' -lrt -lpthread -ldl -static '
38
38
 
39
39
  $HID_C = "#{$srcdir}/hid.c.libusb"
@@ -1,3 +1,3 @@
1
1
  class Blink1
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/blink1.rb CHANGED
@@ -1,2 +1,41 @@
1
1
  require 'blink1/blink1'
2
- require 'blink1/version'
2
+ require 'blink1/version'
3
+
4
+ class Blink1
5
+
6
+ attr_accessor :millis
7
+ attr_accessor :delay_millis
8
+
9
+ def initialize
10
+ @millis ||= 300
11
+ @delay_millis ||= 500
12
+ end
13
+
14
+ def blink r, g, b, times
15
+ 1.upto(times) do
16
+ self.fade_to_rgb(millis, r, g, b)
17
+ self.class.sleep(delay_millis)
18
+ self.fade_to_rgb(millis, 0, 0, 0)
19
+ self.class.sleep(delay_millis)
20
+ end
21
+ end
22
+
23
+ def random times
24
+ 1.upto(times) do
25
+ r = rand(0xff)
26
+ g = rand(0xff)
27
+ b = rand(0xff)
28
+ self.fade_to_rgb(millis, r, g, b)
29
+ self.class.sleep(delay_millis)
30
+ end
31
+ end
32
+
33
+ def on
34
+ self.fade_to_rgb(millis, 0xff, 0xff, 0xff)
35
+ end
36
+
37
+ def off
38
+ self.fade_to_rgb(millis, 0, 0, 0)
39
+ end
40
+
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb-blink1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-17 00:00:00.000000000 Z
12
+ date: 2012-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler