rotor 0.0.4 → 0.0.5

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: a09b04547cb01901db87f7bb24b577c7f04dbd22
4
- data.tar.gz: 2681e960065e601a800fbb08ec35c8b3a30dad90
3
+ metadata.gz: 045817c2e789686019b0c8e8fa2b5fac3e92a3e1
4
+ data.tar.gz: 8cdb1bf4d66cb039b5bb0c55b8238830803dd753
5
5
  SHA512:
6
- metadata.gz: c4b577946cc3941814a45d79acc8e8c8feb029680e2013c57893263cdc5960e11cda4139ef634be9a13bbbcc99a23d370c0f83826e45def733a2fc32c3e3482b
7
- data.tar.gz: 4499b3265c9ed51e1faeec4870b9533c39a1e9b33dfa1eb772fb519bdc18e973935579beba974a415d704d6c21b256deb28e71491e2cb65da516c4610c8b7182
6
+ metadata.gz: dd0ea3779643df75afe7021a09ca1c50650209f23d310cac6e164113ddf9591f744fd25a353a3ecb121cbae746f2343940f0498c3e4587d8792e6e3b6c827509
7
+ data.tar.gz: 95dad1ab9e906f82b7c555f6c50ce18bf85a0e6617c20822475694126b13ea9a37d4ad48c729395d05d7c44c09f1d36a8e1bed8f14c6b488b3037f58d817e0fc
data/.DS_Store ADDED
Binary file
data/lib/rotor/motor.rb CHANGED
@@ -1,19 +1,29 @@
1
1
  require 'wiringpi'
2
+ require 'pi_piper'
3
+
2
4
  module Rotor
5
+ include PiPiper
3
6
  class Stepper
4
- def initialize(coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin)
7
+ def initialize(coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin=nil)
5
8
  @io = WiringPi::GPIO.new(WPI_MODE_GPIO)
6
9
  @coil_A_1_pin = coil_A_1_pin
7
10
  @coil_A_2_pin = coil_A_2_pin
8
11
  @coil_B_1_pin = coil_B_1_pin
9
12
  @coil_B_2_pin = coil_B_2_pin
10
13
  @enable_pin = enable_pin
11
- [coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin].each do |pin|
14
+
15
+ [@coil_A_1_pin, @coil_A_2_pin, @coil_B_1_pin, @coil_B_2_pin].each do |pin|
12
16
  `echo #{pin} > /sys/class/gpio/unexport`
13
17
  @io.mode(pin,OUTPUT)
14
18
  @io.write(pin,LOW)
15
19
  end
16
- @io.write(enable_pin,HIGH)
20
+
21
+ unless @enable_pin == nil
22
+ `echo #{@enable_pin} > /sys/class/gpio/unexport`
23
+ @io.mode(@enable_pin,OUTPUT)
24
+ @io.write(@enable_pin,LOW)
25
+ @io.write(@enable_pin,HIGH)
26
+ end
17
27
  end
18
28
 
19
29
  def forward(delay=5,steps=100)
@@ -50,5 +60,30 @@ module Rotor
50
60
  @io.write(@coil_B_1_pin, w3)
51
61
  @io.write(@coil_B_2_pin, w4)
52
62
  end
63
+
64
+ def set_home(x_coord=0, y_coord=0, x_homing_switch, y_homing_switch, x_homing_normally_open=true, y_homing_normally_open=true)
65
+ x_homing_normally_open ? x_homing_logic = :high : x_homing_logic = :low
66
+ y_homing_normally_open ? y_homing_logic = :high : y_homing_logic = :low
67
+
68
+ @x_move = true
69
+ @y_move = true
70
+
71
+ while @x_move == true
72
+ self.backwards(10,5)
73
+ end
74
+
75
+ while @y_move == true
76
+ self.forward(10,5)
77
+ end
78
+
79
+ after :pin => x_homing_switch, :goes => x_homing_logic do
80
+ @x_move = false
81
+ end
82
+
83
+ after :pin => y_homing_switch, :goes => y_homing_logic do
84
+ @y_move = false
85
+ end
86
+ end
87
+
53
88
  end
54
89
  end
data/lib/rotor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rotor
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/rotor.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
 
24
24
  spec.add_dependency "wiringpi"
25
+ spec.add_dependency "pi_piper"
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rotor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kobaltz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pi_piper
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Ruby Gem for controlling Bipolar and Unipolar Stepper Motors
56
70
  email:
57
71
  - dave@k-innovations.net
@@ -59,6 +73,7 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
76
+ - ".DS_Store"
62
77
  - ".gitignore"
63
78
  - Gemfile
64
79
  - LICENSE.txt