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

Tweak the Christmas animation effect to be less harsh on the eyes #7648

Merged
merged 5 commits into from
Jul 25, 2020

Conversation

Maxr1998
Copy link
Contributor

@Maxr1998 Maxr1998 commented Dec 15, 2019

Description

I found that the Christmas animation is a bit harsh on the eyes, jumping directly from red to green and back, and I thought it would be a good idea to make the effect a bit smoother (especially it's Christmas we're talking about, a rather calm & cozy holiday).

So, my idea generally was to, instead of "jumping" between the colors, I use a cubic-bezier formula to animate over the colors in between (e.g. orange, yellow), which obviously is pretty easily done by animating the hue.

The more complicated thing was to tweak these curves to a) actually have a smooth animation and b) make the yellow not stand out as much, that's why I also animated the value.
I tested my changes, and I think the animation looks much better now, but there are still a few problems with my code.

  1. I had to decrease the RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL by a lot, essentially breaking all setups customizing that value.
  2. I am still using a constant for the interval, instead of the get_interval_time with different speed modes which would probably be better suited for that.
  3. The readability of the code is not very good, imo. I could probably improve that by using some sensible constants, but I'd be interested to hear some feedback first.
  4. The documentation would need some updating.

So, it might also be a good idea to, instead of changing the existing effect, add a completely new one, thus leaving more choice to the users and avoiding any breaking changes.

I'd be interested to hear what you think, and I recommend to just try out the updated effect 😀

Types of Changes

  • Enhancement/optimization

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

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

Tested the changes, and they look good!

However, could you add the new setting to the documentation, and update the settings in the documents?
https://github.com/qmk/qmk_firmware/blob/master/docs/feature_rgblight.md#effect-and-animation-settings

quantum/rgblight.c Outdated Show resolved Hide resolved
@drashna drashna requested a review from a team December 16, 2019 07:12
@drashna
Copy link
Member

drashna commented Dec 16, 2019

Also, the only downside I see to this change is that it definitely increases the size of the code for this animation, and causes a number of boards to be too large.

That's not really an issue with this PR, though. But if you have ideas for optimizing the code, it may be nice to include here. Otherwise, no worries.

@Maxr1998
Copy link
Contributor Author

Awesome, gonna fix the stuff mentioned here, then it should be ready to merge 😇

Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

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

Okay, I know this is a bit weird of a request, but instead of using pow, could you just handle the math in the function?

It makes it a bit more readable, and most importantly, it's like a 2k difference in firmware size. (this being why it's weird). Whatever pow does, it's NOT friendly for AVR. And since most of our boards use AVR ....

@drashna
Copy link
Member

drashna commented Dec 16, 2019

Also, a good board to test with is the singa. It seems to compile the largest.

@Maxr1998
Copy link
Contributor Author

Maxr1998 commented Dec 16, 2019

Replaced the pow now, and made some other tweaks, but for some reason, the firmware is still to large (for the singa). Could it be that the float I'm using is the culprit now? It seems anyway that pow implicitly converted to float before.

EDIT: well yes, without any float in the code, we gain a cool 1200 bytes. Still not enough, but close.

docs/feature_rgblight.md Outdated Show resolved Hide resolved
@fauxpark
Copy link
Member

@Maxr1998 AVRs don't have an FPU, so doing float math is very expensive both flash-wise and computationally.

@Maxr1998
Copy link
Contributor Author

Maxr1998 commented Dec 16, 2019

Some more changes, but still a bit less than 400 bytes over. With the whole function body commented out, I only have 100 bytes remaining on the Singa. Actually haven't got any ideas left how I could compress my code to 1/5th of its current size 🙈. More suggestions?

@zvecr
Copy link
Member

zvecr commented Dec 17, 2019

You can get a much more accurate representation of the travis build locally with ./util/docker_build.sh singa:default

Travis shows 398 bytes free on master, 58 bytes free on the last build so a potential increase of 340 bytes.

@Maxr1998
Copy link
Contributor Author

Interesting, the docker build actually passes for me locally. So, does that mean the PR is mergeable then? Still any ideas how to strip some bytes from the binaries?

