Class: HackyHAL::DeviceControllers::IoGearAviorHdmiSwitch

Inherits:
GenericSerialPort show all
Defined in:
lib/hacky_hal/device_controllers/io_gear_avior_hdmi_switch.rb

Constant Summary collapse

SERIAL_PORT_OPTIONS =
{
  baud_rate: 19200,
  data_bits: 8,
  stop_bits: 1,
  parity: SerialPort::NONE,
  flow_control: SerialPort::NONE
}

Constants inherited from GenericSerialPort

GenericSerialPort::DEFAULT_COMMAND_TIMEOUT, GenericSerialPort::DEFAULT_OPTIONS, GenericSerialPort::MAX_READ_WRITE_RETRIES

Instance Attribute Summary

Attributes inherited from GenericSerialPort

#serial_device_path, #serial_options

Attributes included from Options

#options

Instance Method Summary collapse

Methods inherited from GenericSerialPort

#disconnect, #read_command, #serial_port, #write_command

Methods inherited from Base

#log

Methods included from Options

#[]

Constructor Details

#initialize(options = {}) ⇒ IoGearAviorHdmiSwitch

Returns a new instance of IoGearAviorHdmiSwitch.



15
16
17
18
# File 'lib/hacky_hal/device_controllers/io_gear_avior_hdmi_switch.rb', line 15

def initialize(options = {})
  options[:serial_options] = SERIAL_PORT_OPTIONS
  super(options)
end

Instance Method Details

#set_input(value) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hacky_hal/device_controllers/io_gear_avior_hdmi_switch.rb', line 20

def set_input(value)
  unless value.is_a?(Fixnum)
    raise ArgumentError, "Input value must be an integer."
  end

  unless value > 0
    raise ArgumentError, "Input value must be positive."
  end

  value = value.to_s.rjust(2, "0")
  write_command("sw i#{value}")
  read_command
end

#set_power_on_detection(value) ⇒ Object



44
45
46
47
48
# File 'lib/hacky_hal/device_controllers/io_gear_avior_hdmi_switch.rb', line 44

def set_power_on_detection(value)
  value = value ? "on" : "off"
  write_command("pod #{value}")
  read_command
end

#switch_to_next_inputObject



34
35
36
37
# File 'lib/hacky_hal/device_controllers/io_gear_avior_hdmi_switch.rb', line 34

def switch_to_next_input
  write_command("sw +")
  read_command
end

#switch_to_previous_inputObject



39
40
41
42
# File 'lib/hacky_hal/device_controllers/io_gear_avior_hdmi_switch.rb', line 39

def switch_to_previous_input
  write_command("sw -")
  read_command
end