help help
Hello ,
Can this code be complied ? If so , you need to choose the right board and com port that you used .
Tools -> Board -> type of you board
Tools -> Serial port -> COM you used
Deray
Hello , im from holland and i am new a pupil in microcontrollers
i have a qustions, i have seeed tft 2,8, this tft have a no sd card,
can I upload a photo with this for my logo,
And you have a idea to create a menu example if I “here” on busy that I go to the next screen ?
i have arduino mega
Yes , you can upload a photo from SD card and showed by TFT Shield , there is library on our wiki ,you can refer to it .
TFT BMP demo sketch
What is the menu ?I don’t quite understand , it for TFT ?
Deray
Edit: Fixed code for RD_LOW and RD_HIGH original code was correct.
I just purchased a 2.8 TFT from RS. I see that it is version 1.0.
I built an interface for an Arduino to a Shield for the Coridium LPC1114 BasicChip which I won.
I converted the TFT.CPP to ArmBasic for the Basic Chip. I was able to get the touch panel working, but have had no luck with the TFT. I examined the links goint to the shield with a logic analyzer and the signals look correct.
-
Could my problem be that the BasicChip is a 3.3V part?
-
Could U3 and U4 on the shield (3.3K resistors) be a problem by no letting the proper signal levels thru to to TFT?
-
When -RD is Active (low) I only see E7 or EF on the data bus.
-
Does the Touch Panel need 5v or will it work on 3.3? My levels seem low. I I need to connect 5V to the panel I will have to add some drivers and dividers. It seems to work OK for now.
-
Do I need to connect -RESET to the shield?
I have both 3.3V and 5V connected to the shield.
I am going up to RS this morning to get a UNO or Mega. I will try that with the original library.
Thanks
JohnK
Here is my ArmBasic code:
'******************************************************************************
’ Copyright © 2012 Universe Unlimited Microsystems
’
’ File: touchtft.bas
’
’ Summary: TFT on SeeedStudios (Radio Shack) 2.8" TFT Touch Shield V 1.0
’
’ derived from:
'SPFD5408A or ST7781R TFT Library.
’
'2011 Copyright © Seeed Technology Inc.
’
'Authors: Albert.Miao, Visweswara R (with initializtion code from TFT vendor)
’
'This library is free software; you can redistribute it and/or
'modify it under the terms of the GNU Lesser General Public
'License as published by the Free Software Foundation; either
'version 2.1 of the License, or (at your option) any later version.
’
'This library is distributed in the hope that it will be useful,
'but WITHOUT ANY WARRANTY; without even the implied warranty of
'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
'Lesser General Public License for more details.
’
'You should have received a copy of the GNU Lesser General Public
'License along with this library; if not, write to the Free Software
'Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
’
’
’
’ Contents:
’
’ Notes:
’
’ Author: John E. Kabat Jr.
’
’ Last Edit: 11/15/2012 10:59:10 By: John E. Kabat Jr.
’
’ Revisions:
’
'******************************************************************************
#ifndef USE_TFT
#define USE_TFT
#include <LPC11xx.bas>
goto endofTFT
'Basic Colors
#define RED &Hf800
#define GREEN &H7e00
#define BLUE &H001f
#define BLACK &H0000
#define YELLOW &Hffe0
#define WHITE &Hffff
'Other Colors
#define CYAN &H07ff
#define BRIGHT_RED &Hf810
#define GRAY1 &H8410
#define GRAY2 &H4208
'TFT resolution 240*320
#define MIN_X 0
#define MIN_Y 0
#define MAX_X 239
#define MAX_Y 319
’ TFT Data Pins are P0(1) thru P0(8)
’ since P0 starts at P0(0) we need to shift left 1 bit
#define TFT_DATA_SHIFT 1
#define TFT_DATA_MASK &H01FE
’ TFT Control Pins are:
’ -CS = P1(9)
’ RS = P1(8)
’ -RD and -WR are on P0
’ -RD = P0(11)
’ -WR = P0(10)
#define CS_VAL P1(9)
#define CS_LOW CS_VAL=0
#define CS_HIGH CS_VAL=1
#define RS_VAL P1(8)
#define RS_LOW RS_VAL=0
#define RS_HIGH RS_VAL=1
#define RD_VAL P0(11)
#define RD_LOW RD_VAL=0
#define RD_HIGH RD_VAL=1
#define WR_VAL P0(10)
#define WR_LOW WR_VAL=0
#define WR_HIGH WR_VAL=1
SUB TFT_ALL_PIN_INPUT
GPIO0_DIR = GPIO0_DIR AND NOT(TFT_DATA_MASK)
’ Checking to see if Basic does anything when setting Input
DIR(1)=0
DIR(2)=0
DIR(3)=0
DIR(4)=0
DIR(5)=0
DIR(6)=0
DIR(7)=0
DIR(8)=0
END SUB
SUB TFT_ALL_PIN_OUTPUT
GPIO0_DIR = GPIO0_DIR OR TFT_DATA_MASK
’ Checking to see if Basic does anything when setting Output
DIR(1)=1
DIR(2)=1
DIR(3)=1
DIR(4)=1
DIR(5)=1
DIR(6)=1
DIR(7)=1
DIR(8)=1
END SUB
SUB TFT_ALL_PIN_LOW
GPIO0_DATA = GPIO0_DATA AND NOT(TFT_DATA_MASK)
’ just checking if Basic does something else when setting low
P0(1)=0
P0(2)=0
P0(3)=0
P0(4)=0
P0(5)=0
P0(6)=0
P0(7)=0
P0(8)=0
END SUB
SUB TFT_PUSHDATA(X AS INTEGER)
dim start as integer
TFT_ALL_PIN_LOW
GPIO0_DATA = GPIO0_DATA OR (X << TFT _DATA_SHIFT)
WR_LOW
START = TIMER
WHILE (TIMER-START < 10) ' wait for 10 micro-seconds
LOOP
WR_HIGH
END SUB
FUNCTION TFT_GETDATA AS INTEGER
dim x, start as integer
RD_LOW
START = TIMER
WHILE (TIMER-START < 10) ' wait for 10 micro-seconds
LOOP
RD_HIGH
x=GPIO0_DATA
x = x >> TFT_DATA_SHIFT
RETURN (x AND &H00FF)
END FUNCTION
SUB TFT_SENDCOMMAND( INDEX AS INTEGER)
PRINT "S Ccommand ";HEX(INDEX)
TFT_ALL_PIN_OUTPUT
CS_LOW
RS_LOW
RD_HIGH
WR_HIGH
TFT_PUSHDATA(0)
TFT_PUSHDATA(INDEX AND &HFF)
CS_HIGH
TFT_ALL_PIN_INPUT
END SUB
SUB TFT_SENDDATA(DAT AS INTEGER)
TFT_ALL_PIN_OUTPUT
CS_LOW
WR_HIGH
RS_HIGH
RD_HIGH
TFT_PUSHDATA((DAT AND &HFF00)>>8)
TFT_PUSHDATA(DAT AND &H00FF)
CS_HIGH
TFT_ALL_PIN_INPUT
END SUB
FUNCTION TFT_READREGISTER(INDEX AS INTEGER) AS INTEGER
DIM DAT AS INTEGER
dim start as integer
CS_LOW
RS_LOW
RD_HIGH
TFT_ALL_PIN_OUTPUT
TFT_PUSHDATA(0)
TFT_PUSHDATA(INDEX)
TFT_ALL_PIN_INPUT
TFT_ALL_PIN_LOW
RS_HIGH
DAT = TFT_GETDATA<<8
DAT = DAT OR TFT_GETDATA
CS_HIGH
’ TFT_ALL_PIN_OUTPUT
RETURN DAT
END FUNCTION
SUB TFT_INIT
DIM IC_CODE AS INTEGER
DIM I,F AS INTEGER
PRINT "TFT INIT"
DIR(10)=1
DIR(11)=1
DIR(40)=1
DIR(41)=1
CS_HIGH
RS_HIGH
RD_HIGH
WR_HIGH
TFT_ALL_PIN_OUTPUT
TFT_ALL_PIN_LOW
wait(500)
IC_CODE = TFT_readRegister(&H0)
print "IC CODE=";HEX(IC_CODE)
IC_CODE = TFT_readRegister(&H0)
print "IC CODE=";HEX(IC_CODE)
IC_CODE = TFT_readRegister(&H0)
print "IC CODE=";HEX(IC_CODE)
#if 0
if IC_CODE = &H5408 THEN
TFT_sendCommand(&H0000)
TFT_sendData(&H0001)
wait(100)
TFT_sendCommand(&H0001)
TFT_sendData(&H0000)
TFT_sendCommand(&H0002)
TFT_sendData(&H0700)
TFT_sendCommand(&H0003)
TFT_sendData(&H1030)
TFT_sendCommand(&H0004)
TFT_sendData(&H0000)
TFT_sendCommand(&H0008)
TFT_sendData(&H0207)
TFT_sendCommand(&H0009)
TFT_sendData(&H0000)
TFT_sendCommand(&H000A)
TFT_sendData(&H0000)
TFT_sendCommand(&H000C)
TFT_sendData(&H0000)
TFT_sendCommand(&H000D)
TFT_sendData(&H0000)
TFT_sendCommand(&H000F)
TFT_sendData(&H0000)
'power on sequence VGHVGL
TFT_sendCommand(&H0010)
TFT_sendData(&H0000)
TFT_sendCommand(&H0011)
TFT_sendData(&H0007)
TFT_sendCommand(&H0012)
TFT_sendData(&H0000)
TFT_sendCommand(&H0013)
TFT_sendData(&H0000)
'vgh
TFT_sendCommand(&H0010)
TFT_sendData(&H1290)
TFT_sendCommand(&H0011)
TFT_sendData(&H0227)
wait(100)
'vregiout
TFT_sendCommand(&H0012)
TFT_sendData(&H001d) '&H001b
wait(100)
'vom amplitude
TFT_sendCommand(&H0013)
TFT_sendData(&H1500)
wait(100)
'vom H
TFT_sendCommand(&H0029)
TFT_sendData(&H0018)
TFT_sendCommand(&H002B)
TFT_sendData(&H000D)
'gamma
TFT_sendCommand(&H0030)
TFT_sendData(&H0004)
TFT_sendCommand(&H0031)
TFT_sendData(&H0307)
TFT_sendCommand(&H0032)
TFT_sendData(&H0002) ' 0006
TFT_sendCommand(&H0035)
TFT_sendData(&H0206)
TFT_sendCommand(&H0036)
TFT_sendData(&H0408)
TFT_sendCommand(&H0037)
TFT_sendData(&H0507)
TFT_sendCommand(&H0038)
TFT_sendData(&H0204) '0200
TFT_sendCommand(&H0039)
TFT_sendData(&H0707)
TFT_sendCommand(&H003C)
TFT_sendData(&H0405) ' 0504
TFT_sendCommand(&H003D)
TFT_sendData(&H0F02)
'ram
TFT_sendCommand(&H0050)
TFT_sendData(&H0000)
TFT_sendCommand(&H0051)
TFT_sendData(&H00EF)
TFT_sendCommand(&H0052)
TFT_sendData(&H0000)
TFT_sendCommand(&H0053)
TFT_sendData(&H013F)
TFT_sendCommand(&H0060)
TFT_sendData(&HA700)
TFT_sendCommand(&H0061)
TFT_sendData(&H0001)
TFT_sendCommand(&H006A)
TFT_sendData(&H0000)
'
TFT_sendCommand(&H0080)
TFT_sendData(&H0000)
TFT_sendCommand(&H0081)
TFT_sendData(&H0000)
TFT_sendCommand(&H0082)
TFT_sendData(&H0000)
TFT_sendCommand(&H0083)
TFT_sendData(&H0000)
TFT_sendCommand(&H0084)
TFT_sendData(&H0000)
TFT_sendCommand(&H0085)
TFT_sendData(&H0000)
'
TFT_sendCommand(&H0090)
TFT_sendData(&H0010)
TFT_sendCommand(&H0092)
TFT_sendData(&H0600)
TFT_sendCommand(&H0093)
TFT_sendData(&H0003)
TFT_sendCommand(&H0095)
TFT_sendData(&H0110)
TFT_sendCommand(&H0097)
TFT_sendData(&H0000)
TFT_sendCommand(&H0098)
TFT_sendData(&H0000)
TFT_sendCommand(&H0007)
TFT_sendData(&H0133)
TFT_sendCommand(&H0022) 'Start to write to display RAM
else
TFT_sendCommand(&H0001)
TFT_sendData(&H0100)
TFT_sendCommand(&H0002)
TFT_sendData(&H0700)
TFT_sendCommand(&H0003)
TFT_sendData(&H1030)
TFT_sendCommand(&H0004)
TFT_sendData(&H0000)
TFT_sendCommand(&H0008)
TFT_sendData(&H0302)
TFT_sendCommand(&H000A)
TFT_sendData(&H0000)
TFT_sendCommand(&H000C)
TFT_sendData(&H0000)
TFT_sendCommand(&H000D)
TFT_sendData(&H0000)
TFT_sendCommand(&H000F)
TFT_sendData(&H0000)
wait(500)
TFT_sendCommand(&H0030)
TFT_sendData(&H0000)
TFT_sendCommand(&H0031)
TFT_sendData(&H0405)
TFT_sendCommand(&H0032)
TFT_sendData(&H0203)
TFT_sendCommand(&H0035)
TFT_sendData(&H0004)
TFT_sendCommand(&H0036)
TFT_sendData(&H0B07)
TFT_sendCommand(&H0037)
TFT_sendData(&H0000)
TFT_sendCommand(&H0038)
TFT_sendData(&H0405)
TFT_sendCommand(&H0039)
TFT_sendData(&H0203)
TFT_sendCommand(&H003c)
TFT_sendData(&H0004)
TFT_sendCommand(&H003d)
TFT_sendData(&H0B07)
TFT_sendCommand(&H0020)
TFT_sendData(&H0000)
TFT_sendCommand(&H0021)
TFT_sendData(&H0000)
TFT_sendCommand(&H0050)
TFT_sendData(&H0000)
TFT_sendCommand(&H0051)
TFT_sendData(&H00ef)
TFT_sendCommand(&H0052)
TFT_sendData(&H0000)
TFT_sendCommand(&H0053)
TFT_sendData(&H013f)
wait(500)
TFT_sendCommand(&H0060)
TFT_sendData(&Ha700)
TFT_sendCommand(&H0061)
TFT_sendData(&H0001)
TFT_sendCommand(&H0090)
TFT_sendData(&H003A)
TFT_sendCommand(&H0095)
TFT_sendData(&H021E)
TFT_sendCommand(&H0080)
TFT_sendData(&H0000)
TFT_sendCommand(&H0081)
TFT_sendData(&H0000)
TFT_sendCommand(&H0082)
TFT_sendData(&H0000)
TFT_sendCommand(&H0083)
TFT_sendData(&H0000)
TFT_sendCommand(&H0084)
TFT_sendData(&H0000)
TFT_sendCommand(&H0085)
TFT_sendData(&H0000)
TFT_sendCommand(&H00FF)
TFT_sendData(&H0001)
TFT_sendCommand(&H00B0)
TFT_sendData(&H140D)
TFT_sendCommand(&H00FF)
TFT_sendData(&H0000)
wait(500)
TFT_sendCommand(&H0007)
TFT_sendData(&H0133)
wait(250)
'exit standby
TFT_sendCommand(&H0010)
TFT_sendData(&H14E0)
wait(500)
TFT_sendCommand(&H0007)
TFT_sendData(&H0133)
TFT_sendCommand(&H0022)
endif
'paint screen black
print "BLACK"
for i=0 to 2 step 1
for f=0 to 38400 step 1
print "i,f=";I,F
TFT_sendData(BLACK)
next f
next i
#endif
end sub
endofTFT:
TFT_INIT
#endif
I added a delay (1 us) after CS. This is so they do not simultaneous transition.
Here is the logic analyzer output: