Get graphic function to work with different image objects.

neutron7

Well-known member
This might be obvious to some but I have never come across it before.

I have some graphic drawing functions, here is a simple one as an example.

Code:
void drawDottedH(int x, int y, int len, int steps, word colr) {
  for (uint8_t buh = 0; buh < len; buh = buh + steps) {
    tft.drawPixel(x + (buh ), y, colr);
  }
}

I have 2 image arrays, one is the frame buffer (called "tft")
and another (called "vis") which is used for blitting with TGX and other effects.

what I would like to do to avoid a lot of duplicate code is make the function work the same way as the graphic library so i can re-use the same function with either array.

instead of:
Code:
drawDottedH(x, y, len, step, col);
in my code, it would be:
Code:
tft.drawDottedH(x, y, len, step, col);
or
Code:
vis.drawDottedH(x, y, len, step, col);
 
Back
Top