pinx 0.1.0

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 (6) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +4 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/pinx.rb +83 -0
  5. metadata +67 -0
  6. metadata.gz.sig +1 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72f620e28be95dae20baad281601acd928d25e92
4
+ data.tar.gz: 52ba8b19b6f4dc4a02b9a4982dba48e718944579
5
+ SHA512:
6
+ metadata.gz: 042d3cd2146838aef20fa739f90e9d9188b2eca844d9d77f65b2bb17d100a7346e1be96e1b9a492bb9445a63b91be513b54bba263463fae1f99a37fdb8a514da
7
+ data.tar.gz: f62cc4197eee73cede6a5c448f9ff221e072043414dae9d5e9da657d35df1a7514acd44834a3c195e6ce3fe71e2122fc939c7a4061b6b6ce1a570b721f1a6615
@@ -0,0 +1,4 @@
1
+ �Bj=V���|�|[A��.�h��%��6k�Ʊ_����GEJRb~�0�*=��x�
2
+ 4�Nˈ�МS�8T�3.�}f҇�DZU�O8��
3
+ ��I-]�#�x��B�^!l;#�R�vѧ�;�XٽR!����0-d3{�)R�b��,�PEq&�M
4
+ H�-l��q~��+�)
Binary file
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: pinx.rb
4
+
5
+ # This is a base clase used by gems rpi_pwm, rpi_led_simulator,
6
+ # myfirmata-plugin-led, and simple_wiimote.
7
+
8
+ class PinX
9
+
10
+ HIGH = true
11
+ LOW = false
12
+
13
+ attr_reader :id
14
+
15
+ def initialize(id)
16
+ @id = id
17
+ @on, @blinking = false, false
18
+ end
19
+
20
+
21
+ def on(durationx=nil, duration: nil)
22
+
23
+ set_pin HIGH
24
+ @on, @blinking = true, false
25
+ duration ||= durationx
26
+
27
+ @off_thread.exit if @off_thread
28
+ @on_thread = Thread.new {(sleep duration; off()) } if duration
29
+
30
+ end
31
+
32
+ def off(durationx=nil, duration: nil)
33
+
34
+ set_pin LOW
35
+ @on, @blinking = false, false
36
+ duration ||= durationx
37
+
38
+ @on_thread.exit if @on_thread
39
+ @off_thread = Thread.new { (sleep duration; on()) } if duration
40
+
41
+ end
42
+
43
+ alias stop off
44
+
45
+ def blink(seconds=0.5, duration: nil)
46
+
47
+ @blinking = true
48
+ t2 = Time.now + duration if duration
49
+
50
+ Thread.new do
51
+ while @blinking do
52
+
53
+ set_pin HIGH
54
+ sleep seconds / 2.0
55
+ break if !@blinking
56
+ sleep seconds / 2.0
57
+ break if !@blinking
58
+
59
+ set_pin LOW
60
+ sleep seconds / 2.0
61
+ break if !@blinking
62
+ sleep seconds / 2.0
63
+ break if !@blinking
64
+
65
+ self.off if duration and Time.now >= t2
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ def on?() @on end
72
+ def off?() !@on end
73
+
74
+ def to_s()
75
+ @id
76
+ end
77
+
78
+ protected
79
+
80
+ def set_pin(val)
81
+ @on = val
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pinx
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
+ 8ixkARkWAmV1MB4XDTE3MDUwOTIyMTAwOFoXDTE4MDUwOTIyMTAwOFowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCC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 dependencies: []
36
+ description:
37
+ email: james@jamesrobertson.eu
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files: []
41
+ files:
42
+ - lib/pinx.rb
43
+ homepage: https://github.com/jrobertson/pinx
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.6.8
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: pinx
67
+ test_files: []
@@ -0,0 +1 @@
1
+ �~1=�|>�Y���Q`E�\P�D��G���]�,�!��p��FBD�DfnFQ9�j�s}'��:K�W���1(��� ��N/�������� �b� �� �"�Q����s�?#�]:��:{��C[����[Y&9XHm�?c:�v�ȕ`q��ZT��������l��[���׆�ŕ�dܴV�w*!�.�M���̮ig#֞,�l�\}c��A�R��5y,i�S9�o��!a� �@�ڗ��