BYTE mTouchCapAPI_GetStatusMatrixButton (MATRIXKEY *Button) { BYTE MatrixKey_Status = KEY_NOT_PRESSED; BYTE RowFlag = KEY_NOT_PRESSED; BYTE ColFlag = KEY_NOT_PRESSED; /* Check if the channel used as Row for corresponding Matrix key is pressed */ //Now check to see if the requested row is pressed if( KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus((Button->Channel_Num[0]),(Button->DecodeMethod) )) { RowFlag=KEY_PRESSED; // Used for determining ROW match } else { //Channel requested is not detected as pressed. RowFlag= KEY_NOT_PRESSED; } //Now check to see if the channel used as column for corresponding Matrix key is pressed if( KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus((Button->Channel_Num[1]),(Button->DecodeMethod) )) { ColFlag=KEY_PRESSED; // Used for determining COL match } else { //Channel requested is not detected as pressed. ColFlag= KEY_NOT_PRESSED; } // check if both the row and column corresponding to the matrix key is pressed if( (ColFlag == KEY_PRESSED) && (RowFlag == KEY_PRESSED) ) { MatrixKey_Status= KEY_PRESSED; //matrix key is pressed } else { //If both channels are not pressed, the key is not pressed MatrixKey_Status= KEY_NOT_PRESSED; //key is not pressed } return MatrixKey_Status; }
SHORT mTouchCapAPI_GetStatusSlider4Ch (SLIDER4CH *Slider) { SHORT SliderState; WORD Percent_Level = 0; if( (KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus((Slider->Channel_Num[0]),(Slider->DecodeMethod) )) || (KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus((Slider->Channel_Num[1]),(Slider->DecodeMethod) )) || (KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus((Slider->Channel_Num[2]),(Slider->DecodeMethod) )) || (KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus((Slider->Channel_Num[3]),(Slider->DecodeMethod) )) ) { /* Use the 4ch slider algorithm to get the Slider Level */ Percent_Level = mTouchCapApp_FourChannelSlider_Logic(Slider); SliderState = (SHORT)Percent_Level; } else { SliderState = -1; // For KEY_NOT_PRESSED } return SliderState; }
/******************************************************************** * Function : void mTouchCapApp_DirectKeys_Demo(void) * * PreCondition : None * * Input : None * * Output : None * * Side Effects : None * * Overview : This function will demonstrate the usage of the API's * that is associated with the Direct key Demo Board * * Note : *******************************************************************/ UINT16 mTouchCapApp_DirectKeys_Demo(void) { UINT16 ButtonStatus = 0; if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey1.Channel_Num, DirectKey1.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_1); # elif defined( PIC32MX795_ONE_PIC_MICRO_DEMO_BOARD ) mTouchCapLED_SetLED(LED_1); # else mTouchCapLED_SetLED(LED_8); # endif ButtonStatus += 1; } if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey2.Channel_Num, DirectKey2.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_2); # elif defined( PIC32MX795_ONE_PIC_MICRO_DEMO_BOARD ) mTouchCapLED_SetLED(LED_2); # else mTouchCapLED_SetLED(LED_9); # endif ButtonStatus += 2; } if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey3.Channel_Num, DirectKey3.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_3); # elif defined( PIC32MX795_ONE_PIC_MICRO_DEMO_BOARD ) mTouchCapLED_SetLED(LED_3); # else mTouchCapLED_SetLED(LED_10); # endif ButtonStatus += 4; } if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey4.Channel_Num, DirectKey4.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_4); # elif defined( PIC32MX795_ONE_PIC_MICRO_DEMO_BOARD ) mTouchCapLED_SetLED(LED_4); # else mTouchCapLED_SetLED(LED_11); # endif ButtonStatus += 8; } // Starter PIC32MX220F032D kit board has only 4 buttons #if !defined( PIC32MX220_STARTER_KIT_BOARD ) if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey5.Channel_Num, DirectKey5.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_5); # elif defined( PIC32MX795_ONE_PIC_MICRO_DEMO_BOARD ) mTouchCapLED_SetLED(LED_5); # else mTouchCapLED_SetLED(LED_12); # endif ButtonStatus += 16; } // One Pic Microcontroller Platform Demo Board has only 5 buttons # if !defined( PIC32MX795_ONE_PIC_MICRO_DEMO_BOARD ) if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey6.Channel_Num, DirectKey6.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_6); # else mTouchCapLED_SetLED(LED_13); # endif ButtonStatus += 32; } if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey7.Channel_Num, DirectKey7.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_7); # else mTouchCapLED_SetLED(LED_14); # endif ButtonStatus += 64; } if(KEY_PRESSED == mTouchCapAPI_GetChannelTouchStatus(DirectKey8.Channel_Num, DirectKey8.DecodeMethod) ) { # if defined( PIC32MX220_CAP_TOUCH_EVAL_BOARD ) mTouchCapLED_SetLED(LED_8); # else mTouchCapLED_SetLED(LED_15); # endif ButtonStatus += 128; } # endif//!defined( PIC32MX795_ONE_PIC_MICRO_DEMO_BOARD ) #endif//!defined( PIC32MX220_STARTER_KIT_BOARD ) if ( ButtonStatus == 0 ) { mTouchCapLED_SetLED(LED_NIL); } return ButtonStatus; }