just starting out with my dev board, USB Audio, and have been playing with the limited hardware that I have available to interact with. That's two switches and two LEDs.
My first hack was to get up and running with a saturating counter using the buttons to inc/dec a count value. I didn't bother with debouncing first and as expected I got multiple samples for each button press.
Then, instead of using a timer to wait the specified debounce period, I thought I'd try just waiting to sample a '1' again. This seems to work for this example which is what I don't understand. Perhaps these switches have a short bounce period but I was expecting to still get multiple samples?
What's your thinking?
Code: Select all
/* Test for button pushes */
while(1) {
select {
case p_buttonA when pinseq(0) :> void:
p_buttonA when pinseq(1) :> void;
if(count < 3)
count++;
break;
case p_buttonB when pinseq(0) :> void:
p_buttonB when pinseq(1) :> void;
if(count > 0)
count--;
break;
}