rpi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/lib/rpi.rb +69 -0
- metadata +81 -0
- metadata.gz.sig +5 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0192c5f1e6eecc2f253e3751986775d66f72ddbd
|
4
|
+
data.tar.gz: ac9bb7ccf143c0becd97d6ad932aa7999a68c76b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ed36eba266c1d1f03647fef8980f6e26e9c52113d31f810d2a95cb3a22241d33a52741eb23cd58e03f560767c7844dd372125c0d2290a0c25307cd88ae50a60
|
7
|
+
data.tar.gz: c3cff4369ed0f2fa85ca0ec9080438adae31425609c6ea0003eaacb700285d1d4bb46a6b2125d81a355781ed398c1db21ce0107709bfe9e2d35f6866930b15c1
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/lib/rpi.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: rpi.rb
|
4
|
+
|
5
|
+
require 'pi_piper'
|
6
|
+
|
7
|
+
|
8
|
+
class RPi
|
9
|
+
include PiPiper
|
10
|
+
|
11
|
+
class Led < Pin
|
12
|
+
|
13
|
+
HIGH = 1
|
14
|
+
LOW = 0
|
15
|
+
|
16
|
+
def initialize(id)
|
17
|
+
@id = id
|
18
|
+
super(pin: id, direction: :out)
|
19
|
+
@state = self.value
|
20
|
+
end
|
21
|
+
|
22
|
+
def on() super(); @state = :on end
|
23
|
+
|
24
|
+
def off()
|
25
|
+
|
26
|
+
return if self.off?
|
27
|
+
super()
|
28
|
+
@state = :off
|
29
|
+
end
|
30
|
+
|
31
|
+
def blink(seconds=0.5)
|
32
|
+
|
33
|
+
@state = :blink
|
34
|
+
|
35
|
+
Thread.new do
|
36
|
+
while @state == :blink do
|
37
|
+
(set_pin HIGH; sleep seconds; set_pin LOW; sleep seconds)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
alias stop off
|
43
|
+
|
44
|
+
def on?() @state == :on end
|
45
|
+
def off?() @state == :off end
|
46
|
+
|
47
|
+
# set val with 0 (off) or 1 (on)
|
48
|
+
#
|
49
|
+
def set_pin(val)
|
50
|
+
|
51
|
+
state = @state
|
52
|
+
self.update_value val
|
53
|
+
@state = state
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(a=[])
|
58
|
+
@leds = a.map {|pin| Led.new pin }
|
59
|
+
end
|
60
|
+
|
61
|
+
def led() @leds end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
if __FILE__ == $0 then
|
66
|
+
# example
|
67
|
+
my_rpi = RPi.new %w(17 22 18 4 23 25 27) # <-- each pin connects to an LED
|
68
|
+
my_rpi.led[ARGV.first.to_i].method(ARGV.last.to_sym).call
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rpi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
|
+
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
+
8ixkARkWAmV1MB4XDTEzMTEyNDIwMDcyNFoXDTE0MTEyNDIwMDcyNFowSDESMBAG
|
16
|
+
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXN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AOxICwewAx186W0aVXdfHtujoUBYHbuutl
|
32
|
+
2yqX2uRxfgCriQ==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2013-11-24 00:00:00.000000000 Z
|
35
|
+
dependencies:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: pi_piper
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
description:
|
51
|
+
email: james@r0bertson.co.uk
|
52
|
+
executables: []
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- lib/rpi.rb
|
57
|
+
homepage: https://github.com/jrobertson/rpi
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.0.0.rc.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: The RPi gem makes it easy to set blinking LEDs on the Rapsberry Pi
|
81
|
+
test_files: []
|