R / C receiver ouput from c ++ to flowcode

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 7.

Moderator: Benj

Post Reply
Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

R / C receiver ouput from c ++ to flowcode

Post by Monie Jacobsen »

Is there anyone here who will be assisting with the following

In Arduino used "map" procodure.
How to make "map" procodure in Flowcode 7 ??
Can you give a code eksemple?

Code:
Channel 2 = map (Channel 2, 970, 1970, 0, 255); // Change input about two 0-255 Bytes

Signal from receiver 970-1970

See Web link here!
http://forum.arduino.cc/index.php?topic=3922.0
Best Regard
Monie

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: R / C receiver ouput from c ++ to flowcode

Post by Benj »

Hi Monie,

Can you just do something like this.

Code: Select all

FloatVar = Number (970 to 1970)
FloatVar = FloatVar - 970.0
FloatVar = FloatVar / 3.90626
NewNumber = FloatVar
NewNumber should now be in the range 0 - 255.

Or if you don't want to use floating point maths then you could use this to get an approximation 0 - 250.

Code: Select all

IntVar = Number (970 to 1970)
IntVar = IntVar - 970
IntVar = IntVar / 4
NewNumber = IntVar
You may need to do additional bounds checking on Number to ensure you are in range.

e.g.

Code: Select all

if ( (Number >= 970) && (Number <= 1970) )
Yes : Code from above...
No: NewNumber = 0

Monie Jacobsen
Posts: 484
Joined: Mon Jul 30, 2012 3:39 pm
Has thanked: 17 times
Been thanked: 46 times
Contact:

Re: R / C receiver ouput from c ++ to flowcode

Post by Monie Jacobsen »

Hi Benj
Many, many thanks for the info.
Best Regard
Monie

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: R / C receiver ouput from c ++ to flowcode

Post by Benj »

Flowcode example of the map function now available here: http://www.matrixtsl.com/mmforums/viewt ... 136#p77099

Post Reply