Skip to content

[Feature] Add color wheel to library #21

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

Open
3 tasks
totally-not-frito-lays opened this issue Mar 16, 2024 · 0 comments
Open
3 tasks

[Feature] Add color wheel to library #21

totally-not-frito-lays opened this issue Mar 16, 2024 · 0 comments
Assignees

Comments

@totally-not-frito-lays
Copy link
Member

totally-not-frito-lays commented Mar 16, 2024

Is your feature request related to a problem? Please describe.
The Color Wheel Activity is great but after discussion, @innaamogolonova and @totally-not-frito-lays decided that this function is better left blackboxed to the students. We'll migrate this into the library as a dedicated function alternative to the setColor(r,g,b).

Describe the solution you'd like
Implement / copy this into the existing library functions. We'll need changes to these files:

  • lantern.h
  • lantern.cpp
  • keywords.txt
  • in library.properties increment version by 0.1.0

Requirements

  • The color wheel can accept any number and always output a packed number to result in a color
  • There's a corresponding explanation / description in the notion page (dedicated call out block?)
  • [Activity] Add color wheel to gradient functions
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Describe alternatives you've considered
We considered leaving the implementation as a written function in examples but this is troublesome because:

  • The logic and numbers are not clear or easy for first time programmers
  • The point of a wrapper library is to abstract this logic into an easy tool to use

Additional context
Add any other context or screenshots about the feature request here.

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