this is not my best method of doubling resolution, however it is one i implemented on the mlx90640 project, mainly to make the code of the project more interesting than the normal code.
Anyway the data from that project is kept stored on the sensor ram, and the i2c data bus is a lot slower, requires a lot of overhead, and the math is complex. for purposes of better performance i wanted to cache the slow access memory without storing it all in the processor
I wanted a method that ensured data would only be read once from the slow ram, and have the end result only processed once to calibration values from math.
the code below caches data in such a way that it reduces requests from slow memory, and slow math calculations to 1 time. it does it by caching two lines of data, a pre line and a current line, it interpolates the current data with the previous line data, it also predicts when to load the cache again for the next line, so you could start x,y at any value and as long as reads are at least sequential for 10 or more reads there is an improvement of performance
here is the routine below. I have shared it in the hopes that other people find it useful.
you will need to modify the mem reads to either a function call like mine, or a array reference to ram.
here is an update that improves performance as of 9/8/19
//ZZZ_ heading just keeps this showing towards the right of tabs
#define nonfloatReturnNumbers true//if this is false it is more accurate. reduces buffer and speeds up output to serial display
#define center_data_filter true //this is like a gain adjust. if less than half of data in range it adds more, if more than half it lowers
//this is a small process that does not use much memory and increases resolution of data in
// however it requires fast ram reads of data in order to not store its own table
//it also requires modification of main structure so it can read data
//it just interpolates in between data by averaging creating a new pixel
//this is not my zoom method. this is just a quick method. some data resolution
// is lost on the edges. it is effectively a resdouble-1
// do not remove commends from this line and above. written james villeneuve
#include "MLX90640_API.h" //we need this so we can access the memory
#define XresolutionOriginal 32 //this is original resolution
#define YresolutionOriginal 24 //this is original resolution
//we use below as cache. we only update information 1/4 of time
//we need a line cache of 32 values to improve performance
//float DataCache[XresolutionOriginal];//this uses a small amount of cache
#if center_data_filter == true
uint16_t add_this_much;
#endif
uint8_t bufferlineNumber =0;//this is a reference to y lines. x line is cached. and previous x line cached.
#if nonfloatReturnNumbers != true
float ReturnCache=0;//this is to make returns more readable. compiler hopefully will remove as a redundancy
float prebufferCache[32];//we use this to reduce mem reads to 1 time.
float CurrentbufferCache[32];//we use this to reduce mem reads to 1 time.
float DoubleResolutionValue(uint8_t XatNewresolution, uint8_t YatNewresolution) {
#endif
#if nonfloatReturnNumbers == true
uint8_t ReturnCache=0;//this is to make returns more readable. compiler hopefully will remove as a redundancy
uint8_t prebufferCache[32];//we use this to reduce mem reads to 1 time.
uint8_t CurrentbufferCache[32];//we use this to reduce mem reads to 1 time.
uint8_t DoubleResolutionValue(uint8_t XatNewresolution, uint8_t YatNewresolution) {
#endif
//this routine uses data from values it can get from sensor reads to double resolution of data without using much memory
//we just need to know the ram we are reading, the x and y resolution, and pixel number
//this is an over simplified setup that interpolates every other value in x and y
//**** we need mem value to pull data from*****************************************************
//**** ...
Thanks for sharing your mlx90640 project and I like the methods you used in creating this project. i love to learn new thing. i am looking for https://reviewguy.in/best-ceiling-fan-in-india/