View Single Post
Old 01-12-2018, 03:08 PM   #54
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Dealing with encoder rings.



What is the best way to convert 0-1 range into 0-12? Some log curve would also be a nice addition to that conversion.
For now, I did a straightforward conversion, which isn't very elegant:
Code:
function ledRings(value) local (int_out)(
    value == 0 ? (int_out = 0;):
    0 < value <= 0.01 ? (int_out = 1;):
    0.01 < value <= 0.1 ? (int_out = 2;):
    0.1 < value <= 0.2 ? (int_out = 3;):
    0.2 < value <= 0.3 ? (int_out = 4;):
    0.3 < value <= 0.4 ? (int_out = 5;):
    0.4 < value <= 0.5 ? (int_out = 6;):
    0.5 < value <= 0.6 ? (int_out = 7;):
    0.6 < value <= 0.7 ? (int_out = 8;):
    0.7 < value <= 0.8 ? (int_out = 9;):
    0.8 < value <= 0.9 ? (int_out = 10;):
    0.9 < value <= 1 ? (int_out = 11;):
    value == 1 ? (int_out = 12;);
    );
This might be better, though:
Code:
int_out = floor(value * 12);
fundorin is offline   Reply With Quote