Crickit Feather - RGBW NeoPixel colors incorrect

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
beardo_tech
 
Posts: 20
Joined: Tue Sep 18, 2018 11:36 pm

Crickit Feather - RGBW NeoPixel colors incorrect

Post by beardo_tech »

Hardware: Feather nRF52840 installed on Crickit for Feather with NeoPixel Digital RGBW LED Strip - White PCB 30 LED/m Product ID: 2832 (2m - 60 neopixels). Also have motor and speaker attached.
Normal operation: When system boots, NeoPixel strip flashes red LEDs until BT connectivity established. Using Circuit Playground Bluefruit as remote, can cycle through various LED animations.
Adapted from "Circuit Playground Bluefruit NeoPixel Animation and Color Remote Control", https://learn.adafruit.com/circuit-play ... te-control. Using CPB as remote, Feather nRF52840 as main controller with Crickit.
All boards updated with latest firmware (bootloader for Feather, SeeSaw for Crickit). Using CP 7.2.5 with libraries from adafruit-circuitpython-bundle-7.x-mpy-20220519. NeoPixel strip configured with pixel order GRBW.

Case 1: NeoPixel connected to Crickit NeoPixel connector. Fail. Colors do not display correctly.
When system boots, NeoPixel strip flashes red, white, blue LEDs. Using CPB to control NeoPixel animations, crashes.
Following errors displayed in REPL (note: using print to track button and switch status):
Remote Control switch is to the left: LEDs off!
Remote Control switch is to the right: LEDs on!
B pressed: Animation change.
Traceback (most recent call last):
File "code.py", line 175, in <module>
File "adafruit_led_animation/sequence.py", line 197, in animate
File "adafruit_led_animation/animation/__init__.py", line 85, in animate
File "adafruit_led_animation/animation/chase.py", line 99, in draw
File "adafruit_led_animation/animation/chase.py", line 99, in <listcomp>
MemoryError: memory allocation failed, allocating 32768 bytes
Code snippet follows:

Code: Select all

# Parameters for externally attached NeoPixel strip
# NeoPixel Setup
NUM_NEOPIX = 60

# - SeeSaw
from adafruit_seesaw.neopixel import NeoPixel
NEOPIX_PIN = 20
PIX_ORDER = (1, 0, 2, 3) # GRBW, Also is default for "none"

# Set up NeoPixel strip on Crickit NeoPixel using Seesaw pin 20
strip_pixels = NeoPixel(crickit.seesaw, NEOPIX_PIN, NUM_NEOPIX, brightness=0.75, auto_write=False, pixel_order = PIX_ORDER)

Case 2: NeoPixel power, ground connected to Crickit NeoPixel connector. NeoPixel signal connected to Feather pin A1. Colors correct.
When system boots, NeoPixel strip flashes red LEDs.
Using CPB to control NeoPixel animations switches and displays correctly. no errors.

Code snippit:

Code: Select all

# Parameters for externally attached NeoPixel strip
# NeoPixel Setup
NUM_NEOPIX = 60

# - Feather
import neopixel
PIX_ORDER = neopixel.GRBW

# Set up NeoPixel strip on Feather pin "board.A1" used to control neopixels, 
# Cricket provides power, ground from Crickit NeoPixel.
NEOPIX_PIN = board.A1

# Create the NeoPixel strip
strip_pixels = neopixel.NeoPixel(NEOPIX_PIN, NUM_NEOPIX, brightness=0.75, auto_write=False, pixel_order=PIX_ORDER)


User avatar
danhalbert
 
Posts: 4654
Joined: Tue Aug 08, 2017 12:37 pm

Re: Crickit Feather - RGBW NeoPixel colors incorrect

Post by danhalbert »

Please try CircuitPython 7.3.0-rc.1. We fixed some things about NeoPixel timing and also about memory allocations in that release. I'm not sure they would address your problem, but I hope so.

User avatar
beardo_tech
 
Posts: 20
Joined: Tue Sep 18, 2018 11:36 pm

Re: Crickit Feather - RGBW NeoPixel colors incorrect

Post by beardo_tech »

