farmbot-serial 0.2.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/arduino.rb +8 -3
- data/lib/arduino/outgoing_handler.rb +20 -19
- 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: 63d4f03cfdeea5d307b9e4d5b9f3abff6e9c3127
|
4
|
+
data.tar.gz: 8d9afbc6a329232d9119fb792bab37b620025cfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b9aced9e498a880f65c3a1977f76f2ea7d5c38a03065f6cffebe5a5ad4648a3e9d3967f89cabf8b3651e44962e5af30b5f4beaf9ce40d052bd6842b993dc764
|
7
|
+
data.tar.gz: d6f3071f68e53b750a82af089125700cf6d6e6e2aafe4df1320fe7c9ba948a11200512a10bbb781fe08244add31a3afc8fc6862aaed6bca3bc8aeb444fb30d53
|
data/lib/arduino.rb
CHANGED
@@ -70,9 +70,14 @@ module FB
|
|
70
70
|
|
71
71
|
def pop_gcode_off_queue
|
72
72
|
gcode = @outbound_queue.pop
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
if gcode.is_a?(FB::Gcode)
|
74
|
+
serial_port.puts gcode
|
75
|
+
status[:last] = gcode.name
|
76
|
+
status[:BUSY] = 1 # If not, pi will race arduino and "talk too fast"
|
77
|
+
else
|
78
|
+
raise TypeError, "Outbound messages must be GCode objects. "\
|
79
|
+
"Use of #{gcode.class} is not permitted."
|
80
|
+
end
|
76
81
|
end
|
77
82
|
|
78
83
|
def start_event_listeners
|
@@ -16,57 +16,58 @@ module FB
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def move_relative(x: 0, y: 0, z: 0, s: 100)
|
19
|
-
write
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
write do
|
20
|
+
# TODO: At some point, I will need to figure out why this is double
|
21
|
+
# firing. In the meantime, the fix is to use `||=` instead of `=`
|
22
|
+
x1 ||= [(bot.current_position.x + (x || 0)), 0].max
|
23
|
+
y1 ||= [(bot.current_position.y + (y || 0)), 0].max
|
24
|
+
z1 ||= [(bot.current_position.z + (z || 0)), 0].max
|
25
|
+
|
26
|
+
"G00 X#{x1} Y#{y1} Z#{z1}"
|
27
|
+
end
|
27
28
|
end
|
28
29
|
|
29
30
|
def move_absolute(x: 0, y: 0, z: 0, s: 100)
|
30
|
-
write "G00 X#{x} Y#{y} Z#{z}"
|
31
|
+
write { "G00 X#{x} Y#{y} Z#{z}" }
|
31
32
|
end
|
32
33
|
|
33
34
|
def home_x
|
34
|
-
write "F11"
|
35
|
+
write { "F11" }
|
35
36
|
end
|
36
37
|
|
37
38
|
def home_y
|
38
|
-
write "F12"
|
39
|
+
write { "F12" }
|
39
40
|
end
|
40
41
|
|
41
42
|
def home_z
|
42
|
-
write "F13"
|
43
|
+
write { "F13" }
|
43
44
|
end
|
44
45
|
|
45
46
|
def home_all
|
46
|
-
write "G28"
|
47
|
+
write { "G28" }
|
47
48
|
end
|
48
49
|
|
49
50
|
def read_parameter(num)
|
50
|
-
write "F21 P#{num}"
|
51
|
+
write { "F21 P#{num}" }
|
51
52
|
end
|
52
53
|
|
53
54
|
def write_parameter(num, val)
|
54
|
-
write "F22 P#{num} V#{val}"
|
55
|
+
write { "F22 P#{num} V#{val}" }
|
55
56
|
end
|
56
57
|
|
57
58
|
def read_status(pin)
|
58
|
-
write "F31 P#{pin}"
|
59
|
+
write { "F31 P#{pin}" }
|
59
60
|
end
|
60
61
|
|
61
62
|
def pin_write(pin:, value:, mode:)
|
62
|
-
write "F41 P#{pin} V#{value} M#{mode}"
|
63
|
+
write { "F41 P#{pin} V#{value} M#{mode}" }
|
63
64
|
bot.status.set_pin(pin, value)
|
64
65
|
end
|
65
66
|
|
66
67
|
private
|
67
68
|
|
68
|
-
def write(
|
69
|
-
bot.write(
|
69
|
+
def write(&blk)
|
70
|
+
bot.write(FB::Gcode.new(&blk))
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: farmbot-serial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Evers
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|