remap function from arduino programming

For general Flowcode discussion that does not belong in the other sections.
Post Reply
solozerouno
Posts: 113
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 4:36 am
Has thanked: 2 times
Been thanked: 2 times

Flowcode v10 remap function from arduino programming

Post by solozerouno »

There is the possibility of converting from 10bit to 8bit with the function in C "REMAP" for Arduino in which, for example, a value is read from A0 and refers to the Pwm, for which the bits are read at 10 and written at 8 .. ... How is it with Flc10 ? Thanks Solozerouno

medelec35
Matrix Staff
Posts: 1451
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 512 times
Been thanked: 472 times

Re: remap function from arduino programming

Post by medelec35 »

Hello.
Of course, the built-in remap function can do that.
However, the most efficient way to convert 10bit to 8 bit is:

Code: Select all

ADC = ADC >> 2
All the code is doing is bit shifting by 2 places which is the same as dividing by 4.
Martin

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: remap function from arduino programming

Post by BenR »

Hello,

We have a component to do the REMAP function if required, it's available under Math -> Map Function.

Martin's suggestion of bitshifting is probably best if you're just looking to reduce the bit depth.

Post Reply