B4R Library Adafruit_Neopixel - Based on V1.15.2 (Release date 15/10/2025)

Hello Everyone,
I wanted a few extra functions in the Adafruit Neopixel libraries on the forum, so instead of editing one of them and adding the functions, I decided to rewrap the latest Adafruit NeoPixel Library on Github. Another reason why I wrapped this library was because I thought that I was having issues with the current libraries, which in fact turned out to be a simple coding error on my behalf :rolleyes:
Anyway, I added some extra functions that might come in handy for B4R developers.

B4R library tab
1769864819146.png


3 IDE build options in example
1769864430058.png


Animation included in example
1000090998.gif


Animation included in example
ezgif-33470c6e6470262e.gif


rAda_NeoPixel

Author:
Peter Simpson
Version: 1.20
  • Ada_NeoPixel
    Wrapper for Adafruit NeoPixel (WS2812 / WS2812B) LED strips and matrices.
    Provides pixel‑level control, brightness management, and colour helpers.
    • Functions:
      • AnimatePixelColor (Start As UInt, Finish As UInt, Colour As ULong, Delay As UInt)
        Animates a pixel sequence from Start to Finish.
        Start The first pixel index.
        Finish The last pixel index.
        Colour The packed colour value.
        Delay Time each pixel stays lit (ms).
      • Begin
        Prepares the NeoPixel driver for operation.
        Must be called after Initialize before any pixel updates.
      • Clear
        Clears the internal pixel buffer (sets all LEDs to off).
        Call Show afterwards to apply the change to the LEDs.
      • DimPixel (Colour As ULong, Percent As Byte) As ULong
        Scales a packed colour by Percent (0‑100) and returns the new packed colour.
        Colour The packed colour value.
        Percent The brightness percentage (0‑100).
      • FadePixel (Index As UInt, Colour As ULong, Steps As UInt, DelayMs As UInt)
        Fades a pixel from its current colour to Colour.
        Index The pixel index.
        Colour The target packed colour.
        Steps Number of interpolation steps.
        DelayMs Delay between steps in milliseconds.
      • Fill (Colour As ULong, First As UInt, Count As UInt)
        Fills a range of pixels with a single packed colour.
        Colour The packed colour value.
        First The starting pixel index.
        Count The number of pixels to fill.
      • GetBrightness As Byte
        Returns the current global brightness level.
        Returns A value between 0 and 255.
      • GetNumPixels As UInt
        Returns the number of pixels configured during Initialize().
      • GetPixelColor (Index As UInt) As ULong
        Returns the packed 32‑bit colour value of a pixel.
        Index The pixel index (0‑based).
        Returns The packed colour value.
      • Initialize (NumberOfPixels As UInt, Pin As Byte, PixelType As ULong)
        Initialises the NeoPixel strip or matrix.
        NumberOfPixels The total number of LEDs in the strip or matrix.
        Pin The GPIO pin used for the NeoPixel data line.
        PixelType The pixel format flags such as NeoGRB + NeoKHZ800.
      • MovePixel (From As UInt, To As UInt)
        Moves a pixel from one index to another.
        From The source pixel index.
        To The destination pixel index.
      • Neo_GRB As ULong
        Returns the GRB colour order flag.
        Use this for WS2812B and most modern NeoPixel strips.
      • Neo_KHZ400 As ULong
        Returns the 400 KHz timing flag.
        Used by older WS2811‑based strips.
      • Neo_KHZ800 As ULong
        Returns the 800 KHz timing flag.
        Required for WS2812 / WS2812B LEDs.
      • Neo_RGB As ULong
        Returns the RGB colour order flag.
        Used by some older or non‑standard LED strips.
      • ScrollText (Text As String, Colour As ULong, SpeedMs As UInt)
        Scrolls text across an 8‑row matrix
        Basic (a-z, A‑Z, 0‑9, space, ASCII 32–47, 58–64 and 91–96).
        Text The null‑terminated string to scroll.
        Colour The packed colour to use.
        SpeedMs Delay between column shifts in milliseconds.
      • SetBrightness (Brightness As Byte)
        Sets the global brightness level.
        Brightness A value from 0 (off) to 255 (maximum brightness).
        Note: This does not modify stored pixel colours.
      • SetPixelColor (Index As UInt, Red As Byte, Green As Byte, Blue As Byte)
        Sets the RGB colour of a single pixel.
        Index The pixel index (0‑based).
        Red The red component (0‑255).
        Green The green component (0‑255).
        Blue The blue component (0‑255).
      • SetPixelColorPacked (Index As UInt, Colour As ULong)
        Sets a pixel using a packed 32‑bit colour value.
        Index The pixel index (0‑based).
        Colour The packed colour created by Color() or ColorW().
      • SetPixelColorW (Index As UInt, Red As Byte, Green As Byte, Blue As Byte, White As Byte)
        Sets the RGBW colour of a single pixel.
        Index The pixel index (0‑based).
        Red The red component (0‑255).
        Green The green component (0‑255).
        Blue The blue component (0‑255).
        White The white component (0‑255) for RGBW strips.
      • SetRGB (Red As Byte, Green As Byte, Blue As Byte) As ULong
        Creates a packed RGB colour value.
        Red The red component (0‑255).
        Green The green component (0‑255).
        Blue The blue component (0‑255).
      • SetRGBW (Red As Byte, Green As Byte, Blue As Byte, White As Byte) As ULong
        Creates a packed RGBW colour value.
        Red The red component (0‑255).
        Green The green component (0‑255).
        Blue The blue component (0‑255).
        White The white component (0‑255).
      • Show
        Sends the internal pixel buffer to the LEDs.
        Call this after modifying pixel colours to update the display.

Update: V1.20
  • ScrollText
  • SetPixelColorPacked
  • DimPixel
  • FadePixel
  • SetRGBW
D = 51, 56

Enjoy...
 

Attachments

  • rAda_NeoPixel.zip
    2.1 KB · Views: 38
  • rAda_NeoPixel_Lib.zip
    4.8 KB · Views: 42
Last edited:
Top