Skip to content

Commit

Permalink
Fix map() bug in WMath.cpp (#1636)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 authored and slaff committed Feb 21, 2019
1 parent f177628 commit 27965c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sming/Wiring/WMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ long random(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;
}


Expand Down

0 comments on commit 27965c1

Please sign in to comment.