PDA

View Full Version : Touchscreen question



manwolf
- 25th June 2008, 02:49
I am playing with the Touchscreen and gLCD on the EasyPIC5 and I am getting extra pixels lighting up on the screen when I draw something. They always appear at least an inch below where I have drawn a line.
I was wondering what was causing this, the code is in MikroBasic or I would post it here.

Anyway my question is what would be a good delay for debouncing the drivers? They are currently using delay_ms(2). I am assuming that is what is causing them to appear because they only appear when I lift the pen from the screen.

Any suggestions or other comments. I am going to start porting over to PBP next.

Ted's
- 25th June 2008, 18:41
Try something like
for k = 2 to (some higher number)
delay_ms(k)
next k

and print the current delay on the screen.

Should do the trick.

DaveC3
- 26th June 2008, 02:45
Ted

I had the same problem with a touch pad. The streaking in my case was pen pressure related. I added a "Pen Down" function that would only let the pad draw if the pressure was greater than a preset value. Here is the code in C



int PenDwn (void)
{
OpenADC(ADC_FOSC_64 & ADC_RIGHT_JUST & ADC_8_TAD,
ADC_CH0 & ADC_INT_OFF & ADC_REF_VDD_VSS, 11);
TS_Y1_Output; //make Y Pins outputs
TS_Y2_Output;
TS_X1_Input; //make X plates inputs
TS_X2_Input;
TS_Y1_ON; //energize Y plates
TS_Y2_ON;
SetChanADC(ADC_CH0); //select voltage channel
Delay10TCYx(200);
ConvertADC(); //read ACD
while( BusyADC());
PenPressure=(1023 & ReadADC())>>2;
if (PenPressure > 210)
{
return (TRUE); //pen pressure exceeded threshold
}
else
{
return (FALSE);
}
}





Basically energize both plates and read the output from the pad.

It worked well for me

Dave

manwolf
- 26th June 2008, 04:45
Think I might have found the answer digging around the MikroE Forums. Possible is floating ADC pins. I have the pullups disconnected as per the manual. I am going to put them back on the ADC pins and see what happens.

DaveC3 -Thanks for the suggestion, but they have something like penDown already in the code and I have played with the value with no luck. Going to rest my eyes tonight and try again tomorrow.

Acetronics2
- 26th June 2008, 07:25
Hi, manwolf,

I think the MKE Touchscreen is a bit "lazy" ... and some quick pen writings cause some surprising pixels ... due to the measuring way.

But I do not remember we were on a MkE nor C Forum, here ...

Why not ask this on the dedicated forum ??? surely more answers !

Alain

Ted's
- 26th June 2008, 09:19
Ted
It is manwolf asking not me.

manwolf, as you were not referring to me did you understand my answer?

manwolf
- 27th June 2008, 03:49
Huh?? what? when? where? How? :(

This is very confusing because my name is Ted also, so here I go.

Ted's - tried a wide range of values with no luck, however didn't have to change much for the screen to quit responding alltogether.

DAVE3C- Pendown type check already in the code. Played with the value up and down. caused a minor change bit still throwing extra pixels. Always about an inch below the pin x,y.

Acertronics - Thanks I have been digging around, that is where I came across the post for the floating ADC pins. Had invite to dinner so I haven't had a chance to test it out yet.