Class: Phidgets::LED

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

Overview

This class represents a PhidgetLED.

Defined Under Namespace

Classes: LEDOuputs

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetLED

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#attached?, #attached_to_server?, attributes, #close, #detached?, #detached_to_server?, device_class, #device_class, device_id, #id, #initialize, #label, #label=, #name, #on_attach, #on_detach, #on_error, #on_server_connect, #on_server_disconnect, #on_sleep, #on_wake, #serial_number, #server_address, server_address, #server_id, server_id, server_status, #type, #version, #wait_for_attachment

Instance Attribute Details

#attributesObject (readonly)

The attributes of a PhidgetLED



16
17
18
# File 'lib/phidgets-ffi/led.rb', line 16

def attributes
  @attributes
end

#ledsLEDOuputs (readonly)

Collection of LEDs

Returns:



11
12
13
# File 'lib/phidgets-ffi/led.rb', line 11

def leds
  @leds
end

Instance Method Details

#current_limitPhidgets::FFI::LEDCurrentLimit

Returns the board current limit for all LEDs, or raises an error. Not supported on all PhidgetLEDs.

Returns:



23
24
25
26
27
# File 'lib/phidgets-ffi/led.rb', line 23

def current_limit
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getCurrentLimit(@handle, ptr)
  Phidgets::FFI::LEDCurrentLimit[ptr.get_int(0)]
end

#current_limit=(new_current_limit) ⇒ Phidgets::FFI::LEDCurrentLimit

Sets the board current limit for all LEDs, or raises an error. Not supported on all PhidgetLEDs.

Parameters:

Returns:



32
33
34
35
36
# File 'lib/phidgets-ffi/led.rb', line 32

def current_limit=(new_current_limit)
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.setCurrentLimit(@handle, Phidgets::FFI::LEDCurrentLimit[new_current_limit])
  new_current_limit
end

#voltagePhidgets::FFI::LEDVoltage

Returns the voltage level for all LEDs, or raises an error. Not supported on all PhidgetLEDs.

Returns:

  • (Phidgets::FFI::LEDVoltage)

    returns the voltage level for all LEDs, or raises an error. Not supported on all PhidgetLEDs.



39
40
41
42
43
# File 'lib/phidgets-ffi/led.rb', line 39

def voltage
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getVoltage(@handle, ptr)
  Phidgets::FFI::LEDVoltage[ptr.get_int(0)]
end

#voltage=(new_voltage) ⇒ Phidgets::FFI::LEDVoltage

Sets the voltage level for all LEDs, or raises an error. Not supported on all PhidgetLEDs.

Parameters:

Returns:



48
49
50
51
52
# File 'lib/phidgets-ffi/led.rb', line 48

def voltage=(new_voltage)
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.setVoltage(@handle, Phidgets::FFI::LEDVoltage[new_voltage])
  new_voltage
end