octopuss83
Joined: 06 Nov 2011 Posts: 13
|
Capacitive Touchpad |
Posted: Mon Dec 05, 2011 12:45 pm |
|
|
hI
I want to use capacitive touchpad of the 16F1825. I try this code and he work very well for detect a push on touchpad:
Code: |
#USE TOUCHPAD (RANGE=L , THRESHOLD=4, SCANTIME=32 , L_Touch='L', S_Touch='S')
TOUCHPAD_STATE(1);
enable_interrupts(GLOBAL);
...
while(1)
{
PushTime =0;
while (!TOUCHPAD_HIT());
c=touchpad_getc();
output_high( PON_Sound);
delay_ms(500);
output_low( PON_Sound );
}
|
this work well
But I want to test a long push:
Code: |
while(1)
{
PushTime =0;
while (!TOUCHPAD_HIT());
c=touchpad_getc();
while (TOUCHPAD_HIT())
{
c=touchpad_getc();
delay_ms(50);
PushTime+=1;
}
if (PushTime >= AppuiLong ) output_high( PON_Light);
else output_high( PON_Sound);
delay_ms(500);
output_low( PON_Light );
output_low( PON_Sound );
}
|
Here the "TOUCHPAD_HIT()" function is a little strong with me.
After a "TOUCHPAD_HIT()" it's necessary to have a "c=touchpad_getc();" function to read pushed touch and reset state of "TOUCHPAD_HIT()" to 0.
And at this moment while I haven't release the touchpad, the "TOUCHPAD_HIT()" state is false and the "while" condition is false. Then I can't detect a long push (over 800ms).
Someone have an idea ?
or the original code of the CCS"capacitive touchpad " Built-in function _________________ ______________________
-- Octopuss --- |
|