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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dddfa7c2d25bd688baa7eb5d4311cf357aed9a91
4
- data.tar.gz: b58a3d1be358edbc5c1261384af7a4677288d06a
3
+ metadata.gz: bb85402d57a779c32e58cc78f4eff7c40ba53e32
4
+ data.tar.gz: 24c42293e0a2c2b6e8fef92cc4c169a9b7ff31fe
5
5
  SHA512:
6
- metadata.gz: 932aba40c52749c0deb31af3b96091c90fb791be0f41548d2b9d33e7c1787b442f6cdaae8f23cd414adf74b0ffa6f038cb870feb6cd87c26b67d1f114b44a67b
7
- data.tar.gz: f23c0cd415319400a44c2ea49dabf55127cf8371b465f726778210520b2d9482f4e62eb63ab7fe15a28d60c95ca48be9049096c465fcc667d6ab6ce5af959bbb
6
+ metadata.gz: 938be26fd7742bc8bca911b8a612729ee62c80118a6a81c98604536ec5ccc3d241c92dec0d1e79e577121b51beec271704c449a0ce0499e45620347b7f7da848
7
+ data.tar.gz: df43566a13c3c14a5da3054990ba6e9fbe7b2bb469f27d26ae2d55606091a491cced2d78f4f1937a4730bb296959505c03a5aa2d90c260f168e63d21487744a9
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- artoo-gpio (0.0.1)
4
+ artoo-gpio (0.1.0)
5
5
  artoo (~> 1.1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -40,6 +40,7 @@ The following GPIO hardware devices have driver support:
40
40
  - Button
41
41
  - LED
42
42
  - Maxbotix ultrasonic range finder
43
+ - Analog sensor
43
44
  - Motor (DC)
44
45
  - Servo
45
46
 
@@ -1,5 +1,5 @@
1
1
  module Artoo
2
2
  module Gpio
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
@@ -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.1
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