How to move the tft lcd 2.4 data pins on Mega2560 [TFT_ID:0x9341]

Hay Everybody…
I have a question for library SPDF5408 Adafruit TFT LCD. How do I change the 8-bit data pin of TFT LCD to pin 22-29 or other digital pins on Arduino Mega 2560, and where I need to change its coding, is it on <SPFD5408_Adafruit_TFTLCD.h> or <SPFD5408_Adafruit_GFX.h>??
In my case, digital pins from 2-13 will be used for GSM Shield ?? Please guide me. Thank you!!!

This is the picture:

Anyone?? Please help me!!!

In the beginning God invented boys and girls.

Arduino Shields work in the same way. Every male pin should plug into the corresponding female socket.

If you want to use unreliable flying leads, you will have to ask the author of your chosen library.

Incidentally, MCUFRIEND_kbv library has always had the USE_MEGA_8BIT_PROTOSHIELD "SPECIAL". My PROTOSHIELD has the exact wiring that you want. But it is made with proper shield sockets.

David.

Big thanks for you David. Your solution fix my problem... :) :) :)

Congratulations. Most people struggle to "enable" a SPECIAL.

It goes pretty quick too!

David.

hi !

i change my board to Mega2560, now what is the difference between this “specials” macros?

//#define USE_MEGA_8BIT_PROTOSHIELD
//#define USE_MEGA_8BIT_SHIELD // 4.7sec Mega2560 Shield
//#define USE_MEGA_16BIT_SHIELD // 2.14sec Mega2560 Shield

PROTOSHIELD —> uses digital pin 22~29

is this config is true for protoshield?
MEGA LCD
22…LCD_D0
23…LCD_D1
24…LCD_D2
25…LCD_D3
26…LCD_D4
27…LCD_D5
28…LCD_D6
29…LCD_D7

8BIT_SHIELD —> is it same with UNO LCD pins ?

16BIT_SHIELD —> where is the other 8bit pins?

Yes.

//#define USE_MEGA_8BIT_PROTOSHIELD  // LCD_D0-D7  on 22-29 LCD_CTL on A0-A4
//#define USE_MEGA_8BIT_SHIELD       // LCD_D0-D7  on 22-29 LCD_CTL on 38-41
//#define USE_MEGA_16BIT_SHIELD      // LCD_D0-D15 on 22-37 LCD_CTL on 38-41

The commercial shields have known wiring. When you use a Protoshield the wiring is up to you.

David.

thanks !

im using "8BIT_SHIELD" but its slow! in this mode i havnt change LCD_CTL to 38~41 but it works ! is it necessary to change it?

i think PROTOSHIELD is high speed !?

Read #2.

Moving databus to 22-29 is as fast as you will ever get. Moving the control pins makes no difference.

Always start with examples. Which one is too slow?

Application speed depends on your logical design. Only re-draw something if it has changed.

If you want help, paste or attach your code. But first off, draw a flowchart yourself. Pencil and paper is best. Think about how your logic "travels" around the blocks.

David.

okay !

i change D0~D7 to 22~29 on mega2560 and enable the prototype micro and use this config for LCD_CTL but nothing show ??? in previous mode my program works !

const int XP = 22, XM = A2, YP = A3, YM = 23;

yes my prog works well but just slower than mega32, my design on mega32 works fast so i change the macro to PROTOTYPE and connect data pins to 22~29 with wires and now not working !?

im confused ...

this my wiring picture 22~29 :

It looks as if you have removed the J2 male header from the Shield. And removed two pins from the J1 header. Then attached flying wires to 22-29

I can't see if you have hacked J3 or J4.

Your first job is to think about any "remote" reader of your messages.

i change D0~D7 to 22~29 on mega2560 and enable the prototype micro and use this config for LCD_CTL but nothing show ??? in previous mode my program works !

const int XP = 22, XM = A2, YP = A3, YM = 23;

Makes no sense. LCD_CTL pins control the LCD e.g. LCD_RD, LCD_WR, ... Touch pins e.g. XP, XM, ... control the Touchscreen

Make notes on paper. Then type your notes to the message. e.g. quote which library example. say what the problem is.

David.

just forget about speed !

i use your multi screen example (uploaded here)

i want to connect my 2.4" LCD with prototype mode —> what is the way for connecting wires?

david_prentice:
It looks as if you have removed the J2 male header from the Shield. And removed two pins from the J1 header.
Then attached flying wires to 22-29 —> yes

I can’t see if you have hacked J3 or J4. —> no i not change other side

Your first job is to think about any “remote” reader of your messages. —> what it means “remote” reader ? sorry for my eng. language !

Makes no sense. LCD_CTL pins control the LCD e.g. LCD_RD, LCD_WR, …
Touch pins e.g. XP, XM, … control the Touchscreen

Make notes on paper.
Then type your notes to the message.
e.g. quote which library example. say what the problem is.

David.

button_multiple.zip (2.35 KB)

with my lcd wiring 22-29 pins (image that sended before)and when "PROTOTYPE" enabled (with your example code) ---> problem: my lcd shows white screen

