Class Led
Any device controlled by the generic LED driver. See https://www.kernel.org/doc/Documentation/leds/leds-class.txt for more details.
Declaration
source linkDocumentation
Methods
▶ def __init__(self, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, name_exact=False, ...) overrideinherited doc Spin through the Linux sysfs class for the device type and find a device that matches the provided name pattern and attributes (if any).
def __init__(
self,
name_pattern=SYSTEM_DEVICE_NAME_CONVENTION,
name_exact=False,
desc=None,
**kwargs,
)
This method overrides ev3dev2.Device.__init__.
- Parameters:
- class_name: class name of the device, a subdirectory of /sys/class.
For example, 'tacho-motor'.
- name_pattern: pattern that device name should match.
For example, 'sensor*' or 'motor*'. Default value: '*'.
- name_exact: when True, assume that the name_pattern provided is the
exact device name and use it directly.
- keyword arguments: used for matching the corresponding device
attributes. For example, address='outA', or driver_name=['lego-ev3-us', 'lego-nxt-us']. When argument value is a list, then a match against any entry of the list is enough.
Example:
d = ev3dev.Device('tacho-motor', address='outA')
s = ev3dev.Device('lego-sensor', driver_name=['lego-ev3-us', 'lego-nxt-us'])If there was no valid connected device, an error is thrown.
▷ def brightness(self) @property Sets the brightness level. Possible values are from 0 to ``max_brightness``.
@property
def brightness(self)
@brightness.setter
def brightness(
self,
value,
)
▷ def brightness_pct(self) @property Returns LED brightness as a fraction of max_brightness
@property
def brightness_pct(self)
@brightness_pct.setter
def brightness_pct(
self,
value,
)
▷ def delay_off(self) @property The ``timer`` trigger will periodically change the LED brightness between 0 and the current brightness setting. The ``off`` time can be specified via ``delay_off`` attribute in milliseconds.
@property
def delay_off(self)
▶ def delay_off(self, value) @delay_off.setter Workaround for ev3dev/ev3dev#225.
@delay_off.setter
def delay_off(
self,
value,
)
delay_on and delay_off attributes are created when trigger is set to timer, and destroyed when it is set to anything else. This means the file cache may become outdated, and we may have to reopen the file.
▷ def delay_on(self) @property The ``timer`` trigger will periodically change the LED brightness between 0 and the current brightness setting. The ``on`` time can be specified via ``delay_on`` attribute in milliseconds.
@property
def delay_on(self)
▷ def delay_on(self, value) @delay_on.setter @delay_on.setter
def delay_on(
self,
value,
)
▷ def max_brightness(self) @property Returns the maximum allowable brightness value.
@property
def max_brightness(self)
▶ def trigger(self) @property Sets the LED trigger. A trigger is a kernel based source of LED events.
@property
def trigger(self)
Triggers can either be simple or complex. A simple trigger isn't configurable and is designed to slot into existing subsystems with minimal additional code. Examples are the ide-disk and nand-disk triggers.
Complex triggers whilst available to all LEDs have LED specific parameters and work on a per LED basis. The timer trigger is an example. The timer trigger will periodically change the LED brightness between 0 and the current brightness setting. The on and off time can be specified via delay_{on,off} attributes in milliseconds. You can change the brightness value of a LED independently of the timer trigger. However, if you set the brightness value to 0 it will also disable the timer trigger.
▷ def trigger(self, value) @trigger.setter @trigger.setter
def trigger(
self,
value,
)
▷ def triggers(self) @property Returns a list of available triggers.
@property
def triggers(self)