Skip to content

Commit

Permalink
updated examples to fix issue #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Preston committed Oct 30, 2014
1 parent 5377c46 commit 6c0af02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions example-interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,13 @@ int main(int argc, char *argv[])
}
else {
printf("Waiting for input (press any button on the PiFaceDigital)\n");
interrupt_ret = pifacedigital_wait_for_input(-1, hw_addr);
interrupt_ret = pifacedigital_wait_for_input(&inputs, 5, hw_addr);
if (interrupt_ret > 0) {
printf("Inputs: 0x%x\n", inputs);
printf("Interrupt detected. Inputs: 0x%x\n", inputs);
} else if (interrupt_ret == 0) {
printf("Interrupt timeout\n");
} else {
printf("Interrupt error\n");
}
}

Expand Down
11 changes: 9 additions & 2 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ int main( int argc, char *argv[] )
{
uint8_t i = 0; /**< Loop iterator */
uint8_t inputs; /**< Input bits (pins 0-7) */
int interrupt_ret; /* Interrupt return value */
int hw_addr = 0; /**< PiFaceDigital hardware address */
int intenable = 1; /**< Whether or not interrupts are enabled */

Expand Down Expand Up @@ -122,8 +123,14 @@ int main( int argc, char *argv[] )
}
else {
printf("Waiting for input (press any button on the PiFaceDigital)\n");
inputs = pifacedigital_wait_for_input(-1, hw_addr);
printf("Inputs: 0x%x\n", inputs);
interrupt_ret = pifacedigital_wait_for_input(&inputs, 5, hw_addr);
if (interrupt_ret > 0) {
printf("Interrupt detected. Inputs: 0x%x\n", inputs);
} else if (interrupt_ret == 0) {
printf("Interrupt timeout\n");
} else {
printf("Interrupt error\n");
}
}

/**
Expand Down

0 comments on commit 6c0af02

Please sign in to comment.