Skip to content

Better SubBladeWithList - #894

Open
NoSloppy wants to merge 31 commits into
profezzorn:masterfrom
NoSloppy:better-SubBladeWithList
Open

NoSloppy wants to merge 31 commits into
profezzorn:masterfrom
NoSloppy:better-SubBladeWithList

Conversation

@NoSloppy

@NoSloppy NoSloppy commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

I will update the POD if/when this is approved.

Basically, this update allows the user to avoid needing to fill out the SubBladeWithList with a "dummy" blade definition containing all the non-targeted pixels.
So for example, if you only want to light up 3 pixels anywhere along a 95 pixel blade, instead of needing to do the current requirement of:

#define NUM_BLADES 2

// preset with an extra "dummy" blade style here
{ "font", "track",
StylePtr<......>(),
StylePtr<Black>()  // <--- dummy
}

// blade array with tediously long dummy definition 
{ 0,
  SubBladeWithList<19, 34, 49>(WS281XBladePtr<95, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >() ),
  SubBladeWithList<0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,  20,21,22,23,24,25,26,27,28,29,30,31,32,33,  35,36,37,38,39,40,41,42,43,44,45,46,47,48,  50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94>(NULL),

  CONFIGARRAY(presets) }
  }

It can now just be

#define NUM_BLADES 1

{ "font", "track",
StylePtr<......>(),
}

{ 0,
SubBladeWithList<19, 34, 49>(WS281XBladePtr<95, bladePin, Color8::GRB, PowerPINS<bladePowerPin2, bladePowerPin3> >() ),
 CONFIGARRAY(presets) }
}

Tested and working well.

Comment thread blades/sub_blade.h Outdated
}
bool IsHandled(HandledFeature effect) override {
if (current_style_)
if (!current_style_)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was inverted and I guess just went unnoticed for a long time.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix should be in a separate PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@profezzorn profezzorn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be a one-liner....

Comment thread blades/sub_blade.h Outdated
NUM_BLADES is 1 in this example, and the style sees a blade with three LEDs.
Note that LED addresses start at zero, so LED 20 is index 19.

That means you do NOT HAVE to list all the LEDs you don't want in an extra

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to document the things you don't have to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Comment thread blades/sub_blade.h Outdated
blade = first_subblade_wrapper->blade_;
}

// Negative indices are allowed, they just mean that the LED goes nowhere.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't match the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More clear now?

Comment thread blades/sub_blade.h Outdated
// addresses a few of the LEDs. That way the LEDs which aren't part of any
// sub-blade end up dark instead of showing whatever happened to be in the
// frame buffer already.
if (blank_unused_leds_) blade_->clear();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if statement is redundant. (because Run() is only called once per subblade group.)
I think the comment is not very helpful.
Maybe say something like:

Without clearing the blade, pixels which aren't part of any subblade will get random values.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you meant the comment is redundant, and that the code is fine, hence the comment suggestion?
I changed it to // Without clearing the blade, pixels which aren't part of any subblade may get random values.
Better?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I meant the if statement is redundant, just "blade_->clear();" should be enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Yes it is. Edited.

Comment thread blades/sub_blade.h
// list, so any LED which isn't part of some sub-blade has to be turned off
// explicitly. This is set on the primary sub-blade, which is the one that
// runs all the styles in the chain.
void SetBlankUnusedLeds() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed.

Comment thread blades/sub_blade.h
Usage: SubBladeWithList<int1, int2, ...>(blade_definition)
Like SubBlade, but you provide a custom list of LED indices instead of a range.
Useful for ring-based or irregular LED layouts.
The style only sees the LEDs in the list, and every LED of the underlying blade

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a long and weird comment, why not just say:

Pixels wrapped into a subblade, but not referenced by any subblade will be black.

Comment thread blades/sub_blade.h
blade = first_subblade_wrapper->blade_;
}

// Unmapped LEDs are allowed; a negative mapping means that this

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done at compilation time.

Comment thread blades/sub_blade.h
ret->SetupSubBlade(blade, 0, count);
// first_subblade_wrapper is the primary sub-blade of this chain, and the
// one which gets to blank out the LEDs that this list doesn't cover.
first_subblade_wrapper->SetBlankUnusedLeds();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed.

Comment thread blades/sub_blade.h
SubBladeWrapper* next_;
int blade_number_;
bool primary_ = false;
bool blank_unused_leds_ = false;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed.

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.

2 participants