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

Animations refactor #54

Merged
merged 8 commits into from
Jul 11, 2020
Merged

Animations refactor #54

merged 8 commits into from
Jul 11, 2020

Conversation

doughsay
Copy link
Member

@doughsay doughsay commented Jul 5, 2020

Closes: #42, Closes: #51

TODO:

  • Fix the tests
  • Add configuration options to each animation that should have them
  • Fix TODOs/FIXMEs in some of the animations
  • Decide on what to do about the "flash" functionality we used to have

@amclain amclain added the refactor Refactoring code or tech debt repayment label Jul 5, 2020
@doughsay doughsay changed the title Effects refactor Animations refactor Jul 6, 2020
@amclain
Copy link
Member

amclain commented Jul 8, 2020

Closes: #43

Do we want to keep the layout design issue open to explore things like the keyboard-layout-editor format?

@doughsay
Copy link
Member Author

doughsay commented Jul 9, 2020

Do we want to keep the layout design issue open to explore things like the keyboard-layout-editor format?

Sure I guess; or we can create a new issue for that. The issue specifically states supporting non-grid layouts, which this PR addresses, even though we don't use it.

Copy link
Member

@amclain amclain left a comment

Choose a reason for hiding this comment

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

I made it about half way through reviewing this PR and will pick up review again tomorrow. Here are my comments so far. Most are optional and things we could defer for others to help with. 😉

lib/layout.ex Outdated Show resolved Hide resolved
lib/layout/key.ex Show resolved Hide resolved
lib/layout/key.ex Show resolved Hide resolved
lib/layout/led.ex Show resolved Hide resolved
Comment on lines +2 to +9
@type any_color_model ::
Chameleon.Color.RGB.t()
| Chameleon.Color.CMYK.t()
| Chameleon.Color.Hex.t()
| Chameleon.Color.HSL.t()
| Chameleon.Color.HSV.t()
| Chameleon.Color.Keyword.t()
| Chameleon.Color.Pantone.t()
Copy link
Member

Choose a reason for hiding this comment

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

ℹ️ (optional)

I wonder if the color model is actually a property of LED. 🤔 Not sure yet.

lib/rgb_matrix/animation/config.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/animation/config/integer.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/animation/config/integer.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/animation/config/option.ex Outdated Show resolved Hide resolved
Comment on lines 14 to 19
try do
value = String.to_existing_atom(bin_value)
cast(option, value)
rescue
ArgumentError -> :error
end
Copy link
Member

@amclain amclain Jul 9, 2020

Choose a reason for hiding this comment

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

ℹ️ (optional)

How about something like Enum.member? rather than try/rescue?

String.to_existing_atom might also be brittle. Wouldn't this return a false positive if I went into IEx and typed the atom name, then validated again? Nevermind, it would go to cast() when is_atom(value).

Also, the BEAM only allows a finite number of atoms to be created. We may want to validate options either by converting them to strings during the validation process, or storing them as strings in the first place (convert atoms to strings at compile time if we still want an animation designer to be able to use them in code).


tl;dr cast the options to binary, validate binary == binary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that's necessary? The whole reason to use String.to_existing_atom is to protect against leaking atoms... I understand the rescue is not ideal... Anyway, let's address this in a later refactor.

Copy link
Member

@vanvoljg vanvoljg left a comment

Choose a reason for hiding this comment

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

This is a partial review, with more to come later. There are a few questions I have, some places where the documentation and typespecs should be improved.

I haven't finished going through RGBMatrix.Engine, yet. I have some confusion about RGBMatrix.Animation.Config and its submodules, but I need to look those over some more before I can ask anything. I'll sleep on it and pick this up tomorrow (today).

lib/layout/key.ex Show resolved Hide resolved
lib/layout/key.ex Outdated Show resolved Hide resolved
lib/layout.ex Show resolved Hide resolved
lib/layout.ex Show resolved Hide resolved
lib/layout.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/engine.ex Show resolved Hide resolved
lib/rgb_matrix/animation.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/animation.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/animation.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/animation.ex Outdated Show resolved Hide resolved
lib/layout/key.ex Outdated Show resolved Hide resolved
Copy link
Member

@amclain amclain left a comment

Choose a reason for hiding this comment

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

😅 Finally finished. I don't see any hard blockers. 🎉

All of my comments are optional, although the recommended (:warning:) ones would be nice to address before merging if you have the bandwidth. If not, we can start tackling the items as tech debt when the PR is merged.

lib/rgb_matrix/animation/hue_wave.ex Show resolved Hide resolved
lib/rgb_matrix/animation/hue_wave.ex Show resolved Hide resolved
lib/rgb_matrix/paintable.ex Show resolved Hide resolved
lib/rgb_matrix/pixel.ex Show resolved Hide resolved
lib/xebow/keyboard.ex Show resolved Hide resolved
test/xebow_test.exs Outdated Show resolved Hide resolved
lib/rgb_matrix/engine.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/engine.ex Show resolved Hide resolved
lib/rgb_matrix/engine.ex Show resolved Hide resolved
lib/rgb_matrix/engine.ex Show resolved Hide resolved
Copy link
Member

@vanvoljg vanvoljg left a comment

Choose a reason for hiding this comment

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

Here's my concluding batch of comments on this. All of them are just comments, and you're free to take or leave them as you like.

I think we might want to try and simplify the logic of how rendering happens, maybe, but that's something that needs discussion.

Cheers!

lib/rgb_matrix/animation/config/integer.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/animation/config.ex Show resolved Hide resolved
lib/rgb_matrix/engine.ex Outdated Show resolved Hide resolved
lib/rgb_matrix/engine.ex Outdated Show resolved Hide resolved
doughsay and others added 2 commits July 11, 2020 12:59
@doughsay doughsay marked this pull request as ready for review July 11, 2020 21:22
Copy link
Member

@amclain amclain left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks! 🎉

@doughsay doughsay merged commit 487c56a into master Jul 11, 2020
@doughsay doughsay deleted the refactor/effects branch July 11, 2020 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Refactoring code or tech debt repayment
Projects
None yet
3 participants