map() from Arduino library is expensive in terms of flash and time
Submitted by cybergibbons on Thu, 27/03/2014 - 08:57
I've been playing with an RFu-328 and a thermistor as opposed to a DS18B20. This is because thermistors are pennies compare to pounds, and they give almost instant readings instead of having to wake, request, sleep, read a with the DS18B20.
The example code I was using had map() to change the thermistor readings into something more useful. I noticed this seemed to be taking a lot longer than expected, so I looked into it.
The short of it is that map() is really quite inefficient, and it's nearly always possible to use a simpler construct to map values.
I wrote a blog post about this, including how to make the map() used in emonGLCD more efficient (not that it matters, as it is mains powered):
map() from Arduino library is expensive in terms of flash and time
Submitted by cybergibbons on Thu, 27/03/2014 - 08:57I've been playing with an RFu-328 and a thermistor as opposed to a DS18B20. This is because thermistors are pennies compare to pounds, and they give almost instant readings instead of having to wake, request, sleep, read a with the DS18B20.
The example code I was using had map() to change the thermistor readings into something more useful. I noticed this seemed to be taking a lot longer than expected, so I looked into it.
The short of it is that map() is really quite inefficient, and it's nearly always possible to use a simpler construct to map values.
I wrote a blog post about this, including how to make the map() used in emonGLCD more efficient (not that it matters, as it is mains powered):
http://cybergibbons.com/arduino/arduino-misconceptions-x-map-is-a-low-ef...