rotor 0.0.13 → 0.1.00
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rotor/gcode.rb +61 -7
- data/lib/rotor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85a4ae370eef40efc19bd9a1745a36e8dbb82943
|
4
|
+
data.tar.gz: 9db5dfab12dc9abaad33fb8db53d3cb2a09e82b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3380a0d8992f067736c53b0aa986a13b94f5aa9b807c33c1b9213ad4e6a5063a35653f00d3cf9815fd32826509ec4ad2cb87b7d964c011287ac7434034b4b3b4
|
7
|
+
data.tar.gz: b74c20526d395f4890bb2b7b8b430a629aff4eb48c89f91f57a3e5d9ff60fd242f1bbc3a65c76d4ad2278538893c69bc37c43bc881e416fb17ad81914d989877
|
data/lib/rotor/gcode.rb
CHANGED
@@ -22,9 +22,62 @@ module Rotor
|
|
22
22
|
if parsed_line[:g]
|
23
23
|
#Move to this origin point.
|
24
24
|
if parsed_line[:g] == 0
|
25
|
-
|
25
|
+
if parsed_line[:z] && parsed_line[:f] && parsed_line[:x].nil? && parsed_line[:y].nil?
|
26
|
+
puts "Lowering marker"
|
27
|
+
@servo.rotate(:down) if @servo
|
28
|
+
elsif parsed_line[:z] && parsed_line[:f].nil? && parsed_line[:x].nil? && parsed_line[:y].nil?
|
29
|
+
puts "Raising marker::#{parsed_line}"
|
30
|
+
@servo.rotate(:up) if @servo
|
31
|
+
else
|
32
|
+
puts "Move Stepper::#{parsed_line}"
|
33
|
+
move_stepper(parsed_line,1)
|
34
|
+
end
|
26
35
|
elsif parsed_line[:g] == 1
|
27
|
-
|
36
|
+
if parsed_line[:z] && parsed_line[:f] && parsed_line[:x].nil? && parsed_line[:y].nil?
|
37
|
+
puts "Lowering marker"
|
38
|
+
@servo.rotate(:down) if @servo
|
39
|
+
elsif parsed_line[:z] && parsed_line[:f].nil? && parsed_line[:x].nil? && parsed_line[:y].nil?
|
40
|
+
puts "Raising marker::#{parsed_line}"
|
41
|
+
@servo.rotate(:up) if @servo
|
42
|
+
else
|
43
|
+
puts "Move Stepper::#{parsed_line}"
|
44
|
+
move_stepper(parsed_line,25)
|
45
|
+
end
|
46
|
+
elsif parsed_line[:g] == 2 || parsed_line[:g] == 3
|
47
|
+
# Get my ARC on
|
48
|
+
puts "DEBUG::#{parsed_line}"
|
49
|
+
x_start = @x
|
50
|
+
x_end = parsed_line[:x]
|
51
|
+
|
52
|
+
y_start = @y
|
53
|
+
y_end = parsed_line[:y]
|
54
|
+
|
55
|
+
x_offset = parsed_line[:i]
|
56
|
+
y_offset = parsed_line[:j]
|
57
|
+
|
58
|
+
x_origin = x_offset + x_start
|
59
|
+
y_origin = y_offset + y_start
|
60
|
+
|
61
|
+
radius = Math.sqrt((x_start - x_origin) ** 2 + (y_start - y_origin) ** 2)
|
62
|
+
|
63
|
+
start_angle = Math.atan2((y_start - y_origin),(x_start - x_origin))
|
64
|
+
end_angle = Math.atan2((y_end - y_origin),(x_end - x_origin))
|
65
|
+
|
66
|
+
steps = (end_angle - start_angle) / 25
|
67
|
+
|
68
|
+
current_degrees = start_angle
|
69
|
+
|
70
|
+
25.times do
|
71
|
+
arc_line = {}
|
72
|
+
arc_line[:x] = x_origin + radius * Math.cos(current_degrees)
|
73
|
+
arc_line[:y] = y_origin + radius * Math.sin(current_degrees)
|
74
|
+
arc_line[:z] = nil
|
75
|
+
current_degrees += steps
|
76
|
+
puts "Move Arc Stepper::#{arc_line}"
|
77
|
+
move_stepper(arc_line,25)
|
78
|
+
end
|
79
|
+
|
80
|
+
|
28
81
|
else
|
29
82
|
# puts "GLINE - Something else"
|
30
83
|
end
|
@@ -60,24 +113,24 @@ module Rotor
|
|
60
113
|
|
61
114
|
if instance_variable_get(:"@#{ets}_move").to_f > instance_variable_get(:"@#{ets}") #move to the right
|
62
115
|
if instance_variable_get(:"@stepper_#{ets}") && instance_variable_get(:"@stepper_#{ets}").at_safe_area?
|
63
|
-
threads << Thread.new { instance_variable_get(:"@stepper_#{ets}").forward(
|
116
|
+
threads << Thread.new { instance_variable_get(:"@stepper_#{ets}").forward(delay, instance_variable_get(:"@#{ets}_movement")) }
|
64
117
|
end
|
65
118
|
elsif instance_variable_get(:"@#{ets}_move").to_f < instance_variable_get(:"@#{ets}") #move to the left
|
66
119
|
if instance_variable_get(:"@stepper_#{ets}") && instance_variable_get(:"@stepper_#{ets}").at_safe_area?
|
67
|
-
threads << Thread.new { instance_variable_get(:"@stepper_#{ets}").backwards(
|
120
|
+
threads << Thread.new { instance_variable_get(:"@stepper_#{ets}").backwards(delay, instance_variable_get(:"@#{ets}_movement")) }
|
68
121
|
end
|
69
122
|
end
|
70
123
|
instance_variable_set(:"@#{ets}",instance_variable_get(:"@#{ets}_move"))
|
71
124
|
end
|
72
125
|
end
|
73
126
|
|
74
|
-
puts "Moving to G#{parsed_line[:g]} #{instance_variable_get(:"@x_move")}, #{instance_variable_get(:"@y_move")}, #{instance_variable_get(:"@z_move")}"
|
127
|
+
#puts "Moving to G#{parsed_line[:g]} #{instance_variable_get(:"@x_move")}, #{instance_variable_get(:"@y_move")}, #{instance_variable_get(:"@z_move")}"
|
75
128
|
threads.each { |thr| thr.join }
|
76
129
|
end
|
77
130
|
|
78
131
|
def parse_line(line)
|
79
132
|
returned_json = {}
|
80
|
-
values = [:g,:x,:y,:z,:i,:j,:m,:f]
|
133
|
+
values = [:g,:x,:y,:z,:i,:j,:k,:m,:f]
|
81
134
|
values.each do |element|
|
82
135
|
returned_json[element] = find_value(element,line)
|
83
136
|
end
|
@@ -88,11 +141,12 @@ module Rotor
|
|
88
141
|
node = element.to_s.upcase
|
89
142
|
data = line.match /#{node}(?<data>\d+[,.]\d+)/
|
90
143
|
data ||= line.match /#{node}(?<data>\d+)/
|
144
|
+
data ||= line.match /#{node}(?<data>-\d+[,.]\d+)/
|
91
145
|
if data
|
92
146
|
case element
|
93
147
|
when :g, :m
|
94
148
|
return data[:data].to_i
|
95
|
-
when :x,:y,:z,:i,:k,:f
|
149
|
+
when :x,:y,:z,:i,:j,:k,:f
|
96
150
|
return data[:data].to_f
|
97
151
|
end
|
98
152
|
else
|
data/lib/rotor/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.00
|
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-
|
11
|
+
date: 2015-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|