Hello Mikroe team,
here is code for Mikrobasic Pro for PIC32 and Visual TFT for Touch screen controler XPT2046:
--------------------------------------------------------------------
module xpt2046
' Use HW spi2 modul
dim Xcoord as word external
Ycoord as word external
PenDown as byte external
dim SPI_TP_CS as sbit at LATD8_bit
SPI_TP_CS_Direction as sbit at TRISD8_bit
SPI_TP_IRQ as sbit at PORTD.B11
SPI_TP_IRQ_Direction as sbit at TRISD11_bit
dim xvysl as word
yvysl as word
xnativ as word
ynativ as word
sub procedure SPI_TP_Init()
sub procedure SPI_TP_Check()
sub function SPI_TP_Read_Once(dim address as char) as word
sub function SPI_TP_Get_Coordinates() as char
sub procedure SPI_TP_Info(dim sloupec as word,dim radek as word,dim barva as word)
implements
sub procedure SPI_TP_Init()
SPI_TP_CS_Direction = 0
SPI_TP_IRQ_Direction = 1
SPI_TP_CS = 0
SPI2_Init_Advanced(_SPI_MASTER, _SPI_8_BIT, 1024, _SPI_SS_DISABLE, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_IDLE_2_ACTIVE)
SPI_TP_IRQ_Direction = 1
SPI_TP_CS = 1
Xcoord = 0
Ycoord = 0
end sub
sub function SPI_TP_Read_Once(dim address as char) as word
dim hodnota as word
SPI2_Write(address)
hodnota = SPI2_Read(0)
hodnota = hodnota << 8
hodnota = hodnota + SPI2_Read(0)
hodnota = hodnota >> 3 ' Prise en charge CLK pendant BUSY
result = hodnota
end sub
sub function SPI_TP_Get_Coordinates() as char
dim x as word
y as word
dim x_min as word
x_max as word
y_min as word
y_max as word
dim x_div as float
y_div as float
'char debug_text[100]
x_min = 200
x_max = 3900
y_min = 200
y_max = 3900
SPI_TP_CS = 0
x = SPI_TP_Read_Once(0xD0)
y = SPI_TP_Read_Once(0x90)
SPI_TP_CS = 1
'sprintf(debug_text, "X = %u ; Y = %u", x, y);
'UART4_Write_Text(debug_text);
'UART4_Write(13);
'UART4_Write(10);
ynativ=y
xnativ=x
if (x = 0) or (x = 4095) or (y = 0) or (y = 4095) then
result= 1
exit
end if
if x < x_min then
x = x_min
end if
if x > x_max then
x = x_max
end if
if y < y_min then
y = y_min
end if
if y > y_max then
y = y_max
end if
x = x-x_min
y = y-y_min
x_div = x_max
x_div = x_div - x_min
x_div = x_div / 800
y_div = y_max
y_div = y_div - y_min
y_div = y_div / 480
x = x / x_div
y = y / y_div
xvysl = x
yvysl = y
result= 0
end sub
sub procedure SPI_TP_Check()
if SPI_TP_IRQ = 0 then
if SPI_TP_Get_Coordinates() = 0 then
TFT_Dot(Xvysl, Yvysl, CL_white)
TFT_Dot(Xvysl + 1, Yvysl, CL_white)
TFT_Dot(Xvysl, Yvysl + 1, CL_white)
TFT_Dot(Xvysl + 1, Yvysl + 1, CL_white)
delay_ms(200) ' Anti rebond
TFT_Dot(Xvysl, Yvysl, CL_BLACK)
TFT_Dot(Xvysl + 1, Yvysl, CL_BLACK)
TFT_Dot(Xvysl, Yvysl + 1, CL_BLACK)
TFT_Dot(Xvysl + 1, Yvysl + 1, CL_BLACK)
end if
end if
end sub
sub procedure SPI_TP_Info(dim sloupec as word,dim radek as word,dim barva as word)
dim txt65buf as string[5]
dim txt66buf as string[5]
dim txt67buf as string[14]
if SPI_TP_IRQ = 0 then
txt67buf=""
txt66buf=""
txt65buf=""
WordToStr(xnativ, txt65buf)
WordToStr(ynativ, txt66buf)
txt67buf=txt65buf+","+txt66buf
TFT_Set_Pen(CL_black, 1)
TFT_Write_Text(txt67buf, sloupec, radek)
' TFT_Set_Pen(CL_white, 12)
TFT_Set_Brush(1, 1, 0, LEFT_TO_RIGHT, CL_white, CL_white)
TFT_Rectangle(sloupec, radek, sloupec+50, radek+12)
' TFT_Line(sloupec, radek, sloupec+55, radek)
end if
end sub
end.
----------------------------------------------------------------------------------------------------
SUB Check_TP() for VISUAL TFT
sub procedure Check_TP()
if SPI_TP_IRQ = 0 then
' After a PRESS is detected read X-Y and convert it to 128x64 space
if (SPI_TP_Get_Coordinates=0) then
Process_TP_Press(Xvysl, Yvysl)
if PenDown = 0 then
PenDown = 1
Process_TP_Down(Xvysl, Yvysl)
end if
end if
else
if PenDown = 1 then
PenDown = 0
Process_TP_Up(Xvysl, Yvysl)
end if
end if
end sub
Would it be possible for this module and procedure for Visual TFT integrated into Visual TFT as an additional touch controler.
It is very annoying after each change in Visual TFT rewrite automatic insertion routine !!!!
Thank you
Routines for Touch controler XPT2046
Post your requests and ideas on the future development of Visual TFT Software.
Author
Message
- aleksa.jovanovic
- Posts: 526
- Joined: 30 Jun 2015 08:48
Re: Routines for Touch controler XPT2046
#2 Post by aleksa.jovanovic » 02 Sep 2015 14:33
Please refer to this post
http://www.mikroe.com/forum/viewtopic.php?f=162&t=59392
Best regards,
Aleksa
http://www.mikroe.com/forum/viewtopic.php?f=162&t=59392
Best regards,
Aleksa
Re: Routines for Touch controler XPT2046
#3 Post by Jardik » 02 Sep 2015 20:13
Hello,
And when you integrate into the Visual Controller XPT2046 TFT ???
The hardest work - functional code is complete. The only thing left to integrate into the Visual TFT. It must do Mikroe team.
Tell us any specific binding deadline integration ???
Thank you
And when you integrate into the Visual Controller XPT2046 TFT ???
The hardest work - functional code is complete. The only thing left to integrate into the Visual TFT. It must do Mikroe team.
Tell us any specific binding deadline integration ???
Thank you
- aleksa.jovanovic
- Posts: 526
- Joined: 30 Jun 2015 08:48
Re: Routines for Touch controler XPT2046
#4 Post by aleksa.jovanovic » 03 Sep 2015 08:43
Hi,
I can't tell you at this point when it will be.
It is on our software team to do list and there is no specific date listed there.
Please avoid posting multiple posts with the same message. Thanks.
Best regards,
Aleksa
I can't tell you at this point when it will be.
It is on our software team to do list and there is no specific date listed there.
Please avoid posting multiple posts with the same message. Thanks.
Best regards,
Aleksa
Return to “Visual TFT Wish List”
Jump to
- NECTO Studio
- ↳ IDE
- ↳ IDE General
- ↳ IDE Beta Testing
- ↳ IDE Wish List
- ↳ ARM AI Compilers
- ↳ mikroC AI for ARM
- ↳ mikroC AI for ARM General
- ↳ mikroC AI for ARM Beta Testing
- ↳ mikroC AI for ARM Wish List
- ↳ PIC AI compilers
- ↳ mikroC AI for PIC
- ↳ mikroC AI for PIC General
- ↳ mikroC AI for PIC Beta Testing
- ↳ mikroC AI for PIC Wish List
- ↳ PIC32 AI Compilers
- ↳ mikroC AI for PIC32
- ↳ mikroC AI for PIC32 General
- ↳ mikroC AI for PIC32 Beta Testing
- ↳ mikroC AI for PIC32 Wish List
- ↳ dsPIC AI Compilers
- ↳ mikroC AI for dsPIC
- ↳ mikroC AI for dsPIC General
- ↳ mikroC AI for dsPIC Beta Testing
- ↳ mikroC AI for dsPIC Wish List
- ↳ AVR AI Compilers
- ↳ mikroC AI for AVR
- ↳ mikroC AI for AVR General
- ↳ mikroC AI for AVR Beta Testing
- ↳ mikroC AI for AVR Wish List
- ↳ Additional Software
- ↳ Visual TFT AI
- ↳ Visual TFT AI General
- ↳ Visual TFT AI Beta Testing
- ↳ Visual TFT AI Wish List
- PRO Compilers
- ↳ PIC PRO Compilers
- ↳ PIC Compilers General
- ↳ mikroC PRO for PIC
- ↳ mikroC PRO for PIC General
- ↳ mikroC PRO for PIC Beta Testing
- ↳ mikroC PRO for PIC Wish List
- ↳ mikroBasic PRO compiler for PIC
- ↳ mikroBasic PRO for PIC General
- ↳ mikroBasic PRO for PIC Beta Testing
- ↳ mikroBasic PRO for PIC Wish List
- ↳ mikroPascal PRO for PIC
- ↳ mikroPascal PRO for PIC General
- ↳ mikroPascal PRO for PIC Beta Testing
- ↳ mikroPascal PRO for PIC Wish List
- ↳ dsPIC PRO Compilers
- ↳ dsPIC Compilers General
- ↳ mikroC PRO for dsPIC30/33 and PIC24
- ↳ mikroC PRO for dsPIC30/33 and PIC24 General
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 General
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic PRO for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 General
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal PRO for dsPIC30/33 and PIC24 Wish List
- ↳ PIC32 PRO Compilers
- ↳ PIC32 Compilers General
- ↳ mikroC PRO for PIC32
- ↳ mikroC PRO for PIC32 General
- ↳ mikroC PRO for PIC32 Beta Testing
- ↳ mikroC PRO for PIC32 Wish List
- ↳ mikroBasic PRO for PIC32
- ↳ mikroBasic PRO for PIC32 General
- ↳ mikroBasic PRO for PIC32 Beta Testing
- ↳ mikroBasic PRO for PIC32 Wish List
- ↳ mikroPascal PRO for PIC32
- ↳ mikroPascal PRO for PIC32 General
- ↳ mikroPascal PRO for PIC32 Beta Testing
- ↳ mikroPascal PRO for PIC32 Wish List
- ↳ AVR PRO Compilers
- ↳ AVR Compilers General
- ↳ mikroC PRO for AVR
- ↳ mikroC PRO for AVR General
- ↳ mikroC PRO for AVR Beta Testing
- ↳ mikroC PRO for AVR Wish List
- ↳ mikroBasic PRO compiler for AVR
- ↳ mikroBasic PRO for AVR General
- ↳ mikroBasic PRO for AVR Beta Testing
- ↳ mikroBasic PRO for AVR Wish List
- ↳ mikroPascal PRO for AVR
- ↳ mikroPascal PRO for AVR General
- ↳ mikroPascal PRO for AVR Beta Testing
- ↳ mikroPascal PRO for AVR Wish List
- ↳ FT90x PRO Compilers
- ↳ FT90x Compilers General
- ↳ mikroC PRO for FT90x
- ↳ mikroC PRO for FT90x General
- ↳ mikroC PRO for FT90x Beta Testing
- ↳ mikroC PRO for FT90x Wish List
- ↳ mikroBasic PRO compiler for FT90x
- ↳ mikroBasic PRO for FT90x General
- ↳ mikroBasic PRO for FT90x Beta Testing
- ↳ mikroBasic PRO for FT90x Wish List
- ↳ mikroPascal PRO for FT90x
- ↳ mikroPascal PRO for FT90x General
- ↳ mikroPascal PRO for FT90x Beta Testing
- ↳ mikroPascal PRO for FT90x Wish List
- ↳ 8051 PRO Compilers
- ↳ 8051 Compilers General
- ↳ mikroC PRO for 8051
- ↳ mikroC PRO for 8051 General
- ↳ mikroC PRO for 8051 Beta Testing
- ↳ mikroC PRO for 8051 Wish List
- ↳ mikroBasic PRO compiler for 8051
- ↳ mikroBasic PRO for 8051 General
- ↳ mikroBasic PRO for 8051 Beta Testing
- ↳ mikroBasic PRO for 8051 Wish List
- ↳ mikroPascal PRO for 8051
- ↳ mikroPascal PRO for 8051 General
- ↳ mikroPascal PRO for 8051 Beta Testing
- ↳ mikroPascal PRO for 8051 Wish List
- ↳ ARM PRO Compilers
- ↳ ARM Compilers General
- ↳ mikroC PRO for ARM
- ↳ mikroC PRO for ARM General
- ↳ mikroC PRO for ARM Beta Testing
- ↳ mikroC PRO for ARM Wish List
- ↳ mikroBasic PRO for ARM
- ↳ mikroBasic PRO for ARM General
- ↳ mikroBasic PRO for ARM Beta Testing
- ↳ mikroBasic PRO for ARM Wish List
- ↳ mikroPascal PRO for ARM
- ↳ mikroPascal PRO for ARM General
- ↳ mikroPascal PRO for ARM Beta Testing
- ↳ mikroPascal PRO for ARM Wish List
- ↳ Older versions of Compilers
- ↳ Older versions of mikroC Compilers
- ↳ mikroC for PIC
- ↳ mikroC General
- ↳ mikroC Beta Testing
- ↳ mikroC Wish List
- ↳ mikroC for dsPIC30/33 and PIC24
- ↳ mikroC for dsPIC30/33 and PIC24 General
- ↳ mikroC for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroC for dsPIC30/33 and PIC24 Wish List
- ↳ RSC-4x mikroC
- ↳ RSC-4x mikroC General
- ↳ RSC-4x mikroC Wish List
- ↳ mikroC Beta testing
- ↳ Older versions of mikroBasic Compilers
- ↳ mikroBasic compiler for PIC
- ↳ mikroBasic General
- ↳ mikroBasic Beta Testing
- ↳ mikroBasic Wish List
- ↳ mikroBasic compiler for dsPIC30/33 and PIC24
- ↳ mikroBasic for dsPIC30/33 and PIC24 General
- ↳ mikroBasic for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroBasic for dsPIC30/33 and PIC24 Wish List
- ↳ mikroBasic for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroBasic compiler for AVR
- ↳ mikroBasic for AVR General
- ↳ mikroBasic for AVR Wish List
- ↳ mikroBasic Beta testing
- ↳ Older versions of mikroPascal Compilers
- ↳ mikroPascal compiler for PIC
- ↳ mikroPascal FAQ
- ↳ mikroPascal General
- ↳ mikroPascal Beta Testing
- ↳ mikroPascal Wish List
- ↳ mikroPascal Bug List
- ↳ mikroPascal compiler for dsPIC30/33 and PIC24
- ↳ mikroPascal for dsPIC30/33 and PIC24 General
- ↳ mikroPascal for dsPIC30/33 and PIC24 Beta Testing
- ↳ mikroPascal for dsPIC30/33 and PIC24 Wish List
- ↳ mikroPascal for dsPIC30/33 and PIC24 Bug List
- ↳ Obsolete Project: mikroPascal compiler for AVR
- ↳ mikroPascal for AVR General
- ↳ mikroPascal for AVR Wish List
- ↳ mikroPascal Beta testing
- ↳ Library Development Discussion
- ↳ Code Requests
- Additional Software
- ↳ Visual TFT Software
- ↳ Visual TFT General
- ↳ Visual TFT Beta Testing
- ↳ Visual TFT Wish List
- ↳ Visual GLCD Software
- ↳ Visual GLCD General
- ↳ Visual GLCD Beta Testing
- ↳ Visual GLCD Wish List
- ↳ Package Manager Software
- ↳ Package Manager General
- ↳ Package Manager Beta Testing
- ↳ Package Manager Wishlist
- ↳ GLCD Font Creator Software
- ↳ SpeakUp Software
- ↳ Timer Calculator
- ↳ CAN Calculator
- ↳ mikroBootloader
- Hardware
- ↳ Development Boards
- ↳ CODEGRIP programmer and debugger
- ↳ Mikromedia
- ↳ mikroProg™ programmer and debugger
- ↳ Development Boards Wishlist
- ↳ Review
- ↳ Click Boards release
- ↳ Hexiwear
- Website & Forums
- ↳ Libstock Discussion
- ↳ Product Announcements
- ↳ Website & Forums General Discussion
- ↳ Website & Forums Wishlist
- ↳ User Projects