/*! * \brief Event called in the event of a long key press detected. * \param keys The keyboard port content * \param event The event kind */ static void KEYDBNC_OnDebounceEvent(DBNC_EventKinds event, DBNC_KeySet keys) { switch(event) { /* pressed */ case DBNC_EVENT_PRESSED: #if PL_CONFIG_NOF_KEYS >= 1 if (keys&(1<<0)) { EVNT_SetEvent(EVNT_SW1_PRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 2 if (keys&(1<<1)) { EVNT_SetEvent(EVNT_SW2_PRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 3 if (keys&(1<<2)) { EVNT_SetEvent(EVNT_SW3_PRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 4 if (keys&(1<<3)) { EVNT_SetEvent(EVNT_SW4_PRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 5 if (keys&(1<<4)) { EVNT_SetEvent(EVNT_SW5_PRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 6 if (keys&(1<<5)) { EVNT_SetEvent(EVNT_SW6_PRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 7 if (keys&(1<<6)) { EVNT_SetEvent(EVNT_SW7_PRESSED); } #endif break; /* long pressed */ case DBNC_EVENT_LONG_PRESSED: #if PL_CONFIG_NOF_KEYS >= 1 if (keys&(1<<0)) { EVNT_SetEvent(EVNT_SW1_LPRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 2 if (keys&(1<<1)) { EVNT_SetEvent(EVNT_SW2_LPRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 3 if (keys&(1<<2)) { EVNT_SetEvent(EVNT_SW3_LPRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 4 if (keys&(1<<3)) { EVNT_SetEvent(EVNT_SW4_LPRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 5 if (keys&(1<<4)) { EVNT_SetEvent(EVNT_SW5_LPRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 6 if (keys&(1<<5)) { EVNT_SetEvent(EVNT_SW6_LPRESSED); } #endif #if PL_CONFIG_NOF_KEYS >= 7 if (keys&(1<<6)) { EVNT_SetEvent(EVNT_SW7_LPRESSED); } #endif break; /* released */ case DBNC_EVENT_RELEASED: #if PL_CONFIG_NOF_KEYS >= 1 if (keys&(1<<0)) { EVNT_SetEvent(EVNT_SW1_RELEASED); } #endif #if PL_CONFIG_NOF_KEYS >= 2 if (keys&(1<<1)) { EVNT_SetEvent(EVNT_SW2_RELEASED); } #endif #if PL_CONFIG_NOF_KEYS >= 3 if (keys&(1<<2)) { EVNT_SetEvent(EVNT_SW3_RELEASED); } #endif #if PL_CONFIG_NOF_KEYS >= 4 if (keys&(1<<3)) { EVNT_SetEvent(EVNT_SW4_RELEASED); } #endif #if PL_CONFIG_NOF_KEYS >= 5 if (keys&(1<<4)) { EVNT_SetEvent(EVNT_SW5_RELEASED); } #endif #if PL_CONFIG_NOF_KEYS >= 6 if (keys&(1<<5)) { EVNT_SetEvent(EVNT_SW6_RELEASED); } #endif #if PL_CONFIG_NOF_KEYS >= 7 if (keys&(1<<6)) { EVNT_SetEvent(EVNT_SW7_RELEASED); } #endif break; case DBNC_EVENT_END: /*! \todo Implement what you have to do at the end of the debouncing. Need to re-enable interrupts? */ #if PL_CONFIG_HAS_KBI KEY_EnableInterrupts(); #endif break; } /* switch */ }
/*! * \brief Event called in the event of a long key press detected. * \param keys The keyboard port content * \param event The event kind */ static void KEYDBNC_OnDebounceEvent(DBNC_EventKinds event, DBNC_KeySet keys) { switch(event) { /* pressed */ case DBNC_EVENT_PRESSED: #if PL_NOF_KEYS >= 1 if (keys==(1<<0)) { EVNT_SetEvent(EVNT_SW_A_PRESSED); } #endif #if PL_NOF_KEYS >= 2 if (keys==(1<<1)) { EVNT_SetEvent(EVNT_SW_B_PRESSED); } #endif #if PL_NOF_KEYS >= 3 if (keys==(1<<2)) { EVNT_SetEvent(EVNT_SW_C_PRESSED); } #endif #if PL_NOF_KEYS >= 4 if (keys==(1<<3)) { EVNT_SetEvent(EVNT_SW_D_PRESSED); } #endif #if PL_NOF_KEYS >= 5 if (keys==(1<<4)) { EVNT_SetEvent(EVNT_SW_E_PRESSED); } #endif #if PL_NOF_KEYS >= 6 if (keys==(1<<5)) { EVNT_SetEvent(EVNT_SW_F_PRESSED); } #endif #if PL_NOF_KEYS >= 7 if (keys==(1<<6)) { EVNT_SetEvent(EVNT_SW_G_PRESSED); } #endif break; /* long pressed */ case DBNC_EVENT_LONG_PRESSED: #if PL_NOF_KEYS >= 1 if (keys==(1<<0)) { EVNT_SetEvent(EVNT_SW_A_LPRESSED); } #endif #if PL_NOF_KEYS >= 2 if (keys==(1<<1)) { EVNT_SetEvent(EVNT_SW_B_LPRESSED); } #endif #if PL_NOF_KEYS >= 3 if (keys==(1<<2)) { EVNT_SetEvent(EVNT_SW_C_LPRESSED); } #endif #if PL_NOF_KEYS >= 4 if (keys==(1<<3)) { EVNT_SetEvent(EVNT_SW_D_LPRESSED); } #endif #if PL_NOF_KEYS >= 5 if (keys==(1<<4)) { EVNT_SetEvent(EVNT_SW_E_LPRESSED); } #endif #if PL_NOF_KEYS >= 6 if (keys==(1<<5)) { EVNT_SetEvent(EVNT_SW_F_LPRESSED); } #endif #if PL_NOF_KEYS >= 7 if (keys==(1<<6)) { EVNT_SetEvent(EVNT_SW_G_LPRESSED); } #endif break; /* released */ case DBNC_EVENT_RELEASED: #if PL_NOF_KEYS >= 1 if (keys==(1<<0)) { EVNT_SetEvent(EVNT_SW_A_RELEASED); } #endif #if PL_NOF_KEYS >= 2 if (keys==(1<<1)) { EVNT_SetEvent(EVNT_SW_B_RELEASED); } #endif #if PL_NOF_KEYS >= 3 if (keys==(1<<2)) { EVNT_SetEvent(EVNT_SW_C_RELEASED); } #endif #if PL_NOF_KEYS >= 4 if (keys==(1<<3)) { EVNT_SetEvent(EVNT_SW_D_RELEASED); } #endif #if PL_NOF_KEYS >= 5 if (keys==(1<<4)) { EVNT_SetEvent(EVNT_SW_E_RELEASED); } #endif #if PL_NOF_KEYS >= 6 if (keys==(1<<5)) { EVNT_SetEvent(EVNT_SW_F_RELEASED); } #endif #if PL_NOF_KEYS >= 7 if (keys==(1<<6)) { EVNT_SetEvent(EVNT_SW_G_RELEASED); } #endif break; case DBNC_EVENT_END: /*! \todo Implement what you have to do at the end of the debouncing */ #if PL_HAS_KBI KEY_EnableInterrupts(); #endif break; } /* switch */ }