Class: HackyHAL::DeviceControllers::IoGearAviorHdmiSwitch
- Inherits:
-
GenericSerialPort
- Object
- Base
- GenericSerialPort
- HackyHAL::DeviceControllers::IoGearAviorHdmiSwitch
- 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
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ IoGearAviorHdmiSwitch
constructor
A new instance of IoGearAviorHdmiSwitch.
- #set_input(value) ⇒ Object
- #set_power_on_detection(value) ⇒ Object
- #switch_to_next_input ⇒ Object
- #switch_to_previous_input ⇒ Object
Methods inherited from GenericSerialPort
#disconnect, #read_command, #serial_port, #write_command
Methods inherited from Base
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( = {}) [:serial_options] = SERIAL_PORT_OPTIONS super() 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_input ⇒ Object
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_input ⇒ Object
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 |