ws2801 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. data/lib/ws2801.rb +39 -38
  2. metadata +3 -3
data/lib/ws2801.rb CHANGED
@@ -9,38 +9,38 @@ module WS2801
9
9
  @@strip = []
10
10
  @@device = "/dev/spidev0.0"
11
11
 
12
- # Set/read length of strip
13
- #
14
- # Example:
15
- # >> WS2801.length(25)
16
- # >> WS2801.length
17
- # => 25
18
- #
19
- # Arguments (or nil):
20
- # count: (Integer)
12
+ # Set/read length of strip
13
+ #
14
+ # Example:
15
+ # >> WS2801.length(25)
16
+ # >> WS2801.length
17
+ # => 25
18
+ #
19
+ # Arguments (or nil):
20
+ # count: (Integer)
21
21
  def self.length len = nil
22
22
  return @@len if len.nil?
23
23
  @@len = len
24
24
  end
25
25
 
26
- # Set/read device
27
- #
28
- # Example:
29
- # >> WS2801.device("/dev/spidev0.0")
30
- # >> WS2801.device
31
- # => "/dev/spidev0.0"
32
- #
33
- # Arguments (or nil):
34
- # device: (String)
26
+ # Set/read device
27
+ #
28
+ # Example:
29
+ # >> WS2801.device("/dev/spidev0.0")
30
+ # >> WS2801.device
31
+ # => "/dev/spidev0.0"
32
+ #
33
+ # Arguments (or nil):
34
+ # device: (String)
35
35
  def self.device dev = nil
36
36
  return @@device if dev.nil?
37
37
  @@device = dev
38
38
  end
39
39
 
40
- # Generate empty strip array
41
- #
42
- # Example:
43
- # >> WS2801.gen
40
+ # Generate empty strip array
41
+ #
42
+ # Example:
43
+ # >> WS2801.gen
44
44
  def self.gen
45
45
  @@strip = Array.new(@@len*3+1)
46
46
  end
@@ -48,16 +48,16 @@ module WS2801
48
48
  # Return current Strip
49
49
  #
50
50
  # Example;
51
- # >> WS2801.strip
51
+ # >> WS2801.strip
52
52
  def self.strip
53
53
  return @@strip
54
54
  end
55
55
 
56
- # Write stripinfo to device (if not empty)
57
- # this needs root rights
56
+ # Write stripinfo to device (if not empty)
57
+ # this needs root rights
58
58
  #
59
- # Example:
60
- # >> WS2801.write
59
+ # Example:
60
+ # >> WS2801.write
61
61
  def self.write
62
62
  return false if @@strip.nil?
63
63
 
@@ -73,13 +73,13 @@ module WS2801
73
73
  # Put pixel X to
74
74
  #
75
75
  # Example:
76
- # >> WS2801.put 3, 120, 255, 120
76
+ # >> WS2801.put 3, 120, 255, 120
77
77
  #
78
78
  # Arguments:
79
- # pixel (Integer)
80
- # red (Integer)
81
- # green (Integer)
82
- # blue (Integer)
79
+ # pixel (Integer)
80
+ # red (Integer)
81
+ # green (Integer)
82
+ # blue (Integer)
83
83
  def self.put pixel, red, green, blue
84
84
  return false if @@strip.nil?
85
85
  @@strip[(pixel*3)] = red
@@ -90,15 +90,16 @@ module WS2801
90
90
  # Fill all pixel
91
91
  #
92
92
  # Example:
93
- # >> WS2801.fill 120, 255, 120
93
+ # >> WS2801.fill 120, 255, 120
94
94
  #
95
95
  # Arguments:
96
- # red (Integer)
97
- # green (Integer)
98
- # blue (Integer)
96
+ # red (Integer)
97
+ # green (Integer)
98
+ # blue (Integer)
99
99
  def self.fill red, green, blue
100
+ self.gen if @@strip.length == 0
100
101
  ((@@strip.size-1)/3).times do |i|
101
- @@strip[(i*3)] = red
102
+ @@strip[(i*3)] = red
102
103
  @@strip[(i*3)+1] = green
103
104
  @@strip[(i*3)+2] = blue
104
105
  end
@@ -107,7 +108,7 @@ module WS2801
107
108
  # Reset pixel to black
108
109
  #
109
110
  # Example:
110
- # >> WS2801.reset
111
+ # >> WS2801.reset
111
112
  def self.reset
112
113
  self.gen
113
114
  self.write
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ws2801
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-01-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Controlling ws2801 chip from Ruby (RGB LED Stripes/Pixel)
14
+ description: Controlling ws2801 chip from Ruby on Raspberry PI (RGB LED Stripes/Pixel)
15
15
  email: roman DOT pramberger AT gmail DOT com
16
16
  executables: []
17
17
  extensions: []
@@ -41,5 +41,5 @@ rubyforge_project:
41
41
  rubygems_version: 1.8.23
42
42
  signing_key:
43
43
  specification_version: 3
44
- summary: Controlling ws2801 chip from Ruby (RGB LED Stripes/Pixel)
44
+ summary: Controlling ws2801 chip from Ruby on Raspberry PI (RGB LED Stripes/Pixel)
45
45
  test_files: []