Class: Phidgets::LED::LEDOuputs

Inherits:
Object
  • Object
show all
Defined in:
lib/phidgets-ffi/led.rb

Overview

This class represents an led for a PhidgetLED. All the properties of an led are stored and modified in this class.

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetLED

Instance Method Summary collapse

Instance Method Details

#brightnessFloat

Returns the brightness level of an LED, or raises an error.

Returns:

  • (Float)

    returns the brightness level of an LED, or raises an error.



75
76
77
78
79
# File 'lib/phidgets-ffi/led.rb', line 75

def brightness
  ptr = ::FFI::MemoryPointer.new(:double)
  Klass.getBrightness(@handle, @index, ptr)
  ptr.get_int(0)
end

#brightness=(new_brightness) ⇒ Float

Sets the brightness level of an LED, or raises an error. Brightness levels range from 0-100

Parameters:

  • new_brightness (Float)

    new brightness

Returns:

  • (Float)

    returns the brightness of an LED, or raises an error.



84
85
86
87
# File 'lib/phidgets-ffi/led.rb', line 84

def brightness=(new_brightness)
  Klass.setBrightness(@handle, @index, new_brightness.to_f)
  new_brightness.to_f
end

#current_limitFloat

Returns the current limit of an LED, or raises an error.

Returns:

  • (Float)

    returns the current limit of an LED, or raises an error.



90
91
92
93
94
# File 'lib/phidgets-ffi/led.rb', line 90

def current_limit
  ptr = ::FFI::MemoryPointer.new(:double)
  Klass.getCurrentLimitIndexed(@handle, @index, ptr)
  ptr.get_int(0)
end

#current_limit=(new_current_limit) ⇒ Float

Sets the current limit of an LED, or raises an error. Current Limit levels range from 0-80 mA

Parameters:

  • new_current_limit (Float)

    new current limit

Returns:

  • (Float)

    returns the current limit of an LED, or raises an error.



99
100
101
102
# File 'lib/phidgets-ffi/led.rb', line 99

def current_limit=(new_current_limit)
  Klass.setCurrentLimitIndexed(@handle, @index, new_current_limit.to_f)
  new_current_limit.to_f
end

#indexInteger

Returns the index of the led, or raises an error.

Returns:

  • (Integer)

    returns the index of the led, or raises an error.



70
71
72
# File 'lib/phidgets-ffi/led.rb', line 70

def index 
	@index
end

#inspectObject

Displays data for an led.



65
66
67
# File 'lib/phidgets-ffi/led.rb', line 65

def inspect
     "#<#{self.class} @index=#{index}, @brightness=#{brightness}>"
end