rpi_pinin_msgout 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b4fdc2b754129d212acd18f67a26fb72d3c78bf
4
- data.tar.gz: 0d0f15d97a7dfc2157ee544bf9198e548488809e
3
+ metadata.gz: c0d353cf5ebadeaf89618ce7a0bbc4ed07cf53d0
4
+ data.tar.gz: 0847602dac884ec4c2d8cb8783e8bd766f7b670e
5
5
  SHA512:
6
- metadata.gz: 0b0ad3e22ff963dca7a745ce285cdae820fcb0503971945c79267d4fa3da9b4665769b17c512d462f93bea6973f735995545a660271b87bbb84a63da05aec520
7
- data.tar.gz: f33c4c3851da1ead1d636bc6085755c0f7339cffa6624a133de801b8a5eb4569021b365830eb03e0999605fac0483b8747cd29fe18d59629783e35d00b82a652
6
+ metadata.gz: 1788b4f60a5a1ce11f59e0800fbe5b41f2d57d071dc129c60326a0f8973896fb3ac9bdb125f91479234a5e4da1efbc9ac21742cd193e72886c60af780a2f4b7c
7
+ data.tar.gz: 118ff1aa58148eb97a20b39e9d6dae80dbf212b485c16f0629340d96212d9de6c8f195737884d3b05ea41556060277c069ad19b3babc006d453505c857d823ae
checksums.yaml.gz.sig CHANGED
Binary file
@@ -18,15 +18,26 @@ class RPiPinInMsgOut < RPiPinIn
18
18
 
19
19
  def initialize(id, pull: nil, mode: :default, verbose: true,
20
20
  subtopic: 'sensor', device_id: 'pi', notifier: Echo.new,
21
- duration: '5 seconds', index: 0, capture_rate: 0.5)
21
+ duration: '5 seconds', index: 0, capture_rate: 0.5,
22
+ descriptor: 'detected')
22
23
 
23
24
  super(id, pull: pull)
24
25
 
25
26
  @mode, @verbose, @notifier, @duration = mode, verbose, notifier, duration
26
- @capture_rate = capture_rate
27
+ @capture_rate, @descriptor = capture_rate, descriptor
27
28
  @topic = [device_id, subtopic, index].join('/')
28
29
 
29
30
  end
31
+
32
+ def capture()
33
+
34
+ case @mode
35
+
36
+ when :default
37
+ setup { default_mode() }
38
+ end
39
+
40
+ end
30
41
 
31
42
  def capture_high()
32
43
 
@@ -51,12 +62,35 @@ class RPiPinInMsgOut < RPiPinIn
51
62
 
52
63
  private
53
64
 
65
+ def button_setup()
66
+
67
+ t0 = Time.now + 1
68
+
69
+ self.watch do |v|
70
+
71
+ # ignore any movements that happened a short time ago e.g. 250
72
+ # milliseconds ago since the last movement
73
+ if t0 + @capture_rate < Time.now then
74
+
75
+ puts Time.now.to_s if @verbose
76
+
77
+ yield(v)
78
+
79
+ t0 = Time.now
80
+
81
+ else
82
+ #puts 'ignoring ...'
83
+ end
84
+
85
+ end # /watch
86
+ end
87
+
54
88
  def setup()
55
89
 
56
90
  t0 = Time.now + 1
57
91
 
58
92
  self.watch_high do
59
-
93
+
60
94
  # ignore any movements that happened a short time ago e.g. 250
61
95
  # milliseconds ago since the last movement
62
96
  if t0 + @capture_rate < Time.now then
@@ -86,9 +120,9 @@ class RPiPinInMsgOut < RPiPinIn
86
120
  # identify if the movement is consecutive
87
121
  msg = if elapsed < duration then
88
122
  s = ChronicDuration.output(duration, :format => :long)
89
- "%s: detected %s times within the past %s" % [@topic, count, s ]
123
+ "%s: %s %s times within the past %s" % [@topic, count, @descriptor, s ]
90
124
  else
91
- "%s: detected" % [@topic, @index]
125
+ "%s: %s" % [@topic, @descriptor]
92
126
  end
93
127
 
94
128
  @notifier.notice msg
@@ -101,7 +135,7 @@ class RPiPinInMsgOut < RPiPinIn
101
135
  end
102
136
 
103
137
  def default_mode()
104
- @notifier.notice "%s: detected" % [@topic, @index]
138
+ @notifier.notice "%s: %s" % [@topic, @descriptor]
105
139
  end
106
140
 
107
- end
141
+ end
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- �H1e�&28�o�׍�D]��U=*�� � fv������F����>��)k�݈�>[_Chl ~uUR�#_r<S*P<��~2\���{ŧEA���F�|����i/�v ����x�qnR���-.�`BƋ쇨lLIoT�i0�ٴzR���Ȝus��5�'��;�_���ܚ���U=��w��@0���džW����.5GU��g�v�~�5�l��� [A-P8�l󴺫�rw-LU
1
+ _���ʼ�+n2j'������3-��sAT��ϥ�6O+�_���@�APGg1���W&��T��y��XHUMF�����S��*m�+��w?���Oe�<���(^�3) %�u����A�&���j>Z�VwAfgH!w;UUIM��M\����x���k���bU2����Y����C�u͓� sS����RyW������1<��ĝ��DX"�3�$I6��T(ؖ�����WX��ݨ
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpi_pinin_msgout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- `c-�?�+��su�d�ڎ|y%
1
+ ^��h ��//qS�<����l�?g��."0{p]#� Q�a���hz*���=��O��62�K"�Ǽ>O0��0��zs�e�}w����[�-C�v;�V���h��QD�"j+LU�nj�wѪ��Q�N�\��be���X�BD�����_e�!D��gE���Eg�������1�Q0-�p9���M/����+Dt�
2
+ 4e�{$� �2��r)K���c(