I recently purchased a 2.8" TFT Touch Shield (The Seeed variety) from Radioshack, scrounged the web for a good library for ST7781R and got it working wonderfully with my Arduino Mega2560.
I now have a clone Arduino Nano (DCCduino), and would like to connect the same display. So far I have wired the power, reset, and touch screen with a little experimentation and they seem to be working fine.
I am now running into a lack of experience issue where the pin definitions for /cs, cd, wr, and rd are created in the libraries and not in the code. Generally, I think I know where they are being defined, but I don't know how to correctly alter the library for these controls and for the 8 data wires.
Some code:
Part of TFT.h:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
//==================/CS=====================
#define DDR_CS DDRB
#define PORT_CS PORTB
#define CS_BIT 0x10
#define CS_OUTPUT {DDR_CS|=CS_BIT;}
#define CS_HIGH {PORT_CS|=CS_BIT;}
#define CS_LOW {PORT_CS&=~CS_BIT;}
//------------------RS----------------------
#define DDR_RS DDRB
#define PORT_RS PORTB
#define RS_BIT 0x20
#define RS_OUTPUT {DDR_RS|=RS_BIT;}
#define RS_HIGH {PORT_RS|=RS_BIT;}
#define RS_LOW {PORT_RS&=~RS_BIT;}
//------------------WR----------------------
#define DDR_WR DDRB
#define PORT_WR PORTB
#define WR_BIT 0x40
#define WR_OUTPUT {DDR_WR|=WR_BIT;}
#define WR_HIGH {PORT_WR|=WR_BIT;}
#define WR_LOW {PORT_WR&=~WR_BIT;}
#define WR_RISING {PORT_WR|=WR_BIT;PORT_WR&=~WR_BIT;}
Seems to define how cs,rs,wr, and rd are handled for certain boards. The only thing differing between this and other boards definitions, (seeeduino is next for example), is this part of each (cs,rs,wr,rd):
#define RD_BIT 0x80
In TFT.cpp there are several areas which appear board specific, but I will list the first function:
#ifdef MEGA
PORTE |= ((data<<4) & (0x30));
PORTG |= ((data<<3) & (0x20));
PORTE |= ((data & 0x08));
PORTH |= ((data>>1) & (0x78));
#endif
It looks like this is setting ports, but I have almost no experience with C++, and haven't found an good resources on my specific problem.
Is it possible to do this without knowing too much detail about the lcd driver and the mcu? (Do I have to write my own library from scratch?)
The full libraries are in the link above, hopefully someone is willing to look over this with me and determine at the very least if it is feasible to alter the existing library. Please have patience I am def. still very green