Thanks for the response. CP 7.3.0-rc.2 was available so I updated the Feather nRF52840 main controller on Crickit. Reconfigured hardware and code to support NeoPixel strip via NeoPixel header on Crickit. Same issue with incorrect colors. Same MemoryError received.

Further troubleshooting as follows:
1. Replaced lib folders "adafruit_led_animation", "adafruit_seesaw", and file "adafruit_crickit.mpy" from zip dated "20220521". Same incorrect colors and MemoryError noted.
2. Since MemoryError appeared to be related to "adafruit_led_animation/animation/chase.py", removed animation sequence using "chase". Then received same error with other animations that used a derivation of "chase", e.g., "rainbowchase", "customcolorchase". Removed all animations related to "chase".
3. Ran program again. Received ValueError regarding "adafruit_seesaw/neopixel.py". REPL contents:
B pressed: Animation change.
Traceback (most recent call last):
File "code.py", line 186, in <module>
File "adafruit_led_animation/sequence.py", line 197, in animate
File "adafruit_led_animation/animation/__init__.py", line 85, in animate
File "adafruit_led_animation/animation/colorcycle.py", line 52, in draw
File "adafruit_seesaw/neopixel.py", line 160, in fill
File "adafruit_seesaw/neopixel.py", line 119, in __setitem__
ValueError: too many values to unpack (expected 3)
Changed code and hardware back to NeoPixel signal connected to Feather pin A1. Colors correct. No errors received.
Following is code snippet showing led animations setup:

Code: Select all

# Neopixel Animations Setup
from adafruit_led_animation.animation.blink import Blink
from adafruit_led_animation.animation.chase import Chase
from adafruit_led_animation.animation.comet import Comet
from adafruit_led_animation.animation.customcolorchase import CustomColorChase
from adafruit_led_animation.animation.rainbowchase import RainbowChase
from adafruit_led_animation.animation.solid import Solid
from adafruit_led_animation.animation.sparkle import Sparkle
from adafruit_led_animation.group import AnimationGroup
from adafruit_led_animation.sequence import AnimationSequence
#import adafruit_led_animation.color as color
from adafruit_led_animation.color import (
    WHITE, OLD_LACE, PINK, RED, AMBER, ORANGE, GOLD, YELLOW, GREEN, BLUE, PURPLE, MAGENTA,
    BLACK,
)

# Setup various LED sequences - Note different for RGB vs. RGBW
# Uncomment for RGBW/GRBW:
from adafruit_led_animation.color import RGBW_WHITE_W as WWITE # For RGBW/GRBW
Theater = Chase(strip_pixels, speed=0.05, size=3, spacing=6, color=WWITE) # For RGBW/GRBW
lightsOn = Solid(strip_pixels, color=WWITE) # For RGBW/GRBW
# For RGB:
#Theater = Chase(strip_pixels, speed=0.05, size=3, spacing=6, color=WHITE) # For RGB/GRB
#lightsOn = Solid(strip_pixels, color=WHITE) # For RGB/GRB
# For All:
Blinky = Blink(strip_pixels, speed=0.25, color=RED)
Halley = Comet(strip_pixels, speed=0.02, color=ORANGE, tail_length=10, bounce=True)
Sparkly = Sparkle(strip_pixels, speed=0.03, color=BLUE)
Zoom = Comet(strip_pixels, speed=0.02, color=ORANGE, tail_length=10, bounce=False)
RBC = RainbowChase(strip_pixels, speed=0.1, size=2, spacing=3)
CCCRB = CustomColorChase(strip_pixels, speed=0.1, size=3, spacing=3, reverse=True)
lightsOut = Solid(strip_pixels, color=BLACK)

Fire = AnimationGroup(
    Comet(strip_pixels, speed=0, tail_length=1, color=BLACK),
    Sparkle(strip_pixels, speed=0.1, num_sparkles=10, color=AMBER),
    Sparkle(strip_pixels, speed=0.2, num_sparkles=10, color=RED),
    Sparkle(strip_pixels, speed=0.1, num_sparkles=20, color=ORANGE),
    Sparkle(strip_pixels, speed=0.5, num_sparkles=5, color=GOLD),
    Sparkle(strip_pixels, speed=0.1, num_sparkles=10, color=BLACK),
    )

