BUTTONS ; scans keypad, rotary encoder, runs subs as necessary according to inputs
...
TACTILES ; detects keypresses in variable scanned from PT6315 VFD driver, which also has switch inputs.
... ; set up PT6315
; tactile press timer
movlw 0xC8 ; test the timer for double press events
subwf TMR0,W ; carry will be clear if under 200
btfss STATUS,C ; carry will be set if it's over 200
goto CLR_C ; next stage
movf tact_counter,f ; counter is set when single press occurs
btfss STATUS,Z ; don't decrement the counter past zero
decfsz tact_counter,f ; double press timer
goto CLR_C
bcf pre_fl ; flag that is set when single press occurs gets cleared if counter reaches zero
CLR_C
bcf STATUS,C
TACTILE_LOOP
; read switches from PT6315
PRES_1
btfss tactiles+1,3 ; first preset
goto PRES_2
btfsc pre_fl ; has a button already been pressed?
goto DOUBLE_1 ; do double press actions - assume it's the same button
banksel preset_1 ; presets are in MATHS2 bank
movlw preset_1 ; get address of variable, copy to BCD
pscall PRESET_COPY ; sub does return banksel and sets timer-runs count
bsf pre_fl ; set the flag, do double-press test next time
; clrf TMR0 ; not using this now, demo only
goto END_PRESETS ; exit the sub
DOUBLE_1
movf tact_counter,f
btfsc STATUS,Z
goto END_PRESETS ; timer has finished, this is another single press
SAVE_1
call GO_REVERT_BCD ; get BCD back from copy
pagesel$
banksel preset_1
movlw preset_1
goto SAVE_PRESETS
PRES_2
; detect bit 4
PRES_3
; detect bit 5
SAVE_PRESETS
pscall PRESET_SAVE ; save BCD to the preset
bcf pre_fl
END_PRESETS
call GO_DISPLAY ; show the preset
; pscall ENTER ; write the new frequency to AD9850 ; WANT MANUAL ENTER?
goto BUTTONS ; finished with timers, go back. No double-press occurred