Class: FB::OutgoingHandler
- Inherits:
-
Object
- Object
- FB::OutgoingHandler
- Defined in:
- lib/arduino/outgoing_handler.rb
Overview
Responsible for writing to the serial line. Sends Gcode from the pi to the arduino. (Pi -> Arduino)
Defined Under Namespace
Classes: UnhandledGcode
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
Instance Method Summary collapse
- #emergency_stop ⇒ Object
- #home_all ⇒ Object
- #home_x ⇒ Object
- #home_y ⇒ Object
- #home_z ⇒ Object
-
#initialize(bot) ⇒ OutgoingHandler
constructor
A new instance of OutgoingHandler.
- #move_relative(x: 0, y: 0, z: 0, s: 100) ⇒ Object
- #read_parameter(num) ⇒ Object
- #read_status(pin) ⇒ Object
- #write_parameter(num, val) ⇒ Object
Constructor Details
#initialize(bot) ⇒ OutgoingHandler
Returns a new instance of OutgoingHandler.
9 10 11 |
# File 'lib/arduino/outgoing_handler.rb', line 9 def initialize(bot) @bot = bot end |
Instance Attribute Details
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
5 6 7 |
# File 'lib/arduino/outgoing_handler.rb', line 5 def bot @bot end |
Instance Method Details
#emergency_stop ⇒ Object
13 14 15 16 |
# File 'lib/arduino/outgoing_handler.rb', line 13 def emergency_stop(*) bot.outbound_queue = [] # Dump pending commands. bot.serial_port.puts "E" # Don't queue this one- write to serial line. end |
#home_all ⇒ Object
34 35 36 |
# File 'lib/arduino/outgoing_handler.rb', line 34 def home_all write "G28" end |
#home_x ⇒ Object
22 23 24 |
# File 'lib/arduino/outgoing_handler.rb', line 22 def home_x write "F11" end |
#home_y ⇒ Object
26 27 28 |
# File 'lib/arduino/outgoing_handler.rb', line 26 def home_y write "F12" end |
#home_z ⇒ Object
30 31 32 |
# File 'lib/arduino/outgoing_handler.rb', line 30 def home_z write "F13" end |
#move_relative(x: 0, y: 0, z: 0, s: 100) ⇒ Object
18 19 20 |
# File 'lib/arduino/outgoing_handler.rb', line 18 def move_relative(x: 0, y: 0, z: 0, s: 100) write "G00 X#{x} Y#{y} Z#{z}" end |
#read_parameter(num) ⇒ Object
38 39 40 |
# File 'lib/arduino/outgoing_handler.rb', line 38 def read_parameter(num) write "F21 P#{num}" end |
#read_status(pin) ⇒ Object
46 47 48 |
# File 'lib/arduino/outgoing_handler.rb', line 46 def read_status(pin) write "F31 P#{pin}" end |
#write_parameter(num, val) ⇒ Object
42 43 44 |
# File 'lib/arduino/outgoing_handler.rb', line 42 def write_parameter(num, val) write "F22 P#{num} V#{val}" end |