rotor 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rotor/motor.rb +9 -7
- data/lib/rotor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 749e70524d5cd517fec84abfafd70ea35791a3b6
|
4
|
+
data.tar.gz: 8f3f7295f4423fedeeb579fb99e1085408f40499
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf6377a70975b031edac451120b6d7ae201f5acb937481e1ce3f3f8c16c8bc039f74bd901dc68823acb67b09ec24645713c537f1cba8d7973c33a42a5aabb826
|
7
|
+
data.tar.gz: 473517bc860cff6ebc4f71bcb3c956eb676523725ba7d7bdd26c4bbd4adb19ae3ed03526c306000c92bc7b57f8c244ab359e1c97753b8f116ea2731a0aa3fcf3
|
data/lib/rotor/motor.rb
CHANGED
@@ -2,7 +2,7 @@ require 'wiringpi'
|
|
2
2
|
|
3
3
|
module Rotor
|
4
4
|
class Stepper
|
5
|
-
def initialize(coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin=nil)
|
5
|
+
def initialize(coil_A_1_pin, coil_A_2_pin, coil_B_1_pin, coil_B_2_pin, enable_pin=nil, homing_switch, homing_normally)
|
6
6
|
@io = WiringPi::GPIO.new(WPI_MODE_GPIO)
|
7
7
|
@coil_A_1_pin = coil_A_1_pin
|
8
8
|
@coil_A_2_pin = coil_A_2_pin
|
@@ -10,6 +10,8 @@ module Rotor
|
|
10
10
|
@coil_B_2_pin = coil_B_2_pin
|
11
11
|
@enable_pin = enable_pin
|
12
12
|
|
13
|
+
@homing_switch = homing_switch
|
14
|
+
@homing_normally = homing_normally
|
13
15
|
[@coil_A_1_pin, @coil_A_2_pin, @coil_B_1_pin, @coil_B_2_pin].each do |pin|
|
14
16
|
`echo #{pin} > /sys/class/gpio/unexport`
|
15
17
|
@io.mode(pin,OUTPUT)
|
@@ -59,14 +61,14 @@ module Rotor
|
|
59
61
|
@io.write(@coil_B_2_pin, w4)
|
60
62
|
end
|
61
63
|
|
62
|
-
def set_home(
|
63
|
-
`echo #{homing_switch} > /sys/class/gpio/unexport`
|
64
|
-
@io.mode(homing_switch,INPUT)
|
64
|
+
def set_home(direction)
|
65
|
+
`echo #{@homing_switch} > /sys/class/gpio/unexport`
|
66
|
+
@io.mode(@homing_switch,INPUT)
|
65
67
|
@move = true
|
66
68
|
while @move == true
|
67
|
-
backwards(2,1) if direction == :backwards #&& @io.read(homing_switch) == homing_normally
|
68
|
-
forward(2,1) if direction == :forward #&& @io.read(homing_switch) == homing_normally
|
69
|
-
@move = false unless @io.read(homing_switch) == homing_normally
|
69
|
+
backwards(2,1) if direction == :backwards #&& @io.read(@homing_switch) == @homing_normally
|
70
|
+
forward(2,1) if direction == :forward #&& @io.read(@homing_switch) == @homing_normally
|
71
|
+
@move = false unless @io.read(@homing_switch) == @homing_normally
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
data/lib/rotor/version.rb
CHANGED