[█████████] INTRO [█████████]
Hello, people (i wish, that you have an amazing day)
[NEED]
We all know how "demanding/needy" most of the microcontrollers that we use in our everyday projects are. And many of us, most probably at least once in our lifetime we had to face an issue with speed, ram-rom capacity or even something combined of all those together, with our microcontrollers [...]
[DILEMMA]
But we also didn't always wanted to exceed the comfort, that the Arduino-IDE & compiler provided to us (users of it) and so, we had to face a dilemma between getting our hands "dirty" with the source code of many things or sacrificing functionality.
[REASON]
And that to me makes alot of sense that us, arduino comunity have to use more resources such as to support as many devices as possible, that sometimes we get to a point that we have to give something in exchange of having a more user friendly and rappid development tool. So... after a long time and thanks to everyone here that helped me from here, here and etc...
[█████████] APPROACH [█████████]
I came to the realisation that we could use MACROS/preprocessor-directives without getting our hands "dirty" with other things, so that we could achive a better programming world, where someone could do something like [what i did here with my new version of library without using any special extension (as a proof of consept too)]:
As an example, by using some code like this in our libraries:
#if defined(_1_OPTIMIZE)
#if ((_1_OPTIMIZE bitor B01111111) == B11111111)
#define USE_PROGMEM
#define NO_BACKPROP
#endif
#if ((_1_OPTIMIZE bitor B10111111) == B11111111)
#define REDUCE_RAM_DELETE_OUTPUTS
#define NO_BACKPROP
#endif
#if ((_1_OPTIMIZE bitor B11101111) == B11111111)
#define REDUCE_RAM_WEIGHTS_COMMON
#define REDUCE_RAM_WEIGHTS_LVL2
#elif ((_1_OPTIMIZE bitor B11011111) == B11111111)
#pragma message "[⚠] 00100000 is not implemented yet."
#endif
#if ((_1_OPTIMIZE bitor B11110111) == B11111111)
#define REDUCE_RAM_DELETE_PREVIOUS_LAYER_GAMMA
#pragma message "[⚠] 00001000 always Enabled not switchable yet."
#endif
#if ((_1_OPTIMIZE bitor B11111011) == B11111111)
#define REDUCE_RAM_STATIC_REFERENCE
#endif
#endif
Such as the user could have Optimization options based on a table:
- B00000000 | Does Nothing
- B10000000 | Uses PROGMEM
- B01000000 | RAM REDUCTION LVL0
- B00100000 | RAM REDUCTION LVL1
- ... (and so on) ...
like:
#define _1_OPTIMIZE B11010100
#include <Libraryfile.h>
...
void setup()
{
...
}
void loop()
{
...
}
[█████████] SUSTAINABILITY [█████████]
I know it might sound crazy, to a level of "types of libraries like this are too complicated to be sustainable through time" or "libraries like this have many issues" or even "after a time codes like this don't seem to make sense even to the author" but don't get me wrong, i don't disagree, i came across many of those issues by myself and even more, even issues related to the compiler and the debuging phase... So let me explain first before any judgment.
[MY VIEW]
I am from those people who think that if someone offers you "open-hands" such a dynamic/meta-tool (in this case MACROS) and you don't catch this offer and try to get as much as possible from it for our own good (when indeed you will need to do it at some point when talking about microcontrollers [that's how i think, at least]), (no offense) then i see it as something that doesn't get the appropriate attention, for it to be actually used to its top levels as it should be [...] and you might think "Ok..ok.. i get the point... But how could someone solve all those issues coming from this approach?"
[SOLUTION]
My idea was to "think as, being able to see what the compiler sees when you define and compile something, the same way you see the code when you are coding" in a sense "be the compiler", and by that i mean that i would like (with your help of course too) to implement extensions/add-ons to our favorite editors, such as that someone could work on the code based on having "choises" between what code to see and edit, like:
lets say that this is what the original code of your library seems like:
#if defined(I_want_to_see_A_when_coding)
call_this_function(...);
...
#endif
#if defined(I_want_to_see_B_when_coding)
call_Ohter_function1(...);
do{
...
}while(true)
...
#endif
#if defined(I_want_to_see_C_when_coding)
call_this_function(...);
...
#endif
if you would like to edit the code based on the "I_want_to_see_A_when_coding" and "I_want_to_see_B_when_coding" from the list of checkboxes provided from the extension. Every change that you would do or be able to see, would be on this code:
call_Ohter_function1(...);
do{
...
}while(true)
...
and i know that i haven't included all the possibilities that can occur, but (i think its too big of a post for me to write more, so i thought to give at least an idea on how it could work for now)
[█████████] OUTRO [█████████]
I might be completly wrong and not aware of many issues related to what i want us to achive with this approach, but sure i am willing at some level to risk it if you people would be intrested too (here is a discord server you could join if you would be intrested to..) [...]
I am sorry for my huge post and and thanks you alot for reading, i would be really happy to hear your ideas and discuss about them [...] <3