MCUFRIEND_kbv and pins

Hi,

I have the Arduino Mega with a 2.8" touch screen shield (VMA412)
https://www.velleman.eu/products/view/?id=435582

MCUFRIEND_kbv and TouchScreen.h are what I'm using and everything is working great.

However, now I wish to add a TLC5940 chip to the project. That wants to use up most of the timer pins (OC1A et al) to run.

The SD card slot accounts for 4 of the five needed by the chip - no prob since I don't need the SD card function.

But pin D9 on the Mega board maps to LCD D1 on the shield. This is also shared by the touch panel.

The touch panel pins are defined in the sketch so that can move to a digital pin at the edge of the mega.

My question is - can I edit the MCUFRIEND library to move from pin D9 to one of the edge pins on the mega board?

If so please would anyone educate me on where those pins are defined in the library files?

Thanks in advance!

TFT access is handled in mcufriend_shield.h, line 56ff for Arduino MEGA.

//LCD pins  |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST|
//AVR   pin |PH4|PH3|PE3|PG5|PE5|PE4|PH6|PH5| |PF0|PF1|PF2|PF3|PF4|

TFT D1 is on MEGA port pin PH6, used in write_8(x) and read_8(x). Not easy to change!

TouchScreen pins can be found in Touch_shield_new.ino, line 12:

const int XP=6,XM=A2,YP=A1,YM=7; //ID=0x9341

As the shield pinout is done to directly match on Arduino UNO (and MEGA or DUE), it is not easy to change, and I do not recommend to attempt to change the wiring.
-jz-

Thank you for your reply.

Please may I ask - when you say 'not easy' - does that mean that it is not possible or just that it would be complicated to do so?

Difficulty is not a deal breaker for me personally - I'm here to learn from people like yourself and by getting hands dirty.

So is it a math problem I face? (i.e. the read & write definitions need offsetting to point to a new port & pin)

Or does PH6 have a specific sub-function that categorically rules out all other pins available on the Mega's bottom-edge extra pin array?

I'm using jumper cables so the physical mating of shields to arduino is not a factor.

Any thoughts?

Thanks again!

Yes, just (a bit) complicated. Just remove PH6 from these methods, and add the new port-pin.
And don't forget to adapt the masks.

Just adding a warning to @jsnow : after modifying a library, never upgrade or downgrade the library because the changes will be overwritten.

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