Repository navigation
Conversation
Image, Scrolling Text, Morse (user_fx) and the pov_display usermod used the
segment name as their file name / text. Segments now have a separate effect
text ("txt" in the JSON API), declared as the 9th entry of the effect
metadata slider group and shown as a text box in the UI.
Presets and API calls without "txt" are migrated on load: the name is copied
when the effect declares a text parameter and the call is a preset or also
sets "fx", so plain renames only change the label.
Also clears name/pixels after memcpy in the Segment copy assignment, which
left them aliased to the source on the early return for inactive segments.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several effects use the segment name as a hidden string parameter. This PR gives segments a separate effect text parameter (
"txt"in the JSON API). Effects declare it in their metadata, and the UI shows a text box for it only for effects that use it. Old presets and API calls keep working: they are migrated as they are loaded, sopresets.jsonis never rewritten.Why
These all use
seg.nameas effect input today:#TIME-style tokensuser_fx)pov_displayusermod.bmpfilenameBecause the name means two things, a user label and effect data:
fire.gifcan't also be called "Hallway"."n", which is how GIF presets work today, but it also means a "Solid red" preset resets your segment labels.What changed
Segment (
FX.h,FX_fcn.cpp)char *fxText. Likename, it is heap-allocated only when set, and limited toWLED_MAX_FXTEXT_LEN(defaults toWLED_MAX_SEGNAME_LEN, so 32 bytes on ESP8266 and 64 on ESP32).getSize().setFxText()does nothing when the text is unchanged. It starts the Scrolling Text transition, whichsetName()used to do.WS2812FX::service()andblendSegment()now comparefxTextinstead ofname.Effect metadata
"Image@!,Blur,,,,,,,File;;;12;...".effectHasFxText(mode)inutil.cppchecks for it.JSON / presets (
json.cpp)"txt"is serialised next to"n". Presets always contain it (""when unset), so loading a preset never keeps a stale text."txt"is absent,"n"is present, the effect declares a text parameter, and the call is a preset or also sets"fx", the name is copied into the text.{"fx":53,"n":"fire.gif"}keep working.{"n":"Hallway"}without"fx") only changes the label.rptalready keeps every key except"n", so repeated segments now get the text as well.stateChanged.Effects and usermods
user_fx) andpov_displayreadfxTextand declare the field ("File" or "Text").WLED_MAX_FXTEXT_LEN.pov_displayREADME is updated.udp_name_syncis unchanged: it still syncs the main segment's name.UI (
index.htm,index.js,index.css){"seg":{"txt":...}}to the selected segments.User-visible changes
fx) copies the name across."n"without"fx"must send"txt"instead."txt":"", about 9 bytes).Not in this PR (follow-ups to discuss)
"n"only with "save segment bounds" (sb), so effect presets stop renaming segments. This is a separate user-visible decision.Also fixed
Segment::operator=(const Segment&)leftnameandpixelspointing at the source's buffers when it returned early for an inactive source (!stop), which could cause a double free. It now clears those pointers right after thememcpy, as the copy constructor already does.Testing
npm run build, thennpm test: 16/16 pass.nodemcuv2,esp32devandesp32s3dev_8MB_opi, plusesp32devwithcustom_usermods = user_fx pov_displayandnodemcuv2withuser_fx(local override, not committed).rpt.This PR is AI-assisted (Claude Code). The new code is marked with
// AI:comments; the remaining one-line pointer handling changes inFX_fcn.cppfollow the existingnamehandling. Everything was reviewed against the source and build-tested as above.🤖 Generated with Claude Code