Simplifying Code - 8x8 LED Gear Shift Indicator

marco_c:
@rwj: To be clear, Parola needs to be give a nul ('\0') terminated array of characters. So you can either pass it

char *curGearChar = GearChars[curGearChar];

which is a pointer to the string in your lookup table, or

char curGearChar[2] = { 'x', '\0' }; // initialize temporary storage

curGearChar[0] = GearChars[curGearChar]; // overwrite first character in the string



where you are copying the character into a new string. Note you have to initialize the temporary array to include the nul character or it will be random stuff that was in memory.

Personally I would use the pointer to the lookup table because that why you use lookup tables, but your hybrid is not correct.

Thank you for clarifying that, it's greatly appreciated.
I've just realised that you are Majic Designs/creator of that very library! I didn't make the connection before, but thank you so much for making my life so much simpler!

which is a pointer to the string in your lookup table

which made me wonder if this would work ?P.displayText((char *) GearChars[gearvalue], PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);

I’ve just realised that you are Majic Designs/creator of that very library!

I was already wondering if there isn’t an overloaded function that would take a ‘char’ and thought to look inside the library code, but that hardly seems relevant now.

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