farmbot-serial 0.7.5 → 0.7.6
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/CONTRIBUTING.md +1 -0
- data/console.rb +14 -1
- data/lib/arduino/outgoing_handler.rb +2 -2
- data/lib/gcode.rb +3 -2
- data/spec/lib/arduino/outgoing_handler_spec.rb +13 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 401a1c1137c965d0ec54830d394d7ad3f832e57a
|
4
|
+
data.tar.gz: b4e397128ef3aecfdfe4b0268f4e7e485248c59a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c8234d5dc44d3b9445c34e0128e7ca38d81b408bf04a957d0ccfd7464c9b1acf1c22e844ec691e1559ce24d38c916eda0124721e283f9804f3f55d9652c3802
|
7
|
+
data.tar.gz: 1eb264d3282a76da3cb5123dd9a411b684c0682dabf4f61d24cf986a06a59a4e4db1fdaed56d8ad6b78d885a8a8c9af5171d704f53bb47bca861176333a55288
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
To get started, <a href="https://www.clahub.com/agreements/FarmBot/farmbot-serial">sign the Contributor License Agreement</a>.
|
data/console.rb
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
require_relative 'lib/farmbot-serial'
|
2
2
|
require 'pry'
|
3
|
+
# Defaults to '/dev/ttyACM0', can be configured.
|
3
4
|
|
4
|
-
|
5
|
+
puts """
|
6
|
+
Select a port, or press enter for '/dev/ttyACM0'
|
7
|
+
1. /dev/ttyUSB0
|
8
|
+
2. /dev/ttyACM0
|
9
|
+
"""
|
10
|
+
case gets.chomp
|
11
|
+
when "1"
|
12
|
+
port = "/dev/ttyUSB0"
|
13
|
+
else
|
14
|
+
port = "/dev/ttyACM0"
|
15
|
+
end
|
16
|
+
|
17
|
+
bot = FB::Arduino.new(serial_port: FB::DefaultSerialPort.new(port))
|
5
18
|
|
6
19
|
puts """
|
7
20
|
FARMBOT SERIAL SANDBOX. WELCOME!
|
@@ -22,7 +22,7 @@ module FB
|
|
22
22
|
# every time the value is read. For this reason, we use ||= and not =.
|
23
23
|
x1 ||= [(bot.current_position.x + (x || 0)), 0].max
|
24
24
|
y1 ||= [(bot.current_position.y + (y || 0)), 0].max
|
25
|
-
z1 ||=
|
25
|
+
z1 ||= (bot.current_position.z + (z || 0)) || 0
|
26
26
|
|
27
27
|
"G00 X#{x1} Y#{y1} Z#{z1}"
|
28
28
|
end
|
@@ -31,7 +31,7 @@ module FB
|
|
31
31
|
def move_absolute(x: 0, y: 0, z: 0, s: 100)
|
32
32
|
x = [x.to_i, 0].max
|
33
33
|
y = [y.to_i, 0].max
|
34
|
-
z =
|
34
|
+
z = z.to_i || 0
|
35
35
|
write { "G00 X#{x} Y#{y} Z#{z}" }
|
36
36
|
end
|
37
37
|
|
data/lib/gcode.rb
CHANGED
@@ -50,10 +50,11 @@ module FB
|
|
50
50
|
attr_reader :head, :tail
|
51
51
|
|
52
52
|
def initialize(str)
|
53
|
-
nodes = str.scan(
|
53
|
+
nodes = str.scan(/[a-zA-Z]+|\-?\d+/) # ["R", "-19"], ["Z", "4"]
|
54
|
+
|
54
55
|
@head, @tail = nodes.shift.to_sym, nodes.join(" ")
|
55
56
|
# Coerce to ints if possible, since serial line is all string types.
|
56
|
-
@tail = @tail.to_i if @tail.match(
|
57
|
+
@tail = @tail.to_i if @tail.match(/^\-?\d+$/)
|
57
58
|
end
|
58
59
|
|
59
60
|
def to_sym
|
@@ -26,11 +26,15 @@ describe FB::OutgoingHandler do
|
|
26
26
|
expect(bot.next_cmd.to_s).to eq("G0 X4 Y5 Z6")
|
27
27
|
end
|
28
28
|
|
29
|
-
it 'never
|
29
|
+
it 'never allows X / Y behind the 0 line' do
|
30
30
|
handler.move_relative(x: -999, y: -999, z: -999)
|
31
31
|
expect(bot.outbound_queue.first.value_of(:x)).to eq(0)
|
32
32
|
expect(bot.outbound_queue.first.value_of(:y)).to eq(0)
|
33
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'allows Z to be negative' do
|
36
|
+
handler.move_relative(z: -999)
|
37
|
+
expect(bot.outbound_queue.first.value_of(:z)).to eq(-999)
|
34
38
|
end
|
35
39
|
|
36
40
|
it 'Moves absolute' do
|
@@ -41,11 +45,16 @@ describe FB::OutgoingHandler do
|
|
41
45
|
expect(bot.next_cmd.to_s).to eq("G0 X7 Y8 Z9")
|
42
46
|
end
|
43
47
|
|
44
|
-
it 'Never
|
45
|
-
handler.move_absolute(x: -987, y: -654, z:
|
48
|
+
it 'Never sends X/Y behind 0' do
|
49
|
+
handler.move_absolute(x: -987, y: -654, z: 0)
|
46
50
|
expect(bot.next_cmd.to_s).to eq("G0 X0 Y0 Z0")
|
47
51
|
end
|
48
52
|
|
53
|
+
it 'sends Z to subzero coords' do
|
54
|
+
handler.move_absolute(x: 0, y: 0, z: -123)
|
55
|
+
expect(bot.next_cmd.to_s).to eq("G0 X0 Y0 Z-123")
|
56
|
+
end
|
57
|
+
|
49
58
|
it 'homes x, y, z, all' do
|
50
59
|
handler.home_x
|
51
60
|
expect(bot.next_cmd.to_s).to eq("F11")
|
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.7.
|
4
|
+
version: 0.7.6
|
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-
|
12
|
+
date: 2015-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
132
132
|
files:
|
133
133
|
- ".gitignore"
|
134
134
|
- ".rspec"
|
135
|
+
- CONTRIBUTING.md
|
135
136
|
- README.md
|
136
137
|
- Rakefile
|
137
138
|
- console.rb
|
@@ -177,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
178
|
version: '0'
|
178
179
|
requirements: []
|
179
180
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.4.
|
181
|
+
rubygems_version: 2.4.8
|
181
182
|
signing_key:
|
182
183
|
specification_version: 4
|
183
184
|
summary: Serial library for Farmbot
|
@@ -193,4 +194,3 @@ test_files:
|
|
193
194
|
- spec/lib/arduino_spec.rb
|
194
195
|
- spec/lib/gcode_spec.rb
|
195
196
|
- spec/spec_helper.rb
|
196
|
-
has_rdoc:
|