Ok, this may seem easy to the initiated.
I would like to save a string to progmem, let say
const char message[] PROGMEM = “AVRFREAKSISTHEBEST”
Now I want to read it back character by character and convert each character to its encoded value.
Let's say "A" = 15, "B" = 16, "C" = 19, "D" = 20, "E"= 24.... The letters don't follow a numerical sequence.
It is easy enough to read each character and the only way I currently know how to do it is something like
case "A" : character = 15; break; case "B" : character = 16; break;
Now the above seem inefficient. Is there a better way, perhaps a macro that can do it?
The other idea in my head, of which I know effectively nothing, is some sort of directive that will convert my code into the correct values and shove that values into PROGMEM. I.e. let the compiler do the work of conversion...
As an example pseudo code
//Look here compiler, I want you to convert this string... mystring = "AVRFREAKS"; for(repeat_until_done) { //get first character //convert character to correct decimal //put character into an array } //put array of characters in PROGMEM //thanks compiler! You saved me some code space and time...! main() //grab binary value from PROGMEM //use it to flash and beep and move stuff
Is it possible and worth it?
Any other suggestions?