Error in Code for Touchscreen

I am using code that I got from a project in project hub. There is an error that I cannot figure out. I looked into the touchscreen example codes and I didn't see this error line of code in any of them.

image

I have a comment on the project site that I am waiting for a reply on. Any additional help would be appreciated.

Thanks,

Andrew

Simple!:

ts is a variable name. You have created ts as:

TouchScreen ts = ...

So, ts is a variable name, not a type.
But this:

struct ts t;

tries to define a variable t of the type "struct ts". But ts is not a structure, it is already a variable name (cannot be used as a type name anymore).

Do you mean?:

TouchScreen t;

The error message tells you already something wrong with a type (name).

It wasn't my code originally. I was using it from the project hub. If you look a couple lines above there is 'TouchScreen ts = Touchscreen(...);'

Do I even need to define a variable named 't' or do I just use 'ts' instead?

Thanks

Sure, yes (I saw and have studied your code), but "ts" is a variable name, not a type name.
Do you get it?
"ts" is already a name for a variable, you cannot use anymore for a type name. The line with code as:

struct ts t;

looks wrong. What do you want to define? ("ts" is not a struct type anymore, "ts" was defined as a variable name, there is not a struct definition named as "ts"...).
What is defined already - cannot be used anymore as a type, with the same name.

It is like:
"how are you called?" = ts
"create a structured instance out of my name ts as t" = struct ts t;

Would you be able to understand what to do?
"ts" is the name of a variable or the name of a structure, but not both at the same time. "Do you mean the variable ts or the type name ts?" Is your family name "ts" or is your sex "ts"?

LOL :sweat_smile:

Later on in the code, there are multiple references to 't'. ex. the line

'tft.println(t.hour);'

which is giving an error because t is not defined. Error message is

'class TouchScreen' has no member named 'hour'

I commented out the original error line (struct ts t). I also tried changing 't' to 'ts' and got the new error message (no member name).

Again, this is not my original code so I am not sure what exactly the code is supposed to be doing (I am not a programmer).

Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.