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.

LEDController

class bbl.leds.LEDController(led_channel, *args, **kwargs)[source]

Bases: object

A singleton class to control an LED.

__init__(led_channel)[source]

Initializes the LEDController instance for controlling an LED based on the specified channel. This method sets up the LED effects, initializes the current effect index, repeat count, duration, and start time. It then maps the provided LED channel to its corresponding pin number and initializes the NeoPixel object.

Parameters:

led_channel (str) – The channel number of the LED, either “LED1” or “LED2”.

Raises:

ValueError – If the provided led_channel is not “LED1” or “LED2”.

Example

>>> led_controller = LEDController("LED1")
>>> # The LEDController instance is now initialized with LED1's pin configuration.

Note

The led_channel parameter should be a string matching either “LED1” or “LED2”. The actual pin numbers for “LED1” and “LED2” are defined in the led_pins_map dictionary. The NeoPixel object is initialized with the pin number and the number of LEDs (4 in this case).

See also

NeoPixel: The class used to control the NeoPixel LED strip.

reinit()[source]
set_led_effect(mod, duration, repeat_count, led_index, rgb)[source]

Sets the LED effect. This method configures the LED with the specified effect, duration, repeat count, LED index, and RGB color.

Parameters:
  • mod (int) – The index of the effect to set. - mod = 0: solid effect - mod = 1: blink effect - mod = 2: breathing effect

  • duration (int) – The duration of the effect in milliseconds.

  • repeat_count (int) – The number of times to repeat the effect. Must be between 0 and 255. A value of 255( 0xFF ) represents infinite repetition.

  • led_index (int) – The index of the LED to control. Each bit represents the index of an LED (e.g., the first bit represents OUT1, the second bit represents OUT2).

  • rgb (int) – The RGB color value of the LED in hexadecimal.

Returns:

None

Raises:

ValueError – If mod, repeat_count, or led_index is out of range, or if rgb is not a valid hexadecimal color code.

Example

>>> # Solid red on LED1 for 1 second
>>> set_led_effect(0, 1000, 5, 0b0001, 0xFF0000)
>>> # Blink green on LED1 and LED2 indefinitely
>>> set_led_effect(1, 500, 255, 0b0011, 0x00FF00)
timing_proc()[source]

Callback function to update the LED effect. This method is called at regular intervals to update the current LED effect.

Parameters:

None

Returns:

None

class bbl.leds.NeoPixel(pin, n, bpp=3, timing=1)[source]

Bases: object

ORDER = (1, 0, 2, 3)
__init__(pin, n, bpp=3, timing=1)[source]
fill(v)[source]
write()[source]