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

Should LED default to PWM #69

Open
dtex opened this issue Jul 13, 2020 · 2 comments
Open

Should LED default to PWM #69

dtex opened this issue Jul 13, 2020 · 2 comments

Comments

@dtex
Copy link
Owner

dtex commented Jul 13, 2020

Whether an LED can do PWM values depends on the IO it is driving. When a user instantiates an LED without specifying an IO, we assume it will be on builtin/digital. i.e.:

const blinker = await new LED(12); // uses builtin/digital
const pulser = await new LED({ pin: 14, IO: "builtin/pwm" });

Should it be the other way around?

@phoddie
Copy link
Contributor

phoddie commented Jul 13, 2020

One detail to consider: PWM is a limited resource on some hosts. The ESP32, for example, as a limited number of PWM channels. You probably don't want to silently use those up on instances that only need digital (on/off).

If they don't specify the IO, could you take that as a signal that a it is acceptable to change the IO after instantiation? Then you can default to digital and upgrade to PWM if needed.

@dtex
Copy link
Owner Author

dtex commented Jul 13, 2020

That makes sense. If they don't explicitly choose a provider or pass in an IO, we assume Digital. If a call is made to a method that requires PWM, we destroy and reopen the IO instance as PWM.

I'll give it a shot.

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

No branches or pull requests

2 participants