1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

out_min should not be in divisor (#2408)

fixes fb00e64a6f error
This commit is contained in:
Me No Dev 2016-08-18 12:38:01 +03:00 committed by GitHub
parent fb00e64a6f
commit 497d19d039

View File

@ -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 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){ if(divisor == 0){
return -1; //AVR returns -1, SAM returns 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) { unsigned int makeWord(unsigned int w) {