Skip to content

Commit 497d19d

Browse files
authored
out_min should not be in divisor (esp8266#2408)
fixes esp8266@fb00e64 error
1 parent fb00e64 commit 497d19d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cores/esp8266/WMath.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ long secureRandom(long howsmall, long howbig) {
7070
}
7171

7272
long map(long x, long in_min, long in_max, long out_min, long out_max) {
73-
long divisor = (in_max - in_min) + out_min;
73+
long divisor = (in_max - in_min);
7474
if(divisor == 0){
7575
return -1; //AVR returns -1, SAM returns 0
7676
}
77-
return (x - in_min) * (out_max - out_min) / divisor;
77+
return (x - in_min) * (out_max - out_min) / divisor + out_min;
7878
}
7979

8080
unsigned int makeWord(unsigned int w) {

0 commit comments

Comments
 (0)