Ι'm using Dspic30F6012A with XPT2046 touch controler, on an OEM TFT screen.
Visual TFT is a great program.
But if "Enable touch panel" is unchecked then it dosen't include events for buttons into the genarated code.
So I need a "dummy touch Screen controler" who will include all events except the initialization and declare segment
It needs only Xcoord and Ycoord (which are globals) have the correct valuses Check_tp function do the rest as it dose now
OR
suggest me an other way to include events into the genarated code with "Enable Touch panel" unchecked
Minas Kalarakis
wish, for dummy Touch screen controler
- petar.timotijevic
- mikroElektronika team
- Posts: 1739
- Joined: 19 Feb 2014 13:46
- Location: Serbia
- Contact:
Re: wish, for dummy Touch screen controler
Hi,
In VisualTFT software user can select between the default touch panel controller type located on mikroElektronika boards, STMPE610 touchpanel controller type located on the mikroMedia Plus boards, FT800 touch panel controller and TSC2006 touch panel controller.
Please see VisualTFT project examples and Touch Panel TFT Library.
mikroC Pro for dsPIC - Touch Panel TFT Library
http://www.mikroe.com/download/eng/docu ... &width=970
Best regards,
Peter
In VisualTFT software user can select between the default touch panel controller type located on mikroElektronika boards, STMPE610 touchpanel controller type located on the mikroMedia Plus boards, FT800 touch panel controller and TSC2006 touch panel controller.
Please see VisualTFT project examples and Touch Panel TFT Library.
mikroC Pro for dsPIC - Touch Panel TFT Library
http://www.mikroe.com/download/eng/docu ... &width=970
Best regards,
Peter
Re: wish, for dummy Touch screen controler
I use an OEM TFT screen, with XPT2046 T. controller.
Now I use Visual TFT to design screens.
as Visual TFT is a new utility - program it has some bugs inside but I can bypass them.
as I said above XPT2046 is an spi controller. I wrote functions to Initialize and got X,Y.
Now from visual TFT I need the Touch Functions like checkTP() Press_up etc to be in the exported code
Without the ADC functions.
At this time I leave Touch controller enabled and I export the code to the compiler IDE, then I delete manually all about the ADC.
Inside Checktp() I call my function and get Xcoord , Ycoord and all works well.
This is the manual mode, the automation is better.
Now I use Visual TFT to design screens.
as Visual TFT is a new utility - program it has some bugs inside but I can bypass them.
as I said above XPT2046 is an spi controller. I wrote functions to Initialize and got X,Y.
Now from visual TFT I need the Touch Functions like checkTP() Press_up etc to be in the exported code
Without the ADC functions.
At this time I leave Touch controller enabled and I export the code to the compiler IDE, then I delete manually all about the ADC.
Inside Checktp() I call my function and get Xcoord , Ycoord and all works well.
This is the manual mode, the automation is better.
- petar.timotijevic
- mikroElektronika team
- Posts: 1739
- Joined: 19 Feb 2014 13:46
- Location: Serbia
- Contact:
Re: wish, for dummy Touch screen controler
Hi,
I'm glad to see that you find a solution.
We have plans to support XPT2046 in VisualTFT software.
Best regards,
Peter
I'm glad to see that you find a solution.
We have plans to support XPT2046 in VisualTFT software.
Best regards,
Peter
Re: wish, for dummy Touch screen controler
Hello Minas and petar.timotijevic,
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
And finally, a question for petar.timotijevic:
Once you are finished module and procedure for Visual TFT, when finally you integrate touch controler XPT2046 in Visual TFT or expand library Touch TFT panel for compiler MIKROE on this controler ???
It is very annoying after each change in Visual TFT rewrite automatic insertion routine !!!!
Thank you
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
And finally, a question for petar.timotijevic:
Once you are finished module and procedure for Visual TFT, when finally you integrate touch controler XPT2046 in Visual TFT or expand library Touch TFT panel for compiler MIKROE on this controler ???
It is very annoying after each change in Visual TFT rewrite automatic insertion routine !!!!
Thank you
Re: wish, for dummy Touch screen controler
Hi Jardik,
I use mikroC pro for Dspic in my projects.
I had to write functions like them use implement for microBasic.
Unfortunally MikroE has do nothing to improve IDE at ver 4.50
All my wishes are still wishes
Still, I have an "Italian Spaghetti" code etc
And of course it is very annoying to delete auto insertion code at each change
I use mikroC pro for Dspic in my projects.
I had to write functions like them use implement for microBasic.
Unfortunally MikroE has do nothing to improve IDE at ver 4.50
All my wishes are still wishes
Still, I have an "Italian Spaghetti" code etc
And of course it is very annoying to delete auto insertion code at each change
- aleksa.jovanovic
- Posts: 526
- Joined: 30 Jun 2015 08:48
Re: wish, for dummy Touch screen controler
Please look at my answer here.
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: wish, for dummy Touch screen controler
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: wish, for dummy Touch screen controler
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
-
- Posts: 71
- Joined: 11 Jul 2015 17:59
Re: wish, for dummy Touch screen controler
Hi,
can i use this example to work without VisualTFT?
can i use this example to work without VisualTFT?