Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ILI9327 on Arduino Mega

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO
View previous topic :: View next topic  
Author Message
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Sat Jan 03, 2015 4:00 pm    Post subject: ILI9327 on Arduino Mega Reply with quote

There is a sale going on, an Arduino Mega 2560 combined with an 400x240 ILI9327 TFT display...




with some small changes of the very nice code of AndersL I managed to get the display working. Have still to check the touchscreen however.



Do a search for ili9327_final in this forum and change these lines in the ili9327_declarations.inc

Code:
   Cs_disp Alias Portg.1                                     ' /Chip Select Display
      Config Cs_disp = Output
   Res_disp Alias Portg.0                                   ' /Reset Display für INIT
      Config Res_disp = Output
' '  Bl_disp Alias Portd.6                                    ' Backlight Display Not used here.Connected to VCC.
'      Config Bl_disp = Output
   Rs_disp Alias Portd.7                                   ' Indexregister = 0, Data = 1
      Config Rs_disp = Output
'   Rd_disp Alias Portb.2                                    ' Read = 0, Write = 1
'      Config Rd_disp = Output
   Wr_disp Alias Portg.2                                     ' write data to Display  0 -> 1 = latch it
      Config Wr_disp = Output
   Data_disp_lo Alias PortC
      Config Data_disp_lo = Output                          ' Data to Display DB0-DB7
   Data_disp_hi Alias PortA
      Config Data_disp_hi = Output                          ' Data to Display DB8-DB15
 


There is no seperate backlight on this display, it is allways on. Also, there is no RD_disp pin, so in the ili9327_functions.inc you will have to remove the RD_disp lines.

It is a very sparkling display. Fast. About 7 euros if you buy it seperatly.

Small note: the supplier is sometimes mixing up the delivery, got a 480x320 ILI9481 instead of this ILI9327 400x240 display. And also have bought ten of these displays, they are not very well packed, so got some with broken screens. The supplier has replaced these broken displays without any problems however.

Have fun, and a happy New Year
Ben Zijlstra
Back to top
View user's profile Visit poster's website
aphawk

Bascom Member



Joined: 23 Jan 2010
Posts: 151
Location: Brazil

brazil.gif
PostPosted: Mon Jan 05, 2015 2:09 am    Post subject: Reply with quote

hi, Ben,

Thanks for this code, and happy New Year too !

Paulo
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 827
Location: France

france.gif
PostPosted: Mon Jan 05, 2015 11:41 am    Post subject: Reply with quote

Well done Ben !
and Happy new year.

as you say : have fun !
Bon courage

JP
Wink
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Mon Jan 05, 2015 12:41 pm    Post subject: touch and sd... Reply with quote

Working on the touchscreen. Works with Arduino-software but should work with Bascom.

Xtp2046, so a known touchscreen chip.

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Wed Jan 07, 2015 1:39 am    Post subject: Touch working.... Reply with quote

Oke. From my earlier project, the Word Clock, I got the routines for the XTP2046 touchscreen. Have to thank Heiko / Hkipnik and SIX1 for there work, from the variable "Tasteneu" I can see it is from our German friends. Have altered some calculations for the wider screen. Have still to make some kind of menu. A grid or matrix.



As you can see the top left corner has X-value 250, Y-value 122
and the top right corner has X-value 990, Y-value 122
left bottom has X-value 250, Y-value 862
right bottom has X-value 990, Y-value 862

Touch is interrupt driven.

To start with dimensioning of the variables
Code:
'touchscreen
Dim Touchx As word
Dim Touchy As word
Dim Tasteneu As Byte
Dim X_dout As Byte
X_dout = &HD0
Dim Y_dout As Byte
Y_dout = &H90
 



Here pieces of the code you have to integrate in the code for the ILI9327_final from AndersL. INT4 is used for the interrupt. When the touchscreen is touched a interrupt is generated. Variable Tasteneu gets the value 1. The XTP2046 is connected to several other ports. You can find it in the code here

Code:
on int4 Touch_int
enable int4
config int4 = falling
enable interrupts
ddre.4 = 0
porte.4 = 1

