Debouncing, this is done as an inc / dec function, a pressed state increases an internal counter and a de-pressed state decreases it, if a 'confirmed' level is reached the button is marked as pressed and whatever function assigned to it is serviced. This of course works well if there's not much else happenning in the main program loop, currently there's only five buttons connected being checked and an LCD update function. If I throw in the 80ms sample loop in the main program loop the buttons will be slower to react with the code as is, but I should be able to adjust the 'confirmed' level values (most of the debouncing will be done whilst the DATA line is being sampled). I'd much rather have the DATA sampling done based on interrupts, but with the timer INTs already enabled, there's going to be clashes and prioritising which would take a lot of work arounds.
The only problem I see here is sampling the incoming data, which effectively means doing a long loop waiting for the CLK signal to change and reading the DATA bits. This would mean 80ms just sitting there reading the data as it has to be done in one go, unlike the button servicing which can be split across several main program loops.I'd like to read the data from the calipers at least once every 100ms, so that when the timer value on the LCD is updated, the calipers reading can be updated as well (there's other reasons for a quick update as well - the reading shouldn't be allowed below a certain level, so if I sample the caliper slowly this functionality won't work). Of course the data stream takes roughly 80ms, so there's no way to read it more than once in a single 100ms window.
T.