Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RGBW lights #2

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

rbndelrio
Copy link

Hey! Hope you don't mind but your fork seems to be the most updated of the bunch, but it lacked support for RGB+W Twinkly products.

tl;dr changelog:

  • adds RGBW support to Led, Frame and Movie classes
  • updated one of the example scripts
  • small type definition tweaks
  • updating tsconfig for typedef sourcemapping
  • fixing a bug or two along the way

I'll annotate the diff in a bit!

Comment on lines +18 to +23
let movie = makeMovie({
nLeds,
nFrames: nLeds + 20,
tailLength: 20,
type: details.led_profile?.toLowerCase() || 'rgb',
});
Copy link
Author

Choose a reason for hiding this comment

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

Made this function configurable so it'll match the device's specs

Copy link
Author

Choose a reason for hiding this comment

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

Oh also nFrames = nLeds + tailLength lets the tail fade out rather than cutting it off

Comment on lines +65 to +67
if (white && preserveWhite) {
this.brighten(white / 255);
}
Copy link
Author

Choose a reason for hiding this comment

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

tbf this is probably unnecessary

Comment on lines +78 to +82
return new Uint8Array(
this._type === 'rgbw'
? [this.white!, this.red, this.green, this.blue]
: [this.red, this.green, this.blue]
);
Copy link
Author

Choose a reason for hiding this comment

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

Apparently RGBW products use white as the first byte 🤷

Comment on lines +9 to +11
import { Led } from "./led";
import { Frame } from "./frame";
import { Movie } from "./movie";
Copy link
Author

Choose a reason for hiding this comment

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

Removing the .js extension throughout fixed some module resolution quirks in VSCode for me

@matthi4s
Copy link

Hey, just wanted to mention here that I made an RGBW implementation as well here: matthi4s@a886a16

I tried to avoid having to declare every LED as RGBW, so any LED, Frame or Movie can be used on RGB and RGBW devices without any further changes, you just have to declare RGBW on the device level (or even autodetect it).

Not sure really which one is the better solution. I can also create a PR for it, but #1 should be merged first.

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