class RPicSim::Mplab::MplabPin
Constants
- IoState
- PinState
Public Class Methods
new(pin_physical)
click to toggle source
Initializes a new Pin
object to wrap the given PinPhysical. @param pin_physical [com.microchip.mplab.mdbcore.simulator.PinPhysical]
# File lib/rpicsim/mplab/mplab_pin.rb, line 5 def initialize(pin_physical) raise ArgumentError, 'pin_physical is nil' if pin_physical.nil? @pin_physical = pin_physical end
Public Instance Methods
high?()
click to toggle source
Returns true if the pin is currently in a “high” state, or false if it is in a “low” state. Raises an exception if MPLAB X claims the state is neither, which we think is impossible.
# File lib/rpicsim/mplab/mplab_pin.rb, line 39 def high? pin_state = @pin_physical.get case pin_state when PinState::HIGH then true when PinState::LOW then false else raise "Invalid pin state: #{pin_state}" end end
name()
click to toggle source
# File lib/rpicsim/mplab/mplab_pin.rb, line 53 def name @pin_physical.pinName end
names()
click to toggle source
# File lib/rpicsim/mplab/mplab_pin.rb, line 49 def names @pin_physical.map(&:name) end
output?()
click to toggle source
Returns true if the pin is currently configured to be an output, or false if it is configured as an input. Raises an exception if MPLAB X claims the state is neither, which we think is impossible.
# File lib/rpicsim/mplab/mplab_pin.rb, line 26 def output? io_state = @pin_physical.getIOState case io_state when IoState::OUTPUT then true when IoState::INPUT then false else raise "Invalid IO state: #{io_state}" end end
set_analog(value)
click to toggle source
# File lib/rpicsim/mplab/mplab_pin.rb, line 18 def set_analog(value) @pin_physical.externalSetAnalogValue value end
set_high()
click to toggle source
# File lib/rpicsim/mplab/mplab_pin.rb, line 14 def set_high @pin_physical.externalSet PinState::HIGH end
set_low()
click to toggle source
# File lib/rpicsim/mplab/mplab_pin.rb, line 10 def set_low @pin_physical.externalSet PinState::LOW end