From 497d19d03913d23de2986c368125e24d67783126 Mon Sep 17 00:00:00 2001 From: Me No Dev Date: Thu, 18 Aug 2016 12:38:01 +0300 Subject: [PATCH] out_min should not be in divisor (#2408) fixes https://github.com/esp8266/Arduino/commit/fb00e64a6f65dede8d897d07a28d7d02f74ae742 error --- cores/esp8266/WMath.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp8266/WMath.cpp b/cores/esp8266/WMath.cpp index d9d87da5a..1f0c8d7db 100644 --- a/cores/esp8266/WMath.cpp +++ b/cores/esp8266/WMath.cpp @@ -70,11 +70,11 @@ long secureRandom(long howsmall, long howbig) { } long map(long x, long in_min, long in_max, long out_min, long out_max) { - long divisor = (in_max - in_min) + out_min; + long divisor = (in_max - in_min); if(divisor == 0){ return -1; //AVR returns -1, SAM returns 0 } - return (x - in_min) * (out_max - out_min) / divisor; + return (x - in_min) * (out_max - out_min) / divisor + out_min; } unsigned int makeWord(unsigned int w) {