pan_tilt 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,17 +6,19 @@ require 'io/console'
6
6
  require 'pan_tilt/rotor'
7
7
 
8
8
  module PanTilt
9
- TILT_PIN = 9
10
- PAN_PIN = 11
11
- LIVE_LED = 13
12
- ESCAPE = 'e'
13
- LEFT_ARROW = 'h'
14
- RIGHT_ARROW = 'l'
15
- UP_ARROW = 'k'
16
- DOWN_ARROW = 'j'
17
- MAX_TILT_ANGLE = 135
18
- MAX_PAN_ANGLE = 160
19
- MIN_TILT_ANGLE = 15
20
- MIN_PAN_ANGLE = 0
21
- INCREMENT = 5
9
+ TILT_PIN = 9
10
+ PAN_PIN = 11
11
+ LIVE_LED = 13
12
+ ESCAPE = 'e'
13
+ LEFT_ARROW = 'h'
14
+ RIGHT_ARROW = 'l'
15
+ UP_ARROW = 'k'
16
+ DOWN_ARROW = 'j'
17
+ MAX_TILT_ANGLE = 135
18
+ MAX_PAN_ANGLE = 160
19
+ MIN_TILT_ANGLE = 15
20
+ MIN_PAN_ANGLE = 0
21
+ PAN_START_POSITION = 90
22
+ TILT_START_POSITION = 90
23
+ INCREMENT = 5
22
24
  end
@@ -1,9 +1,13 @@
1
1
  module PanTilt
2
2
  class CommandLine
3
3
  def initialize(debug=false)
4
- @debug = debug
4
+ options = {
5
+ debug: debug,
6
+ pan_position: PanTilt::PAN_START_POSITION,
7
+ tilt_position: PanTilt::TILT_START_POSITION
8
+ }
5
9
  @board = Dino::Board.new(Dino::TxRx::Serial.new)
6
- @rotor = PanTilt::Rotor.new @board, @debug
10
+ @rotor = PanTilt::Rotor.new @board, options
7
11
  @led = Dino::Components::Led.new(pin: PanTilt::LIVE_LED, board: @board)
8
12
  end
9
13
 
@@ -2,12 +2,14 @@ module PanTilt
2
2
  class Rotor
3
3
  attr_reader :board, :tilt_servo, :pan_servo
4
4
 
5
- def initialize(board, debug=false)
6
- @debug = debug
5
+ def initialize(board, options={})
6
+ @debug = options[:debug]
7
+ pan_pos = options[:pan_position]
8
+ tilt_pos = options[:tilt_position]
7
9
 
8
10
  @board = board
9
- @tilt_servo = Dino::Components::Servo.new(pin: PanTilt::TILT_PIN, board: @board)
10
- @pan_servo = Dino::Components::Servo.new(pin: PanTilt::PAN_PIN, board: @board)
11
+ @tilt_servo = Dino::Components::Servo.new(pin: PanTilt::TILT_PIN, board: @board, position: tilt_pos)
12
+ @pan_servo = Dino::Components::Servo.new(pin: PanTilt::PAN_PIN, board: @board, position: pan_pos)
11
13
  end
12
14
 
13
15
  def rotate_by(pan_offset, tilt_offset)
@@ -1,3 +1,3 @@
1
1
  module PanTilt
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pan_tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-23 00:00:00.000000000 Z
12
+ date: 2013-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dino