AN370
Rev. 1.0
33
7.2.5. Application Considerations
It is the responsibility of the main application to remember the current state of the buttons being currently service.
By other words, when the application uses wBsr_Pop() function it needs to remember the button vector.
For example, application is waiting for a button press. If single button pressed and held, the button press item will
be entered into the PTS FIFO. The application calls the bBts_GetPtsItemCount(), which will return 1. The
application then calls wBts_Pop() to get the button vector and a button press timestamp. After the pop the FIFO is
empty. After the button is serviced the application should call the bBts_GetPtsItemCount() again to determine
whether the button press status changed. If the PTS FIFO is still empty, that means that the original button situation
has not changed and the application therefore concludes that the button is still being pressed.
If that happens application could call bBsr_GetTimestamp() function and compare the original button press
timestamp with the current time to determine time duration of the current button status. It is up to the application to
take care of “stuck” buttons.
Main application
:
/*
*------------------------------------------------------------------------------
*
* MACROS:
*/
/* Size of FIFO of captured buttons .. max number of unserviced button changes */
#define bPtsSize_c (10U)
/*
*------------------------------------------------------------------------------
*
* VARIABLES:
*/
/* Interested to hold at most 10 button presses before processing them */
tBsr_PtsElement xdata arPtsArray[bPtsSize_c];
/* BSR control structure */
tBsr_Setup xdata rBsrSetup;
/* Return structure as WORD */
WORD wPtsButton;
/*
*------------------------------------------------------------------------------
*/