Skip to content

NeoPixel Ring + SH1107 auto_refresh stops working #25

Open
@mikeysklar

Description

@mikeysklar

Forum issue regarding a small neopixel ring blocking the SH1107 FeatherWing from auto_refreshing.

When the led.show() for the Neopixel is commented out the OLED updates. If led.show() is left in the code the OLED stops updating within a few iterations.

The work around was to manually call display.refresh().

Working code provided. Comment out display.refresh() reproduces issue.

+------------------------------------+-------------------------+
|               Item                 |       Description       |
+------------------------------------+-------------------------+
| Adafruit Feather STM32F405         | WO# P4382C              |
| CircuitPython                      | 9.2.4                   |
| Library Bundle                     | 20250211                |
| Neopixel Ring 12-LED               | ADA# 1643               |
| OLED 128x64  FeatherWing           | ADA# 4650               |
+------------------------------------+-------------------------+

Image

import time
import board
import displayio
from i2cdisplaybus import I2CDisplayBus
import adafruit_displayio_sh1107
from adafruit_display_text import label
import terminalio
import neopixel
import random

# Initialize sh1107 featherwing display
#time.sleep(2)

i2c = board.I2C()

WIDTH = 128
HEIGHT = 64

displayio.release_displays()
display_bus = I2CDisplayBus(i2c, device_address=0x3C)
display = adafruit_displayio_sh1107.SH1107(display_bus, width=WIDTH, height=HEIGHT)

splash = displayio.Group()
display.root_group = splash

# Palette
color_bitmap = displayio.Bitmap(128, 164, 1)
color_palette = displayio.Palette(1)  # i.e. one color
color_palette[0] = 0xFFFFFF

# Background
bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)
inner_bitmap = displayio.Bitmap(WIDTH, HEIGHT, 1)
inner_palette = displayio.Palette(1)
inner_palette[0] = 0x000000
inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=0, y=0)
splash.append(inner_sprite)

# Build display line
line_1 = label.Label(terminalio.FONT, text="", scale=1, color=0xFFFFFF)
line_1.anchor_point = (0, 0)
line_1.anchored_position = (0, 3)
splash.append(line_1)

# Initialize NeoPixel ring
leds = neopixel.NeoPixel(board.D12, 12, brightness=0.1, auto_write=False)

i = 0
leds.fill((0, 0, 0))
leds.show()

while True:
    i += 1
    print(f"Pass {i}")

    # sh1107 display
    line_1.text = f"Pass {i}"

    # Update display manually to avoid blocking
    display.refresh()

    # neopixel ring update, but only every other loop iteration
    if i % 2 == 0:
        leds.fill((0, 0, 0))
    else:
        leds[0] = (255, 0, 0)

    leds.show()

    # Adjust timing for both display and NeoPixels
    time.sleep(0.25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions