farmbot-serial 0.2.2 → 0.2.3

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: baebe8a0cfa185dafd4fbe91636c72f455e5aed2
4
- data.tar.gz: d0b77fa227cbdf5c28b4800446f107d8063e28b6
3
+ metadata.gz: 7ab299472231f9765ad9f25cf45fbc9ee02a8daf
4
+ data.tar.gz: 61cdd2c8d32a6d5faea497d335b217c1113b4335
5
5
  SHA512:
6
- metadata.gz: b7ec31f6cc54759f023c1b42e6001025c78714ba5a9b60198b9959140f9e30bbc8473f79f2ccc1728576e20471692afe4b56df6f9aad8e1963a6fa081e439da7
7
- data.tar.gz: d19e8921f94dc79f4c15418318f7d1a239ac8d53d3cea335daadc93ee08a9430f43d640c54c2f49ab29e76094c5fc8f118015f414d6204c33c091ab834f4248a
6
+ metadata.gz: 736508d897f2f552e277fbc3713eccab3075b3e73896177ba3c534e55750dbb31b0b08597d81cadd9150ee20eb78641b12d3d2fc365303cb2664c5740bd9d2ee
7
+ data.tar.gz: fd005c33a0519e801ef33ce4531ed1a474371f4c936b31860c2d50e57a1a7be5d52415eb5baada1b0fe8391390c8d8770dfd8ca6a904e5a210d905ccf7fac1e6
@@ -20,7 +20,6 @@ module FB
20
20
  end
21
21
 
22
22
  def report_parameter_value(gcode)
23
- # This is not correct. We need to store pin values in an array somewhere.
24
23
  bot.status.gcode_update(gcode)
25
24
  end
26
25
 
@@ -33,7 +32,7 @@ module FB
33
32
  end
34
33
 
35
34
  def report_status_value(gcode)
36
- bot.status.gcode_update(gcode)
35
+ bot.status.set_pin(gcode.value_of(:P), gcode.value_of(:V))
37
36
  end
38
37
 
39
38
  def received(gcode)
@@ -11,6 +11,7 @@ module FB
11
11
  end
12
12
 
13
13
  def emergency_stop(*)
14
+ # This message is special- it is the only method that bypasses the queue.
14
15
  bot.outbound_queue = [] # Dump pending commands.
15
16
  bot.serial_port.puts "E" # Don't queue this one- write to serial line.
16
17
  bot.status[:last] = :emergency_stop
@@ -1,9 +1,7 @@
1
1
  module FB
2
2
  class Status
3
3
  # Map of informational status and default values for status within Arduino.
4
- DEFAULT_INFO = {X: 0, Y: 0, Z: 0, S: 10, Q: 0, T: 0, C: '', P: 0, V: 0,
5
- W: 0, L: 0, E: 0, M: 0, XA: 0, XB: 0, YA: 0, YB: 0, ZA: 0,
6
- ZB: 0,YR: 0, R: 0, BUSY: 1, LAST: 'none'}
4
+ DEFAULT_INFO = {X: 0, Y: 0, Z: 0, S: 10, BUSY: 1, LAST: 'none', PINS: {}}
7
5
  Info = Struct.new(*DEFAULT_INFO.keys)
8
6
 
9
7
  def initialize
@@ -36,7 +34,10 @@ module FB
36
34
 
37
35
  def gcode_update(gcode)
38
36
  transaction do
39
- gcode.params.each { |p| @info.send("#{p.head}=", p.tail) }
37
+ gcode.params.each do |p|
38
+ setter = "#{p.head}="
39
+ @info.send(setter, p.tail) if @info.respond_to?(setter)
40
+ end
40
41
  end
41
42
  end
42
43
 
@@ -47,5 +48,14 @@ module FB
47
48
  def ready?
48
49
  self[:BUSY] == 0
49
50
  end
51
+
52
+ def pin(num)
53
+ @info[:PINS][num] || :unknown
54
+ end
55
+
56
+ def set_pin(num, val)
57
+ val = [true, 1, '1'].include?(val) ? :on : :off
58
+ transaction { |info| info.PINS[num] = val }
59
+ end
50
60
  end
51
61
  end
@@ -38,6 +38,10 @@ module FB
38
38
  GcodeToken.new(cmd.any? ? cmd.first : "NULL0")
39
39
  end
40
40
 
41
+ def value_of(param)
42
+ params.find{ |p| p.head == param.to_sym.upcase }.tail
43
+ end
44
+
41
45
  # A head/tail pair of a single node of GCode. Ex: R01 = [:R, '01']
42
46
  class GcodeToken
43
47
  attr_reader :head, :tail
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Evers