The standard Arduino map function is implemented using division of signed long integers. This is a very slow operation on AVR, since there is no hardware divider. The fast_map function provided by this library can be much faster. E.g. mapping a uint8_t input to a uint8_t output range is ~10x faster.
Exact speedup varies depending on data types & number ranges.
The library is available in both the Arduino Library and PlatformIO Library registries.
The library can also be cloned & included locally or included directly from GitHub (if your tooling supports it).
#include <avr-fast-map.h>- Replace calls to
mapwith calls tofast-map.
The code base is compatible with all platforms: non-AVR builds compile down to the map function.