#define DEV_MODE true.
I’ll probably either have to cut out my edits to
Draw.cpp or redo them completely because this commit is a big change.
I’m not actually sure how the compiler will handle this.
Normally calling functions only once will cause them to be inlined (and template functions are generally more likely to be inlined anyway),
but the question is will the compiler be smart enough to realise the redundancy of the inline code and fold it into a single function block.
If not, this approach will take a significant chunk out of progmem.
Having a quick skim, a few observations:
if ((up | down | left | right) & 1) is going to be smaller than
if ((up | down | left | right) != 0).
& 1 should add an extra instruction (an
!= 0 should just make use of the status register’s zero flag for the branch (which was probably happening already with
if (up | down | left | right), but implicit casting to
bool is evil).
DrawScaledTx doesn’t need
(In fact, since this is a
.cpp file, none of your functions need
abs as a template will sometimes result in less code than defining it as a macro.
Remember that macros are just text subtitution, so if you did (for example)
ABS(a - b), the compiler would actually see
(((a - b) < 0) ? -(a - b) : (a - b)).
A template function on the other hand would force its arguments to be evaluated before its body is evaluated.