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

Animartrix updates #55

Merged
merged 10 commits into from
Jun 29, 2023
Merged

Animartrix updates #55

merged 10 commits into from
Jun 29, 2023

Conversation

netmindz
Copy link
Collaborator

  • Usermod to be disabled by default to not clutter the list of effects too much
  • Disabling actually preventing the effects being listed (reboot required)
  • Updated library with fix for SM1
  • Pass speed slider to animartrix speed factor

@netmindz netmindz marked this pull request as ready for review June 29, 2023 11:54
@@ -67,6 +67,8 @@ class ANIMartRIXMod:public ANIMartRIX {
if (SEGENV.call == 0) {
init(SEGMENT.virtualWidth(), SEGMENT.virtualHeight(), false);
}
float speedFactor = map(SEGMENT.speed, 0, 255, 1, 100) / 10;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This calc isn't right.

Requirements:
0 = 0.1
125 = 1.0
255 = 10.0

Problem: 125 currently returns 5.0

Copy link
Collaborator

@softhack007 softhack007 Jun 29, 2023

Choose a reason for hiding this comment

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

I think the easiest solution would be to split the mapping into two parts: <1.0 and >=1.0.
Also you need to use "mapf" as the mapped result is float.
something like

float speedFactor = 1.0f:
if (SEGMENT.speed < 128) speedFactor = mapf(SEGMENT.speed,   0, 127, 0.1f, 1.0f);
                    else speedFactor = mapf(SEGMENT.speed, 128, 255, 1.0f, 10.0f);

The small overlap at "1.0f" does not matter much - nobody will notice there is no difference between 127 and 128.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, didn't know about mapf (). Thought I might need to split into increase Vs decrease

Copy link
Collaborator

Choose a reason for hiding this comment

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

you can grab mapf() here

WLED/wled00/FX.cpp

Lines 6205 to 6209 in 17147f3

// float version of map()
static float mapf(float x, float in_min, float in_max, float out_min, float out_max){
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

actually its planned to make this function global, as WLED is starting to collect several copies of mapf() in unsermods..

@netmindz netmindz merged commit 40751b4 into MoonModules:mdev Jun 29, 2023
@netmindz netmindz deleted the animartrix-updates branch June 29, 2023 20:15
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