可寻址LED#

介绍#

可寻址 LED 是一种可编程 RGB LED 灯条设备,它连接到 3 线端口,并允许您控制单个 LED(例如 WS2812/“NeoPixel” 型)以显示自定义颜色和图案。

本页面使用 address_led 作为可寻址 LED 的示例名称。您可以根据需要将其替换为您自己配置的名称。

以下是可用方法列表:

  • set – 设置可寻址 LED 灯条的颜色。

  • clear – 关闭整个可寻址 LED 灯条。

构造函数 – 手动初始化和配置可寻址 LED。

set#

set 将可寻址 LED 灯条设置为提供的值。

Usage:
address_led.set(data, offset)

参数

描述

data

包含 list 的 Color 值。其中包括 预定义颜色、十六进制整数 和 网页颜色。

offset

可选。LED 的起始索引,从 0 开始。

# Create a sequence of colors: Red, Green, Blue
color_list = [Color(0xFF0000), Color(0x00FF00), Color(0x0000FF)]

# Set the Addressable LED to the color_list sequence
address_led.set(color_list)

clear#

clear 关闭整个可寻址 LED 灯条。

Usage:
address_led.clear()

参数

描述

此方法没有参数。

构造函数#

构造函数用于创建 AddressableLed 对象,这些对象是配置可寻址 LED 所必需的。

AddressableLed#

AddressableLed 创建一个可寻址 LED。

Usage:
AddressableLed(port)

范围

描述

port

The 3-Wire Port that the Addressable LED strip is connected to:

  • On the V5 Brain – brain.three_wire_port.x where x is the number of the port.
  • On a 3-Wire Expander – expander.a where expander is the name of the expander instance.

# Create an Addressable LED in Port A
address_led = AddressableLed(brain.three_wire_port.a)