Economical coding

Hi all.

I'm trying to work out the best way to make full use of my Boarduino; I'm acutely aware of the limitations of the hardware, so I'm kind of freaking out about whether or not it's best to do a certain task as an iterative function, or just hardcode the lot and bung it in a header file.

I'm trying to do a pretty digital dash for my motorbike, and for the rev counter, I've got a vertical bar, which will increase according to the engine's rpm. As a key to that, I'm putting in a series of little Roman Numerals alongside it, because I can crunch those down to within a 3x3 grid, as opposed to 5x8 for characters.

My question is; do I put together a couple of routines that draw the numerals, (one for a ten, one for a five, and one for a one), and then draw them as seven(){five(); one(); one();} with coordinates, or do I just use the header file approach, with 3K of bitmap data.

bearing in mind the tachometer chart will need to go from two to eleven, I'll need to call 21 instances of the numeral functions to be able to populate it properly, as opposed to nine bitmaps.

To clarify, the hardware that I'm using the adafruit ST7565 negative display (mucho pretty), with a 328-powered Boarduino.

Which is the better method, given the hardware?

Thanks in advance...

Keep in mind that RAM is usually the first resource to run out. If you use a large table, put it in FLASH (PROGMEM) and read it from there when you need it. If you declare it as global or static it will be copied into RAM. 3K of bitmap data in FLASH shouldn't be much of a problem.

johnwasser:
Keep in mind that RAM is usually the first resource to run out. If you use a large table, put it in FLASH (PROGMEM) and read it from there when you need it. If you declare it as global or static it will be copied into RAM. 3K of bitmap data in FLASH shouldn't be much of a problem.

Cool. Once again, you've helped immensely :slight_smile:
Thanks.