-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Conversation
netmindz
commented
Jun 29, 2023
- 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
@@ -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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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..