Map

From Pinguino
Jump to: navigation, search

Name

map - map one range to another

Description

s32 map ( s32 x , s32 in_min , s32 in_max , s32 out_min , s32 out_max )
Scale a number from one range of values to another

Syntax

 map( x, in_min, in_max, out_min, out_max );
Parameters
x - number to be scaled
in_min - minimum range of input
in_max - maximum range of input
out_min - minimum range for output
out_max - maximum range for output

Example

To change percentage (0 - 100) to PWM range (0 - 1023)
 newValue = map( value, 0 , 100, 0 , 1023 );

Bugs

See Also

Comments