I have resorted to creating bitmaps for each number and a few letters for a 128x64 Oled module. This was to save memory and get around limitations of libraries such as the u8glib. If I had linux I could use the tools they provided to fix some of these but that's out of the question for now. I wanted to know if there's a simple way of mapping each character to it's bitmap so a function similar to XXX.print(); be used, in order to parse the characters and display the corresponding bitmaps automatically. That would make my life so much easier! thanks!


I would split it down into functions.

First write a function which takes a character and a pair of coordinates, then draws the bitmap corresponding to that character at the given coordinates on the screen.

Then you want a function that is the "next level up". You just pass it a single character, and it remembers the current coordinates and uses those with the character to call the first function. It's then the job of this function to move the coordinates to the next character location ready for the next time it's called.

Finally you want an outer layer (or a few outer layer) functions that take different data types (const char * for example) and send each character in turn to the second function above.

If you were to make a class to wrap it all in you could inherit the Print class. That means you just need to provide the size_t write(char) function which is equivalent to the second function above (of course you still need the first function). The wrappers for different data types are then all provided for you.

| improve this answer | |
  • my biggest problem now is that I can't use any other structure except const uint8_t var[] PROGMEM = {}; for my bitmaps. They will be changed by the compiler as soon as I delete the PROGMEM line. Also when I do this, there is no way I can pass the bitmap into anything (other than manually typing it which defeats the purpose!).As soon as I copy it, even using memcopy_P it is altered when it's displayed! I'm losing my mind over this! – OM222O Feb 10 '19 at 22:48
  • Maybe I can write a huge case statement rather than a lookup table, but that seems awfully wasteful and bad practice. I played around with using structures, pointers, etc with no real luck in solving anything! it seems to be cursed! – OM222O Feb 10 '19 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.