artoo-gpio 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/artoo-gpio/version.rb +1 -1
- data/lib/artoo/drivers/analog_sensor.rb +43 -0
- data/lib/artoo/drivers/maxbotix.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb85402d57a779c32e58cc78f4eff7c40ba53e32
|
4
|
+
data.tar.gz: 24c42293e0a2c2b6e8fef92cc4c169a9b7ff31fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 938be26fd7742bc8bca911b8a612729ee62c80118a6a81c98604536ec5ccc3d241c92dec0d1e79e577121b51beec271704c449a0ce0499e45620347b7f7da848
|
7
|
+
data.tar.gz: df43566a13c3c14a5da3054990ba6e9fbe7b2bb469f27d26ae2d55606091a491cced2d78f4f1937a4730bb296959505c03a5aa2d90c260f168e63d21487744a9
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/artoo-gpio/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'artoo/drivers/driver'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Drivers
|
5
|
+
# AnalogSensors driver behaviors
|
6
|
+
class AnalogSensor < Driver
|
7
|
+
COMMANDS = [:analog_read, :lower, :upper, :previous_read].freeze
|
8
|
+
|
9
|
+
attr_reader :lower, :upper, :previous_read
|
10
|
+
|
11
|
+
def analog_read(pin)
|
12
|
+
connection.analog_read(pin)
|
13
|
+
end
|
14
|
+
|
15
|
+
def start_driver
|
16
|
+
@previous_read = 0
|
17
|
+
@upper = additional_params[:upper].nil? ? 1023 : additional_params[:upper]
|
18
|
+
@lower = additional_params[:lower].nil? ? 0 : additional_params[:lower]
|
19
|
+
|
20
|
+
every(interval) do
|
21
|
+
new_value = connection.analog_read(pin)
|
22
|
+
update(new_value) unless new_value.nil?
|
23
|
+
end if !interval.nil? and interval > 0
|
24
|
+
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
# Publishes events according to the button feedback
|
30
|
+
def update(new_val)
|
31
|
+
@previous_read = new_val
|
32
|
+
|
33
|
+
if new_val >= @upper
|
34
|
+
publish(event_topic_name("update"), "upper", new_val)
|
35
|
+
publish(event_topic_name("upper"), new_val)
|
36
|
+
elsif new_val <= @lower
|
37
|
+
publish(event_topic_name("update"), "lower", new_val)
|
38
|
+
publish(event_topic_name("lower"), new_val)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -35,7 +35,7 @@ module Artoo
|
|
35
35
|
|
36
36
|
# Publishes events according to the ultrasonic rangefinder value
|
37
37
|
def update(value)
|
38
|
-
last_reading = value
|
38
|
+
@last_reading = value
|
39
39
|
publish(event_topic_name("update"), "range", range)
|
40
40
|
publish(event_topic_name("range"), range)
|
41
41
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artoo-gpio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ron Evans
|
@@ -77,6 +77,7 @@ executables: []
|
|
77
77
|
extensions: []
|
78
78
|
extra_rdoc_files: []
|
79
79
|
files:
|
80
|
+
- .travis.yml
|
80
81
|
- Gemfile
|
81
82
|
- Gemfile.lock
|
82
83
|
- LICENSE
|
@@ -85,6 +86,7 @@ files:
|
|
85
86
|
- artoo-gpio.gemspec
|
86
87
|
- lib/artoo-gpio.rb
|
87
88
|
- lib/artoo-gpio/version.rb
|
89
|
+
- lib/artoo/drivers/analog_sensor.rb
|
88
90
|
- lib/artoo/drivers/button.rb
|
89
91
|
- lib/artoo/drivers/led.rb
|
90
92
|
- lib/artoo/drivers/maxbotix.rb
|