@zvecr
Copy link
Member

zvecr commented Dec 17, 2019

Technically yes, the PR would be mergeable as all the boards are now building. Though the question I would pose is, do we want to accept an increase in firmware of 340 bytes for what is arguably the worse animation out of the bunch. Personally, I wouldn't care if the animation was just flat out removed...

@yiancar
Copy link
Contributor

yiancar commented Dec 17, 2019

maybe make it disabled out by default?

@Maxr1998
Copy link
Contributor Author

Maxr1998 commented Dec 17, 2019

@zvecr yikes. Well, I kinda like it, so maybe really make it disabled by default, as in, remove it from RGBLIGHT_ANIMATIONS? It's pretty seasonal, so it shouldn't be in the firmware all the time anyway.

@zvecr
Copy link
Member

zvecr commented Dec 17, 2019

Yeah disabled by default could work (which doesn't have to be done within this PR). Lets see what some of the other collaborators say on the situation.

@nooges
Copy link
Member

nooges commented Dec 18, 2019

I’d be alright with removing it from default

@yanfali
Copy link
Contributor

yanfali commented Dec 18, 2019

Ditto

@yiancar
Copy link
Contributor

yiancar commented Dec 18, 2019

I have created this issue to further discuss what should be the default:)
#7669

@Maxr1998
Copy link
Contributor Author

@yiancar thanks for creating the issue, this seems to be a good idea generally. However, I think that should be handled inside another PR. I can do a quick draft tomorrow, removing some of the more complex/specific animations from the default already.

@Maxr1998
Copy link
Contributor Author

Forgot about this a bit, but I added a draft for the changes in #7680. Feel free to discuss those over there.

@Maxr1998 Maxr1998 requested review from drashna and fauxpark January 21, 2020 10:41
@stale
Copy link

stale bot commented Mar 6, 2020

Thank you for your contribution!
This pull request has been automatically marked as stale because it has not had activity in the last 45 days. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, or re-open when it's ready.
For maintainers: Please label with awaiting review, breaking_change, in progress, or on hold to prevent the issue from being re-flagged.

@Maxr1998
Copy link
Contributor Author

@tzarc done 😄

@Maxr1998
Copy link
Contributor Author

Maxr1998 commented Jul 25, 2020

Also tested my changes, obviously. Now I'm kinda in a Christmas mood 🤔 🎅

@tzarc tzarc merged commit 7d7f5bf into qmk:develop Jul 25, 2020
@tzarc
Copy link
Member

tzarc commented Jul 25, 2020

Also tested my changes, obviously. Now I'm kinda in a Christmas mood 🤔 🎅

Perfect outcome! ;)

Thanks for the submission, merged!

noroadsleft pushed a commit that referenced this pull request Jul 26, 2020
)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
noroadsleft pushed a commit that referenced this pull request Jul 31, 2020
)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
noroadsleft pushed a commit that referenced this pull request Aug 11, 2020
)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
noroadsleft pushed a commit that referenced this pull request Aug 27, 2020
)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
noroadsleft pushed a commit that referenced this pull request Aug 29, 2020
)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
nicocesar pushed a commit to nicocesar/qmk_firmware that referenced this pull request Sep 6, 2020
…k#7648)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Sep 30, 2020
…k#7648)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
kjganz pushed a commit to kjganz/qmk_firmware that referenced this pull request Oct 28, 2020
…k#7648)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
@Maxr1998 Maxr1998 deleted the christmas_tweaks branch January 14, 2021 11:59
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
…k#7648)

* Tweak the Christmas animation effect to be less harsh on the eyes

* Further improve the tweaked Christmas animation code

- Use constants where it makes sense
- Instead of complicated math, use a static variable to keep track if it's animating from or to red
- Don't use pow (but a simple macro instead)
- Using floating point math is necessary for the fraction in the cubic bezier function to work

* Update docs for the tweaked Christmas animation effect

* Further improve memory usage

- Don't use floats, but 32 bit ints instead (where needed)
- Replace limits.h with constant

* Fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants