Easy way to declare a table, not using SRAM

_

Seems a bit risky to be using the line number, since any modification to the file might break it. Better to use an appropriate text editor to hard code the numbers based off the line numbers, easy to do with something like vi.

In what way is that trick better than this, other than in terms of obfuscation:

const int PROGMEM tab[] = 
{
    ofs+fact*sin(1*dt),
    ofs+fact*sin(2*dt),
    ofs+fact*sin(3*dt),
    ofs+fact*sin(4*dt),
(repeat as many as you need)
};

GOOD code is clear, and it's function obvious. That makes it easier for you to remember how it works, for others to understand how it works, and reduces the number of bugs. These kinds of tricks are of no value. They don't save any space, they don't add any useful functionality. They do nothing but make the code harder to understand. There is a cost, but there is no benefit to offset that cost.

Actually I find that code much more confusing. It is hard to understand what is being done, relies on the compiler implementing COUNTER, and has a limitation of N that even you do not understand.

What's wrong with a simple

const int PROGMEM tab[] = {
#include "tableFile.csv"
};

or similar?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.