Trying to draw a simple line with GFX

Why doesn’t this work?
void drawLine(uint16_t 1, uint16_t 17, uint16_t 120, uint16_t 17, uint16_t WHITE);

PIO says something has to come between uint16_t and 1. It wants punctuation before a numeric constant.

??

Hi Joe.

Are you declaring the drawLine() function, or calling it?

For a declaration:

// Draw a line from (x0,y0) to (x1,y1).
void drawLine(uint16_t x0, uint16_t y0, 
              uint16_t x1, uint16_t y1, 
              uint16_t colour);

For a call, it would be:

drawLine(1, 17, 120, 17, WHITE);

Edit: Happy Christmas.

Cheers,
Norm.

Edit by @maxgerhardt: Removed void in front of the function call for correctness

1 Like

Would you do the void also? I’ve never tried doing that with a function call… so don’t know if the compiler would spit the dummy if I did… :laughing:

1 Like

Thanks for the edit @maxgerhardt, I’m afraid I forgot to remove the void as part of a copy/paste!

Happy Christmas.

Cheers,
Norm.

You can do this:

(void) drawLine(1, 17, 120, 17, WHITE);

If the function returns a value that is of no interest, but it’s not necessary.

Cheers,
Norm.

1 Like

Thank you very much. I didn’t realize we had to declare a line. I thought it was a machine function, not a real library creature.

Bon natale

Hi Joe.

Your question was:

Because it is incorrect C/C++. This looks like a declaration of a function, but with numbers instead of names for the parameters. That is not allowed.

If, on the other hand, it was actually a function call,then you onlyneed the numbers and not the data types – the declaration has already defined those, most likely in a (library?) Header file.

Cheers,
Norm.

1 Like