Warning:

To protect the digital assets of creators and enhance system security and stability, the CyberBrick Multi-Function Core Board does not support firmware flashing with any third-party tools! If you need to restore the Multi-Function Core Board to its factory state, please wait for the official recovery tool to be released by CyberBrick. If you proceed to flash the firmware using third-party tools, the firmware of the Multi-Function Core Board will be permanently damaged and cannot be recovered. CyberBrick will not be responsible for any consequences resulting from such operations.

This documentation is adapted from the official MicroPython project. The CyberBrick team has extended the source code with custom interfaces and features to our hardware and application needs.

In addition to these enhancements, certain built-in MicroPython interfaces have been intentionally disabled to protect the system's integrity, and ensure the overall security and reliability of the device. This also facilitates content protection for creators' intellectual property, where applicable.

Portions of the content are derived from the official MicroPython documentation and have been included here under its open-source license to provide users with a consistent and enriched development experience tailored to the CyberBrick platform.

neopixel — control of WS2812 / NeoPixel LEDs

This module provides a driver for WS2818 / NeoPixel LEDs.

Note

This module is only included by default on the ESP8266, ESP32 and RP2 ports. On STM32 / Pyboard and others, you can either install the neopixel package using mip, or you can download the module directly from micropython-lib and copy it to the filesystem.

class NeoPixel

This class stores pixel data for a WS2812 LED strip connected to a pin. The application should set pixel data and then call NeoPixel.write() when it is ready to update the strip.

For example:

import neopixel

# 32 LED strip connected to X8.
p = machine.Pin.board.X8
n = neopixel.NeoPixel(p, 32)

# Draw a red gradient.
for i in range(32):
    n[i] = (i * 8, 0, 0)

# Update the strip.
n.write()

Constructors

class neopixel.NeoPixel(pin, n, *, bpp=3, timing=1)

Construct an NeoPixel object. The parameters are:

  • pin is a machine.Pin instance.

  • n is the number of LEDs in the strip.

  • bpp is 3 for RGB LEDs, and 4 for RGBW LEDs.

  • timing is 0 for 400KHz, and 1 for 800kHz LEDs (most are 800kHz).

Pixel access methods

NeoPixel.fill(pixel)

Sets the value of all pixels to the specified pixel value (i.e. an RGB/RGBW tuple).

NeoPixel.__len__()

Returns the number of LEDs in the strip.

NeoPixel.__setitem__(index, val)

Set the pixel at index to the value, which is an RGB/RGBW tuple.

NeoPixel.__getitem__(index)

Returns the pixel at index as an RGB/RGBW tuple.

Output methods

NeoPixel.write()

Writes the current pixel data to the strip.