parenthesis blindness help needed

can anyone help with this one line of code i seem to be having parenthesis blindness

if ((tft.fillScreen == (BLACK)) && ((p.x > 163) && (p.x < 200))&& ((p.y > 295) && (p.y < 314)))
{
  tft.print("bingo")
}

invalid use of member function (did you forget the ‘()’ ?)

Could it be as simple as adding a ; to this line?
tft.print(“bingo”)

I saw this in your other thread http://forum.arduino.cc/index.php?topic=335684.0
It looks to me as though tft.fillScreen is a function. If so it needs to be used as one, like this

tft.fillScreen();

and almost certainly it needs parameters in the brackets such as the colour the screen is to be filled with, but that is a guess.

Please read my reply in your other thread.

split it to multiline

if ((tft.fillScreen == (BLACK)) && ((p.x > 163) && (p.x < 200))&& ((p.y > 295) && (p.y < 314)))

==>

if ((tft.fillScreen == (BLACK)) &&
((p.x > 163) && (p.x < 200)) &&
((p.y > 295) && (p.y < 314))
)

sorry guys this isnt working im getting the errors no matter what i try
im going to approach it from another direction

and yes i have tried all the options above

Maybe if we knew what the error was. And saw all the code. It might be an extra parens above this.

mikewitney:
can anyone help with this one line of code i seem to be having parenthesis blindness

if ((tft.fillScreen == (BLACK)) && ((p.x > 163) && (p.x < 200))&& ((p.y > 295) && (p.y < 314)))

{
  tft.print(“bingo”)
}




invalid use of member function (did you forget the '()' ?)

tft.fillScreen == (BLACK) ???

tft.fillScreen (x,y,z);

I'm getting errors too. Maybe you can help me?

My errors are: You didn't post the error messages (note the special "copy errors" button in the Arduino IDE) and you didn't post your entire code.

MorganS:
I'm getting errors too. Maybe you can help me?

My errors are: You didn't post the error messages (note the special "copy errors" button in the Arduino IDE) and you didn't post your entire code.

No need to get preachy again.

The syntax for tft.fillScreen == (BLACK) is wrong and the error message said so.

This forum suppose to help decipher the error messages - read the title.

If it ain’t clear, make it simple and clear and in the process the error maybe gets found.

if ( tft.fillScreen == ( BLACK )) 
{
  if ( (( p.x > 163 ) && (p.x < 200)) && (( p.y > 295 ) && ( p.y < 314 )) )
  {
    tft.print("bingo")
  }
}

Learn to match braces and parenthesis. Contain whole expressions in ( ).

And he said it did not help...

KeithRB:
And he said it did not help...

That was different code. Count the parenthesis, not the same.

mikewitney:
sorry guys this isnt working im getting the errors no matter what i try
im going to approach it from another direction

and yes i have tried all the options above

Have you established what tft.fillScreen actually does ?
To me it still (see reply #2) seems to be a function that fills the screen with a given colour rather than reading the current colour of the screen and in any case needs brackets after its name hence the error message you got

invalid use of member function (did you forget the '()' ?)

What do you get if you do

Serial.println(tft.fillScreen());

UKHeliBob:
Have you established what tft.fillScreen actually does ?
To me it still (see reply #2) seems to be a function that fills the screen with a given colour rather than reading the current colour of the screen and in any case needs brackets after its name hence the error message you got

invalid use of member function (did you forget the '()' ?)

What do you get if you do

Serial.println(tft.fillScreen());

no matching function for call to 'Adafruit_ILI9341::fillScreen()
it wont let me do it
so yes ur correct... thanks for that. i would have been at this for ages

i am still new to all this arduino stuff i've come from IOS dev to this as i had an adea i'm just trying to put this idea together.. once i have this system up and running it will be controlled by an IOS & Android app which i already have ready to go.. this is my first Arduino adventure.

and believe be just to get the hardware its cost me over £350 as i keep buying stuff and finding out its no good so a buy something else to replace it

i started with a raspberry pi then on to a Arduino uno then moved to a Arduino Mega.
i have 3 screens 2 of which are now spare. and much more
just to get where i am now

but hey at least i can build more stuff afterwards LOL

UKHeliBob was correct it was a function i was trying to add in to the if statement
if i try

if ( tft.fillScreen == ( BLACK ))

i get the error

invalid use of member function (did you forget the '()' ?)

so i can't do that

Hi,

Can you please post a complete copy of your sketch, using code tags?

If your sketch is too big, use REPLY rather than QUICK REPLY and it has an attachment facility, so you can post your sketch as an attachment, but try code tags first.

Tom...... :slight_smile:

So that function prototype looks like this:

virtual void fillScreen(uint16_t color);

Im not sure if you intend on finding out what colour the screen is with your previous:

if ( tft.fillScreen == ( BLACK ))

But that won't work.

This function takes a colour and fills the screen in that colour. So to fill the screen in black:

tft.fillScreen( ILI9341_BLACK );

so i can't do that

No, you can't. Perhaps you should try explaining what you are really trying to do. Then, we can offer suggestions.

If what you are trying to do is determine the screen color, I have to wonder why that is necessary. Only YOU assign the color. Simply remember which color is currently assigned, and base your decisions on that.

In the OP's other thread on the subject he explains what he is trying to do, ie determine which screen is being shown when the user presses a virtual button on the screen.

His worry is that the user will press a button, the screen will change and the same button press will be detected on the second screen. I suggested that he needs to detect when the button becomes pressed rather than is pressed (sound familiar ?) but he seems to have chosen to ignore that advice and seek another way to do it by detecting the current screen based on its colour.

mikewitney:
no matching function for call to 'Adafruit_ILI9341::fillScreen()
it wont let me do it
so yes ur correct… thanks for that. i would have been at this for ages

i am still new to all this arduino stuff i’ve come from IOS dev to this as i had an adea i’m just trying to put this idea together… once i have this system up and running it will be controlled by an IOS & Android app which i already have ready to go… this is my first Arduino adventure.

and believe be just to get the hardware its cost me over £350 as i keep buying stuff and finding out its no good so a buy something else to replace it

i started with a raspberry pi then on to a Arduino uno then moved to a Arduino Mega.
i have 3 screens 2 of which are now spare. and much more
just to get where i am now

but hey at least i can build more stuff afterwards LOL

  1. Open whatever TFT library x.h you are using in any text editor.
  2. find method / function fillScreen
  3. read the function description / brief - if it has one
  4. see what parameters does it requires - most likely int RGB colors AKA fillScreen(R, G, B);
  5. does the function returns anything - I doubt it.
  6. BLACK MAY be a #define 255,255,255 - check that

Your problem has nothing to do which what hardware you are using , nothing to do with brackets , nothing to do with if() etc,…

You are using the function incorrectly and the compiler told you that.

The syntax is incorrect and if the function does not return anything checking for == BLACK is pointless.

It ALWAYS helps to actually open the “library” file - ( it is ALL Open source ) source code to verify how the function you are trying to use works.

But again - the syntax and usage is wrong.