Sha256: faf8a85e0922dcfa028fcfe04ec73c6bb506e9be34b028206d12e876cefcbd0d
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
module Minilab class DigitalPortIo #@private constructor :minilab_wrapper, :digital_configuration, :library_translator def configure_input_port(port) @digital_configuration.configure_port_for_input(port) end def configure_output_port(port) @digital_configuration.configure_port_for_output(port) end def read_digital(pin) check_pin_configuration(pin, :input) @minilab_wrapper.read_digital_pin(get_library_pin_number(pin)) end def write_digital(pin, value) check_pin_configuration(pin, :output) @minilab_wrapper.write_digital_pin(get_library_pin_number(pin), value) true end def read_port(port) raise "Digital port #{port} is not configured for input." unless @digital_configuration.is_port_configured_for_input?(port) @minilab_wrapper.read_port(@library_translator.get_library_port(port)) end private def get_library_pin_number(pin) @library_translator.get_library_pin_number(pin) end def check_pin_configuration(pin, type) port = @library_translator.get_port_for_pin(pin) unless @digital_configuration.send("is_port_configured_for_#{type}?", port) raise "Digital port #{port} for pin #{pin} is not configured for #{type}." end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minilab-2.0.1-x86-mingw32 | lib/minilab/digital_port_io.rb |