Code from Mr.Richard (Thanks !), see post #3, works just fine.
But now I'm stuck again ...
For accurate reading of ADC I use bubble-sort algoritm, how it's presented on this forum.
Code:
Main:
nr=1
for nr = 1 to 2
For CounterA=0 to 8
ADCON0 = %10000001
Pauseus 50 ' Wait for channel to setup
ADCON0.1 = 1 ' Start conversion
While ADCON0.1=1:Wend ' Wait for conversion
DataW.HighByte=ADRESH ' Read variable from ADC and save
DataW.LowByte=ADRESL
RawData(CounterA)=DataW
Next CounterA
CounterA=0
Gosub Getsort
next nr
if adca=adcb then gosub efectuez
goto main
;============================================================================
GetSort:
If RawData(CounterA+1) < RawData(CounterA) then
DataW=RawData(CounterA)
RawData(CounterA)=RawData(CounterA+1)
RawData(CounterA+1)=DataW
If CounterA>0 then CounterA=CounterA-2
endif
CounterA=CounterA+1
If CounterA<9 then goto GetSort
DataW=0
For CounterA=3 to 6
DataW=DataW+RawData(CounterA)
Next CounterA
ADCValue=DataW>>2
if nr = 1 then
adca = adcvalue
else
adcb = adcvalue
endif
Return
;============================================================================
The code works amazing, almost no error ... for different value of ADC, I can do different tasks.
BUT ... I can not figure out how to use the procedure of short/long press in this code... since even a short press makes the code to jump to "efectuez" (where I have different commands defined).
I tried to use the same procedure as in post #3 ; I tried to put it into different places of the code, but without result ! Whatever I do, it's like pressing the button for a short time.
Bookmarks