Go on. You have made no attempt to add your Calibration.

// copy-paste results from TouchScreen_Calibr_native.ino

const int XP=PB7,XM=PA6,YP=PA7,YM=PB6; //0x1602 BLUEPILL
//const int XP=PA7,XM=PA2,YP=PA3,YM=PB0; //0x1602 MY BLUEPILL
const int TS_LEFT=907,TS_RT=136,TS_TOP=139,TS_BOT=942; //0x1602 Australian
//const int XP=PB7,XM=PA0,YP=PA1,YM=PB8; //240x320 ID=0x9302
//const int TS_LEFT=810,TS_RT=178,TS_TOP=922,TS_BOT=177; //0x9302 Domenico

//const int XP=7,XM=A1,YP=A2,YM=6; //320x480 ID=0x6814
//const int TS_LEFT=134,TS_RT=906,TS_TOP=114,TS_BOT=924;
//const int XP=7,XM=A1,YP=A2,YM=6; //ID=0x7783
//const int TS_LEFT=208,TS_RT=877,TS_TOP=102,TS_BOT=897;
//const int XP=6,XM=A1,YP=A2,YM=7; //ID=0x7789
//const int TS_LEFT=885,TS_RT=148,TS_TOP=111,TS_BOT=902;
//const int XP = 6, XM = A2, YP = A1, YM = 7; //ID=0x9341
//const int TS_LEFT = 907, TS_RT = 136, TS_TOP = 942, TS_BOT = 139;

Seriously. Run all the library examples first. Quote example name. Explain any problem.

I doubt if I ever posted a ZIP in that state. Unless I was replying to a BluePill user.

David.

opps ! this is not edited code ! i edited but still not working and im add calibration like this :

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>

#define MINPRESSURE 200
#define MAXPRESSURE 1000

#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

//ALL Touch panels and wiring is DIFFERENT
//Copy-paste results from TouchScreen_Calibr_native.ino
const int XP = 8, XM = A2, YP = A3, YM = 9; //240x320 ID=0x7575
const int TS_LEFT=937,TS_RT=118,TS_TOP=942,TS_BOT=65;

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

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

i want to know how is the true wiring LCD for working in PROTOTYPE mode ?(please show me the wiring guide )
which pin from arduino mega2560 connected to data and control pins of lcd ?

the white screen related to my wiring and all your examples works fine if i dont use PROTOTYPE mode

is it true to remove lcd pin headers and connect it with wires to 22~29 ?
is anything else needed? for example changing XP to 22 and YM to 23 ?
or removing other side of lcd pin headers (A0~A5) and connecting to other digital pins ?

Go on. English might not be your first language but you are good.

Just put your brain into gear.

What were the Touch pins when you had a regular Shield? It is commonly on A1, A2, 7, 6 for Red shields Blue shields are often on A2, A3, 9, 8.

If you have moved 7, 6 to 29, 28 you would expect to change XP, YM accordingly Likewise moving 9, 8 to 23, 22.

You could edit the Calibration sketch to test pins 22-29 instead of testing pins 2-9 when diagnosing the Touch pins. I think that the Calibration sketch on GitHub Beta makes this easy.

Seriously. If you find something difficult to understand, please suggest an improvement. I would like the examples to be "better" for regular shields. I want it to be "hard" to hack shields.

David.

thanks David !

my lcd shield board is red with HX7347G driver and A2, A3, 9, 8 works fine for me ! and im enable this driver from your mcu_friend_kbv.cpp library files and im enable PROTOTYPE macro from your "special" header file (for using max. speed data lines)

but my lcd only works with pin 2~9 for data and in PROTOTYPE enabled mode my digital pins on mega2560 not working and because of it lcd shows white screen !

in better word: my digital pins maybe not send data or maybe disabled or ....

===

just some questions: 1- are you changing pins in your library code? something like software pin changing ? 2- is it true to remove(=desoldeing pin headers)in lcd and connect it with wires to 22~29 digital pins ?

===

and excuse me for long conversation, i have a little time to complete this work ...

MCUFRIEND_kbv.cpp:

#define SUPPORT_8347D

utility/mcufriend_shield.h:

#define USE_SPECIAL

utility/mcufriend_special.h:

#define USE_DUE_8BIT_PROTOSHIELD

I would feel a lot happier if you simply wrote down each step. I don't see why I should have to guess.

But the most important question is:

Why don't you plug the Shield into the MEGA2560 as Nature intended?

You would still need: MCUFRIEND_kbv.cpp:

#define SUPPORT_8347D

But everything else would work after this.

If someone has an overwhelming desire to shoot their foot, I can't stop her. She just has to endure the pain. I hope you enjoy it.

David.

hi !

im forget to edit mcufriend_shield.h:

define USE_SPECIAL

Why don't you plug the Shield into the MEGA2560 as Nature intended? ---> i think we should hack the lcd pin headers and connect it to digital port of Mega2560, but you do it with writing software lib !

thanks !