how would I store something like this as a variable
tft.fillRect(0, 10, 5, 1, ST7735_BLACK);
how would I store something like this as a variable
tft.fillRect(0, 10, 5, 1, ST7735_BLACK);
What are you aiming to do with the variable should what you ask be possible ?
I am trying to set a position at the rectangle for a sprite
Is it the parameters for the function call that you want to store as a variable or the whole expression ?
I am attempting to do something like this
int rectangle = tft.fillRect(0, 10, 5, 1, ST7735_BLACK);
Then why not simply do it like that ?
it gives an error
You wouldn't. That's a function call. It performs an action. It doesn't create anything that can be stored as a variable.
If the expression or its parameters were in a variable then the same error, whatever it is, would occur
It is time for you to post a complete sketch that illustrates the error, using code tags when you do, and for you to post the full error message too, also in code tags
You said previously “no errors”
I think we need more explanation.
If you’re creating the rectangle repeatedly, you could simply out it within a function() that you call wgphebener you need it.
#define rectangle tft.fillRect(0, 10, 5, 1, ST7735_BLACK)
This will replace "rectangle" with the string/command following it
I tried this but I got the error again
the error says "Compilation error: void value not ignored as it ought to be"
I still do not understand what it is that you are trying to do by replacing a call to a function with a variable. Can you please give an example of how you would use the variable in a sketch once it was assigned ?
for example I want to do something like this
spriteY = rectangle;
Then what are you going to do with the spriteY variable ?
I want to make a sprites Y position in the same Y location of the rectangle
You could do this
sprite.y = rectangle.y;
If sprite and rectangle are both structs
Some TFT controllers support sprites.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.