TFT Trouble --> edited HW_AVR.inc --> compiling error

Hello! So I am currently using the exact same set up as this previous post, and encountered the same issue (my touchscreen was being inconsistent after turning off/on the power):

https://forum.arduino.cc/index.php?topic=196133.0

I tried the fix (editing HW_AVR.inc), and saved the file as an administrator because I have Arduino saved in my programs directory. I have saved other UTouch and UTFT files as an administrator and nothing has given me issue so far.

When I tried to upload a sketch, I got an error message. So I undid my changes in HW_AVR.inc, and even though the syntax of my HW_AVR.inc is EXACTLY the same as it was initially, I still get a similar error message (printed below). It seems as if the file is being read incorrectly.

What's up and how do I fix it? Do I have to redownload UTouch or something?

================================================================

In file included from C:\Program Files (x86)\Arduino\libraries\URTouch\URTouch.cpp:27:0:

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:1:6: error: 'UTouch' has not been declared

void UTouch::touch_WriteData(byte data)

^

In file included from C:\Program Files (x86)\Arduino\libraries\URTouch\URTouch.h:30:0,

from C:\Program Files (x86)\Arduino\libraries\URTouch\URTouch.cpp:23:

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc: In function 'void touch_WriteData(byte)':

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:6:6: error: 'P_CLK' was not declared in this scope

cbi(P_CLK, B_CLK);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:2:28: note: in definition of macro 'cbi'

#define cbi(reg, bitmask) *reg &= ~bitmask

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:6:13: error: 'B_CLK' was not declared in this scope

cbi(P_CLK, B_CLK);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:2:36: note: in definition of macro 'cbi'

#define cbi(reg, bitmask) *reg &= ~bitmask

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:11:8: error: 'P_DIN' was not declared in this scope

sbi(P_DIN, B_DIN);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:3:28: note: in definition of macro 'sbi'

#define sbi(reg, bitmask) *reg |= bitmask

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:11:15: error: 'B_DIN' was not declared in this scope

sbi(P_DIN, B_DIN);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:3:35: note: in definition of macro 'sbi'

#define sbi(reg, bitmask) *reg |= bitmask

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:13:8: error: 'P_DIN' was not declared in this scope

cbi(P_DIN, B_DIN);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:2:28: note: in definition of macro 'cbi'

#define cbi(reg, bitmask) *reg &= ~bitmask

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:13:15: error: 'B_DIN' was not declared in this scope

cbi(P_DIN, B_DIN);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:2:36: note: in definition of macro 'cbi'

#define cbi(reg, bitmask) *reg &= ~bitmask

^

In file included from C:\Program Files (x86)\Arduino\libraries\URTouch\URTouch.cpp:27:0:

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc: At global scope:

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:20:6: error: 'UTouch' has not been declared

word UTouch::touch_ReadData()

^

In file included from C:\Program Files (x86)\Arduino\libraries\URTouch\URTouch.h:30:0,

from C:\Program Files (x86)\Arduino\libraries\URTouch\URTouch.cpp:23:

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc: In function 'word touch_ReadData()':

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:27:7: error: 'P_CLK' was not declared in this scope

sbi(P_CLK, B_CLK);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:3:28: note: in definition of macro 'sbi'

#define sbi(reg, bitmask) *reg |= bitmask

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:27:14: error: 'B_CLK' was not declared in this scope

sbi(P_CLK, B_CLK);

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:3:35: note: in definition of macro 'sbi'

#define sbi(reg, bitmask) *reg |= bitmask

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:29:11: error: 'P_DOUT' was not declared in this scope

if (rbi(P_DOUT, B_DOUT))

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:4:30: note: in definition of macro 'rbi'

#define rbi(reg, bitmask) ((*reg) & bitmask)

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR.inc:29:19: error: 'B_DOUT' was not declared in this scope

if (rbi(P_DOUT, B_DOUT))

^

C:\Program Files (x86)\Arduino\libraries\URTouch\hardware/avr/HW_AVR_defines.h:4:37: note: in definition of macro 'rbi'

#define rbi(reg, bitmask) ((*reg) & bitmask)

^

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

================================================================

Did your code ever compile with the original file? If so, you clearly buggered something up.

It might be that the compile process is still using the older version of your files; restarting the IDE should take care of that.

3rd party libraries don't belong in Arduino's install directory; they belong in C:\Users\yourUserName\Documents\Arduino\libraries.

PS
what makes you think that this is related to Avrdude, stk500, Bootloader issues?

Leave the IDE. Delete all your wrongly placed User libraries.

Start the IDE. Install the User libraries properly with the Library Manager.
UTFT is not approved by the Manager. You must use ZIP.
Download the UTFT, URTouch Zip files. Install from ZIP.

Edit any User_Config files for the newly installed libraries.

Everything should work fine.

If you have a problem, post a link to your display, photo of wiring, say which UTFT example. Paste your constructor statement.

Copy-paste the last few lines from a successful build i.e. the Memory use, and libraries used.

The Arduino IDE works very well. The Library Manager reports versions, and installs approved libraries from verified locations. Avoid installing anything from random places on the Web.
This applies to UTFT too. Only download from RinkyDink.

David.