rb-blink1 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2012 Atsushi Nagase
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -62,9 +62,28 @@ The Ruby interface for blink(1)
62
62
 
63
63
  blink1 = Blink1.new
64
64
  blink1.open
65
- blink1.randoom(25)
65
+ blink1.random(25)
66
66
  blink1.close
67
67
 
68
+ === Turn LED on
69
+
70
+ require 'blink1'
71
+
72
+ blink1 = Blink1.new
73
+ blink1.open
74
+ blink1.on
75
+ blink1.close
76
+
77
+ === Turn LED off
78
+
79
+ require 'blink1'
80
+
81
+ blink1 = Blink1.new
82
+ blink1.open
83
+ blink1.off
84
+ blink1.close
85
+
86
+
68
87
  == Author
69
88
 
70
89
  - {Atsushi Nagase}[http://ngs.io/]
data/ext/blink1/blink1.c CHANGED
@@ -44,8 +44,8 @@ static VALUE rb_blink1_blink1_getCachedPath(VALUE self, VALUE i) {
44
44
 
45
45
  static VALUE rb_blink1_getCachedSerial(VALUE self, VALUE i) {
46
46
  const wchar_t *ret = blink1_getCachedSerial(FIX2INT(i));
47
- char *dest;
48
- wcstombs(dest, ret, sizeof(ret));
47
+ char dest[16] = {"\0"};
48
+ int t = wcstombs(dest, ret, sizeof(ret));
49
49
  return rb_str_new2(dest);
50
50
  }
51
51
 
@@ -1,3 +1,3 @@
1
1
  class Blink1
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/blink1.rb CHANGED
@@ -12,7 +12,7 @@ class Blink1
12
12
  end
13
13
 
14
14
  def blink r, g, b, times
15
- 1.upto(times) do
15
+ times.times do
16
16
  self.fade_to_rgb(millis, r, g, b)
17
17
  self.class.sleep(delay_millis)
18
18
  self.fade_to_rgb(millis, 0, 0, 0)
@@ -21,7 +21,7 @@ class Blink1
21
21
  end
22
22
 
23
23
  def random times
24
- 1.upto(times) do
24
+ times.times do
25
25
  r = rand(0xff)
26
26
  g = rand(0xff)
27
27
  b = rand(0xff)
@@ -38,4 +38,31 @@ class Blink1
38
38
  self.fade_to_rgb(millis, 0, 0, 0)
39
39
  end
40
40
 
41
- end
41
+ def [] index
42
+ self.read_pattern_line(index)
43
+ end
44
+
45
+ def []= index, prop
46
+ fade_millis = prop[:fade_millis] || prop['fade_millis']
47
+ r = prop[:r] || prop['r']
48
+ g = prop[:g] || prop['g']
49
+ b = prop[:b] || prop['b']
50
+ self.write_pattern_line(index, fade_millis, r, g, b)
51
+ end
52
+
53
+ def self.list
54
+ count = enumerate_vid_pid(vendor_id, product_id)
55
+ i = 0
56
+ devs = []
57
+ while i < count do
58
+ devs << {
59
+ id: i,
60
+ serial: cached_serial(i),
61
+ path: cached_path(i)
62
+ }
63
+ i += 1
64
+ end
65
+ devs
66
+ end
67
+
68
+ 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.2
4
+ version: 0.0.4
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-18 00:00:00.000000000 Z
12
+ date: 2012-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler