Difference between revisions of "Component: Map Function (Calculation)"

From Flowcode Help
Jump to navigationJump to search
Line 17: Line 17:
 
==Component Source Code==
 
==Component Source Code==
  
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Map-Function.fcfx FC_Comp_Source_Map-Function.fcfx]
+
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_temp/Map-Function.fcfx FC_Comp_Source_temp/Map-Function.fcfx]
  
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Map-Function.fcfx FC_Comp_Source_Map-Function.fcfx]
+
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_temp/Map-Function.fcfx FC_Comp_Source_temp/Map-Function.fcfx]
  
 
==Detailed description==
 
==Detailed description==
Line 48: Line 48:
  
 
''<span style="color:red;">No additional examples</span>''
 
''<span style="color:red;">No additional examples</span>''
 +
 +
  
  
Line 55: Line 57:
 
==Macro reference==
 
==Macro reference==
  
===MapUlong===
+
===MapByte===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapUlong'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapByte'''
 
|-
 
|-
| colspan="2" | Map function for unsigned long type variables&nbsp;
+
| colspan="2" | Map function for byte type variables&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | Value
 
| width="90%" | Value
 
|-
 
|-
 
| colspan="2" | Main variable used for map function&nbsp;
 
| colspan="2" | Main variable used for map function&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | InMin
 
| width="90%" | InMin
 
|-
 
|-
 
| colspan="2" | Lowest input value&nbsp;
 
| colspan="2" | Lowest input value&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | InMax
 
| width="90%" | InMax
 
|-
 
|-
 
| colspan="2" | Highest value input&nbsp;
 
| colspan="2" | Highest value input&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | OutMin
 
| width="90%" | OutMin
 
|-
 
|-
 
| colspan="2" | Lowest value after conversion&nbsp;
 
| colspan="2" | Lowest value after conversion&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" | OutMax
 
| width="90%" | OutMax
 
|-
 
|-
Line 94: Line 96:
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
===MapInt===
+
===MapFloat===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapInt'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapFloat'''
 
|-
 
|-
| colspan="2" | Map function for signed int type variables&nbsp;
+
| colspan="2" | Map function for floating point type variables&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
+
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | Value
 
| width="90%" | Value
 
|-
 
|-
 
| colspan="2" | Main variable used for map function&nbsp;
 
| colspan="2" | Main variable used for map function&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
+
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | InMin
 
| width="90%" | InMin
 
|-
 
|-
 
| colspan="2" | Lowest input value&nbsp;
 
| colspan="2" | Lowest input value&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
+
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | InMax
 
| width="90%" | InMax
 
|-
 
|-
 
| colspan="2" | Highest value input&nbsp;
 
| colspan="2" | Highest value input&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
+
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | OutMin
 
| width="90%" | OutMin
 
|-
 
|-
 
| colspan="2" | Lowest value after conversion&nbsp;
 
| colspan="2" | Lowest value after conversion&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
+
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" | OutMax
 
| width="90%" | OutMax
 
|-
 
|-
Line 138: Line 140:
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
  
  
===MapFloat===
+
===MapInt===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapFloat'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapInt'''
 
|-
 
|-
| colspan="2" | Map function for floating point type variables&nbsp;
+
| colspan="2" | Map function for signed int type variables&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
+
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" | Value
 
| width="90%" | Value
 
|-
 
|-
 
| colspan="2" | Main variable used for map function&nbsp;
 
| colspan="2" | Main variable used for map function&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
+
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" | InMin
 
| width="90%" | InMin
 
|-
 
|-
 
| colspan="2" | Lowest input value&nbsp;
 
| colspan="2" | Lowest input value&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
+
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" | InMax
 
| width="90%" | InMax
 
|-
 
|-
 
| colspan="2" | Highest value input&nbsp;
 
| colspan="2" | Highest value input&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
+
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" | OutMin
 
| width="90%" | OutMin
 
|-
 
|-
 
| colspan="2" | Lowest value after conversion&nbsp;
 
| colspan="2" | Lowest value after conversion&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
+
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" | OutMax
 
| width="90%" | OutMax
 
|-
 
|-
Line 182: Line 184:
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}
Line 275: Line 277:
  
  
===MapByte===
+
===MapUlong===
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
|-
 
|-
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapByte'''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapUlong'''
 
|-
 
|-
| colspan="2" | Map function for byte type variables&nbsp;
+
| colspan="2" | Map function for unsigned long type variables&nbsp;
 
|-
 
|-
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" | Value
 
| width="90%" | Value
 
|-
 
|-
 
| colspan="2" | Main variable used for map function&nbsp;
 
| colspan="2" | Main variable used for map function&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" | InMin
 
| width="90%" | InMin
 
|-
 
|-
 
| colspan="2" | Lowest input value&nbsp;
 
| colspan="2" | Lowest input value&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" | InMax
 
| width="90%" | InMax
 
|-
 
|-
 
| colspan="2" | Highest value input&nbsp;
 
| colspan="2" | Highest value input&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" | OutMin
 
| width="90%" | OutMin
 
|-
 
|-
 
| colspan="2" | Lowest value after conversion&nbsp;
 
| colspan="2" | Lowest value after conversion&nbsp;
 
|-
 
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" | OutMax
 
| width="90%" | OutMax
 
|-
 
|-
Line 314: Line 316:
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
 
|-
 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 
|}
 
|}

Revision as of 12:02, 3 February 2023

Author medelec35
Version 2.0
Category Calculation


Map Function component

The map function is intended to change one range of values into another range of values. For example. Output from a temperature sensor is in centigrade. you can map it to give the result in Fahrenheit. To do that set: InMin to 0, InMax 100, OutMin to 32 & OutMax to 212

Component Source Code

Please click here to download the component source project: FC_Comp_Source_temp/Map-Function.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_temp/Map-Function.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples




Macro reference

MapByte

Fc9-comp-macro.png MapByte
Map function for byte type variables 
Fc9-u8-icon.png - BYTE Value
Main variable used for map function 
Fc9-u8-icon.png - BYTE InMin
Lowest input value 
Fc9-u8-icon.png - BYTE InMax
Highest value input 
Fc9-u8-icon.png - BYTE OutMin
Lowest value after conversion 
Fc9-u8-icon.png - BYTE OutMax
highest value after conversion 
Fc9-bool-icon.png - BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
Fc9-u8-icon.png - BYTE Return


MapFloat

Fc9-comp-macro.png MapFloat
Map function for floating point type variables 
Fc9-f32-icon.png - FLOAT Value
Main variable used for map function 
Fc9-f32-icon.png - FLOAT InMin
Lowest input value 
Fc9-f32-icon.png - FLOAT InMax
Highest value input 
Fc9-f32-icon.png - FLOAT OutMin
Lowest value after conversion 
Fc9-f32-icon.png - FLOAT OutMax
highest value after conversion 
Fc9-bool-icon.png - BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
Fc9-f32-icon.png - FLOAT Return


MapInt

Fc9-comp-macro.png MapInt
Map function for signed int type variables 
Fc9-s16-icon.png - INT Value
Main variable used for map function 
Fc9-s16-icon.png - INT InMin
Lowest input value 
Fc9-s16-icon.png - INT InMax
Highest value input 
Fc9-s16-icon.png - INT OutMin
Lowest value after conversion 
Fc9-s16-icon.png - INT OutMax
highest value after conversion 
Fc9-bool-icon.png - BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
Fc9-s16-icon.png - INT Return


MapLong

Fc9-comp-macro.png MapLong
Map function for signed long type variables 
Fc9-s32-icon.png - LONG Value
Main variable used for map function 
Fc9-s32-icon.png - LONG InMin
Lowest input value 
Fc9-s32-icon.png - LONG InMax
Highest value input 
Fc9-s32-icon.png - LONG OutMin
Lowest value after conversion 
Fc9-s32-icon.png - LONG OutMax
highest value after conversion 
Fc9-bool-icon.png - BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
Fc9-s32-icon.png - LONG Return


MapUInt

Fc9-comp-macro.png MapUInt
Map function for unsigned int type variables 
Fc9-u16-icon.png - UINT Value
Main variable used for map function 
Fc9-u16-icon.png - UINT InMin
Lowest input value 
Fc9-u16-icon.png - UINT InMax
Highest value input 
Fc9-u16-icon.png - UINT OutMin
Lowest value after conversion 
Fc9-u16-icon.png - UINT OutMax
highest value after conversion 
Fc9-bool-icon.png - BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
Fc9-u16-icon.png - UINT Return


MapUlong

Fc9-comp-macro.png MapUlong
Map function for unsigned long type variables 
Fc9-u32-icon.png - ULONG Value
Main variable used for map function 
Fc9-u32-icon.png - ULONG InMin
Lowest input value 
Fc9-u32-icon.png - ULONG InMax
Highest value input 
Fc9-u32-icon.png - ULONG OutMin
Lowest value after conversion 
Fc9-u32-icon.png - ULONG OutMax
highest value after conversion 
Fc9-bool-icon.png - BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
Fc9-u32-icon.png - ULONG Return



Property reference

Fc9-prop-icon.png Properties