Class: FB::OutgoingHandler

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#botObject (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_stopObject



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_allObject



34
35
36
# File 'lib/arduino/outgoing_handler.rb', line 34

def home_all
  write "G28"
end

#home_xObject



22
23
24
# File 'lib/arduino/outgoing_handler.rb', line 22

def home_x
  write "F11"
end

#home_yObject



26
27
28
# File 'lib/arduino/outgoing_handler.rb', line 26

def home_y
  write "F12"
end

#home_zObject



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