# Setup animations
animations = AnimationSequence(
    Blinky,
    Theater,
    Halley,
    Sparkly,
    Zoom,
    RBC,
    CCCRB,
    Fire,
    lightsOn,
    lightsOut,
)
'''
# Using Neopixel on Crickit NeoPixel header
animations = AnimationSequence(
    Blinky,    # Incorrect colors
    #Theater,  # MemoryError re. "../chase.py"
    Halley,    # Incorrect colors
    Sparkly,   # Incorrect colors
    Zoom,      # Incorrect colors
    #RBC,      # MemoryError re. "../chase.py"
    #CCCRB,    # MemoryError re. "../chase.py"
    Fire,      # Does not display at all
    #lightsOn,  # ValueError re. adafruit_seesaw/neopixel.py
    lightsOut, # Works...
)
'''
My original setup used Circuit Playground Crickit with CPB as controller with same CPB remote. No hardware mods.
Was going to reactivate and update the original configuration and see if same errors are received with that hardware configuration, but on further review the following is noted about using NeoPixels on Crickit for Circuit Playground (ref: https://learn.adafruit.com/adafruit-cri ... ickit-tour):
If you have a Circuit Playground Crickit then the NeoPixels are driven by the Circuit Playground A1 pad by default. This way you can use the MakeCode emulator and built in Circuit Playground CircuitPython library. However, if you want, you can cut the jumper underneath the Crickit and solder closed the ss pad so that the seesaw chip controls the NeoPixels (for advanced hackers only).

User avatar
beardo_tech
 
Posts: 20
Joined: Tue Sep 18, 2018 11:36 pm

Re: Crickit Feather - RGBW NeoPixel colors incorrect

Post by beardo_tech »

Some further notes to assist in troubleshooting...

Did run same code on another hardware configuration with CPB and respective Crickit (with code mods made for hardware). Noted same incorrect color issue, however the problem was that it had been configured for RGB NeoPixels, but had connected RGBW NeoPixels. The incorrect color mapping matched what was seen on Feather nRF52840 installed on Crickit for Feather using SeeSaw for NeoPixel control. Changed code for RGBW and all works correctly.

Verified on original configuration (Feather nRF52840 installed on Crickit for Feather) that I was using RGBW and the software was configured correctly.

Possible issue is that on Crickit for Feather, RGBW NeoPixels are not being processed correctly by adafruit_seesaw/neopixel.py. They are being handled as RGB, causing the incorrect color mapping, and possibly the other errors.

User avatar
danhalbert
 
Posts: 4654
Joined: Tue Aug 08, 2017 12:37 pm

Re: Crickit Feather - RGBW NeoPixel colors incorrect

Post by danhalbert »

Thanks for the possible diagnosis. We'll look at this further.

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Crickit Feather - RGBW NeoPixel colors incorrect

Post by adafruit_support_carter »

There are a lot of layers of complexity here - the BT remote, the animation library, etc.

Have you tried recreating this issue with a simple NeoPixel example? Something like this:
https://github.com/adafruit/Adafruit_Ci ... el_test.py
adapted for the pins, pixel order, etc. of your NeoPixel strip.

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Crickit Feather - RGBW NeoPixel colors incorrect

Post by adafruit_support_carter »

Actually I think maybe I'm seeing the issue. It appears you need to specify the bpp parameter as well when using RGBW NeoPixels, and set it to 4, ex:

Code: Select all

pixels = neopixel.NeoPixel(ss, 20, 12, bpp=4, pixel_order=neopixel.GRBW)
Here's a simple set of commands that can be tested at the REPL:

Code: Select all

import board
from adafruit_seesaw import seesaw, neopixel
ss = seesaw.Seesaw(board.I2C())
pixels = neopixel.NeoPixel(ss, 20, 12, bpp=4, pixel_order=neopixel.GRBW)
pixels.fill(0xFF0000)
pixels.fill(0x00FF00)
pixels.fill(0x0000FF)
Pin 20 is the NeoPixel pin on the Feather Crickit Board.
You can change 12 to whatever number of pixels are on your strip.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”