devctrl.devices.led_controller.impl.thorlabs_ledd1b.LEDD1B#

class LEDD1B(port='COM4')[source]#

Bases: LedController

Control Thorlabs LEDD1B LED driver using an Arduino Nano

The Arduino must have the correct software loaded on it. See the arduino-thorlabs-ledd1b project directory for details.

Parameters:

port – Serial port name (default: “COM4”)

Methods

add_device

Manually add a specific device.

allow_only_dummy_devices

check_has_correct_software

Verify the Arduino has the correct software loaded

connect

connect_device

Connect to a LEDD1B LED controller

connect_dummy

Connect an instance of the device's dummy implementation

get_base_classes

Return a flat dictionary of all base classes below this class :param recurse: If True, recursively search for base classes :return: dict of {class name: class}

get_brightness_percent

Get the current brightness percentage

get_capabilities

Get controller capabilities

get_current_A

get_device_name

get_device_type_name

get_led_name

get_mode

Query the current device operating mode

get_status

Query the status of the device and return a string describing errors.

is_connected

Check if the Arduino is connected and responding

list_devices

Get a list of all devices for this type.

off

Set the LED brightness to 0%

on

Set the LED brightness to 100%

read

Read response lines from the Arduino

set_brightness_percent

Set the LED brightness percentage

set_current_A

set_mode

Set the device operating mode

Attributes

BRIGHTNESS_ON_OFF = 2#
BRIGHTNESS_PERCENT = 1#
VALID_BRIGHTNESS_PERCENT = (0, 100)#
_CLASS_TYPE = 'implementation'#
__abstractmethods__ = frozenset({'get_mode', 'set_mode'})#
__annotations__ = {'_manual_devices': list[str]}#
__del__()[source]#
__dict__ = mappingproxy({'__module__': 'devctrl.devices.led_controller.impl.thorlabs_ledd1b', '__firstlineno__': 13, '__doc__': 'Control Thorlabs LEDD1B LED driver using an Arduino Nano\n\nThe Arduino must have the correct software loaded on it.\nSee the arduino-thorlabs-ledd1b project directory for details.\n\n:param port: Serial port name (default: "COM4")\n', '_CLASS_TYPE': 'implementation', '__init__': <function LEDD1B.__init__>, '__del__': <function LEDD1B.__del__>, 'check_has_correct_software': <function LEDD1B.check_has_correct_software>, 'is_connected': <function LEDD1B.is_connected>, '_write': <function LEDD1B._write>, 'read': <function LEDD1B.read>, 'on': <function LEDD1B.on>, 'off': <function LEDD1B.off>, 'set_brightness_percent': <function LEDD1B.set_brightness_percent>, 'get_brightness_percent': <function LEDD1B.get_brightness_percent>, '__repr__': <function LEDD1B.__repr__>, 'get_capabilities': <function LEDD1B.get_capabilities>, '_enumerate_devices': <classmethod(<function LEDD1B._enumerate_devices>)>, 'connect_device': <classmethod(<function LEDD1B.connect_device>)>, '__static_attributes__': ('arduino', 'level', 'port'), '__abstractmethods__': frozenset({'set_mode', 'get_mode'}), '_abc_impl': <_abc._abc_data object>, '_children': {}, '_manual_devices': []})#
__firstlineno__ = 13#
__init__(port='COM4')[source]#
__module__ = 'devctrl.devices.led_controller.impl.thorlabs_ledd1b'#
__repr__() str[source]#
Returns:

Formatted string with device model and port

__slots__ = ()#
__static_attributes__ = ('arduino', 'level', 'port')#
__weakref__#

list of weak references to the object

_abc_impl = <_abc._abc_data object>#
_children = {}#
_dummies_only = False#
classmethod _enumerate_devices() list[str][source]#

Enumerate available LEDD1B devices

Scans serial ports for Arduino devices matching the expected criteria.

Returns:

List of available serial port names

_manual_devices: list[str] = []#
_write(val)[source]#

Send a command to the Arduino

Parameters:

val – Command string to send

classmethod add_device(connect_info)#

Manually add a specific device. The device will show up when list_devices() is called for the device type. Call this from the device class implementation, e.g. use ModelXYZ9000.add_device(‘GPIB:1234:5678’) to add a specific device with a fixed GPIB address. This is useful when automatic discovery is undesired/impossible, either because it is not implemented or it disturbs other devices which can’t handle a identification request. :param cls: The device implementation class :param connect_info: A string argument that is passed to the connect() method of the device implementation, when the device is being connected.

static allow_only_dummy_devices()#
check_has_correct_software(no_error=False)[source]#

Verify the Arduino has the correct software loaded

Runs the identify command and raises an exception if the Arduino does not reply with the expected output string.

Parameters:

no_error – If True, don’t raise exception on error

Raises:

ConnectionError – If Arduino doesn’t have expected software

classmethod connect(device_type_name: str, device_name: str | None, **kwargs) Device#
Parameters:
  • device_type_name – The name of the device class

  • device_name – The name of the device class

classmethod connect_device(device_name: str) LEDD1B[source]#

Connect to a LEDD1B LED controller

Creates a new LEDD1B instance connected to the specified serial port.

Parameters:

device_name – Serial port name

Returns:

Configured LEDD1B instance

classmethod connect_dummy(**kwargs) Device#

Connect an instance of the device’s dummy implementation

classmethod get_base_classes(recurse=True) dict[str, type[Device]]#

Return a flat dictionary of all base classes below this class :param recurse: If True, recursively search for base classes :return: dict of {class name: class}

get_brightness_percent()[source]#

Get the current brightness percentage

Returns:

Current brightness level (0 or 100)

Raises:

RuntimeError – If brightness was never set

get_capabilities() int[source]#

Get controller capabilities

Returns a bitmask indicating supported features.

Returns:

Capabilities bitmask (BRIGHTNESS_ON_OFF)

get_current_A()#
classmethod get_device_name() str#
Returns:

The specific type name of the device, e.g., SR830 or Keithly2600

classmethod get_device_type_name() str#
Returns:

The general type name of the device, e.g., Lock-In Amplifier or Voltmeter

get_led_name() None | str#
abstractmethod get_mode() str#

Query the current device operating mode

Returns:

Current mode identifier string

get_status() str#

Query the status of the device and return a string describing errors. If everything is ok, empty string must be returned :return: String of device status

is_connected() bool[source]#

Check if the Arduino is connected and responding

Sends an identify command to verify communication.

Returns:

True if Arduino responds, False otherwise

classmethod list_devices() list[tuple[str, str]]#

Get a list of all devices for this type. The list made up of: - Manually added devices - Available devices (those returned by _enumerate_devices) - A dummy device (if a dummy implementation exists) - List of all devices of child classes

Returns:

list of available devices

off()[source]#

Set the LED brightness to 0%

on()[source]#

Set the LED brightness to 100%

read()[source]#

Read response lines from the Arduino

Returns:

List of response lines

set_brightness_percent(level: int)[source]#

Set the LED brightness percentage

This controller only supports 0% or 100% brightness.

Parameters:

level – Brightness level (0 or 100)

Raises:

ValueError – If level is not 0 or 100

set_current_A(current_A: float)#
abstractmethod set_mode(mode: str)#

Set the device operating mode

Parameters:

mode – Mode identifier string