Clock alias porth.3
Cst alias porte.3
Dout alias portg.5
Din alias pine.5
config Din = input
config Clock = output
config cst = output
config Dout = output
Cst = 1

dim tijdelijk2 as string * 40
 


Tijdelijk2 is used as a temp variable, to display the values.

An interrupt routine is called and this looks like this. You have to place it somewhere at the end of your program.

Code:

Touch_int:
   tasteneu=1
Return
 


And a do loop with the reading of the XTP2046 can be placed in your ili9327 code at places where you are using some kind of menu

Code:
Do
      if tasteneu > 0 then
         cst = 0
         shiftout dout,clock,x_dout,1,8,20
         waitms 5
         shiftin din, clock, touchx, 1, 12, 20
         shiftout dout, clock, y_dout, 1, 8, 20
         waitms 5
         shiftin din, clock, touchy,1,12,20
         cst=1

         touchx = touchx / 38
         touchx=touchx+200

         touchy = touchy / 38

         waitms 200
         tasteneu = 0

         tijdelijk2="X = "+str(touchx)

         Call Ili9327_text(tijdelijk2 , 150 , 80 , 5 , red , Black)

         tijdelijk2="Y = "+str(touchy)

         Call Ili9327_text(tijdelijk2 , 150 , 100 , 5 , red , Black)

         call ili9327_text("x=990",340,12,5,white,black)
         call ili9327_text("y=122",340,28,5,white,black)

         call ili9327_text("x=250",10,12,5,white,black)
         call ili9327_text("y=122",10,28,5,white,black)

         call ili9327_text("x=250",10,205,5,white,black)
         call ili9327_text("y=862",10,220,5,white,black)

         call ili9327_text("x=990",340,205,5,white,black)
         call ili9327_text("y=862",340,220,5,white,black)

      end if
   Loop
 


Perhaps this was the hardest part

Code:
touchx = touchx / 38
touchx=touchx+200
touchy = touchy / 38
 


How to keep X and Y between unique values.

You can remove the readtouch(X) and readtouch(Y) from the code of AndersL, or exchange these code with the code above.

Ready for testing...

Have fun
Ben Zijlstra
Back to top
View user's profile Visit poster's website
Plons

Bascom Member



Joined: 24 May 2005
Posts: 432
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Tue May 05, 2015 5:15 pm    Post subject: Reply with quote

Hi folks,

I am working on code for the same display TFT240x400 but with a different controller: HX8352 instead of ILI9327. Almost done (will post it when fully done), but I am puzzled by
Code:
Sub Ili9327_setxy_[u][b]frame[/b][/u](byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word)  

What is it supposed to do ? There is another sub
Code:
Sub Ili9327_setxy(byval X1 As Word , Byval Y1 As Word , Byval X2 As Word , Byval Y2 As Word)
which I already translated to HX8352-instructions.
So what does Frame-version of Sub Ili9327_setxy(etc) do more ?

Thanks for all your good work !

Nard

_________________
Bascom AVR ver 2.0.8.1
ProtectedParallelPortProgrammingDongle: http://www.aplomb.nl/TechStuff/PPPD/PPPD%20English.html
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 432
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Tue May 12, 2015 3:15 pm    Post subject: Reply with quote

Attached the SW for the same display but equipped with a HX8352 controller. Purchased at www.elecfreaks.com
http://www.elecfreaks.com/store/32width-400240-tft-lcm-tft0132w-tft0132wd-p-116.html
Not perfect (see notes in HX8352_test_SD_HC_revA.bas) but this is as far as I go.

Nard

_________________
Bascom AVR ver 2.0.8.1
ProtectedParallelPortProgrammingDongle: http://www.aplomb.nl/TechStuff/PPPD/PPPD%20English.html
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 827
Location: France

france.gif
PostPosted: Tue May 12, 2015 5:43 pm    Post subject: Reply with quote

thank you for sharing Nard,

I also discovered a new distributor of gadgets made in China Wink

Jean-Pierre
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 4722
Location: Holland

blank.gif
PostPosted: Tue May 12, 2015 8:37 pm    Post subject: Reply with quote

Well done Plons!
Thanks for sharing.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-ARDUINO All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum