Skip to content

ws2812: add brightness control#854

Open
gandarez wants to merge 1 commit intotinygo-org:devfrom
gandarez:feat/ws2812-brightness
Open

ws2812: add brightness control#854
gandarez wants to merge 1 commit intotinygo-org:devfrom
gandarez:feat/ws2812-brightness

Conversation

@gandarez
Copy link
Copy Markdown
Contributor

@gandarez gandarez commented Apr 7, 2026

Summary

  • Adds a SetBrightness(b uint8) method to Device for global brightness control (0–255, default 255)
  • Introduces applyBrightness() helper that scales RGB channels using integer math (uint16 multiply + bit shift to avoid float ops)
  • Updates writeColorsRGB, writeColorsRGBA, and the RP2040/RP2350 PIO path to apply brightness before writing each color
  • brightness field defaults to 255 (full brightness), ensuring backwards-compatible behavior for existing users

Test plan

  • Flash to a WS2812 LED strip and verify full brightness at 255
  • Call SetBrightness(128) and confirm ~50% perceived brightness
  • Call SetBrightness(0) and confirm LEDs are off
  • Verify SK6812 RGBW strips: alpha channel is passed through unchanged (not dimmed)
  • Verify RP2040/RP2350 PIO path applies brightness correctly via ws.PutRGB

@gandarez gandarez changed the base branch from release to dev April 7, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant