sleemanj / optiboot

Small and Fast Bootloader for Arduino and other Atmel AVR chips
66 stars 13 forks source link

is map() implemented to work for attiny13? #30

Closed darkmetalman closed 4 months ago

darkmetalman commented 4 months ago

Hello Is map() implemented to work for attiny13? My code is not working with when I use the map() arduino function.

It works when I flash using MCUdude's MicroCore.

Regards!

sleemanj commented 4 months ago

Hmmm.

Are you passing in constant values for the ranges, or are they variables?

sleemanj commented 4 months ago

If you are using variable for the start/end ranges (eg map(x,y,z,j,h)), there is a bug which would prevent it from compiling, put this in your sketch to correct it

uint32_t _map( uint32_t x, uint32_t in_min, uint32_t in_max, uint32_t out_min, uint32_t out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

if you are using constants for the ranges (eg map(x, 1,1023, 1,255)) then the bug would not present itself.

The incorrect defintion has been fixed in https://github.com/sleemanj/ATTinyCore/commit/7b9ec522859dbc2c4e350d465c6d9a548cfe27ca but when I will get around to a new release I don't know.

darkmetalman commented 4 months ago

Thanks!!! that solved the problem.