/** * @brief Sends data out of a specific type on the XBee for a period of time. * @param data: the data to be sent. * @param len: the amount of data being sent. * @param type: the type of the BloxFrame. * @param dst_id: the dest xbee id to send to. * @param millis: the amount to continue transmission. * @retval None. */ void Blox_XBee_Send_Period (uint8_t *data, uint32_t len, BloxFrameType type, uint32_t dst_id, uint32_t millis) { uint32_t cur_time = SysTick_Get_Milliseconds(); while (SysTick_Get_Milliseconds() < cur_time+millis) { Blox_XBee_Send(data, len, type, dst_id); } }
/** * @brief Determines gesture movement from pre-populated tracking gesture array * @retval None */ void Blox_gestureHandler(int touchNumber){ // uint16_t xavg_1, xavg_2, yavg_1, yavg_2 = 0; int gestureNow=0; int counter =0; int XMov =0; int YMov = 0; int XStart = XVals[touchNumber-1][0]; int YStart = YVals[touchNumber-1][0]; int XEnd = XVals[touchNumber-1][val[touchNumber-1]-1]; int YEnd = YVals[touchNumber-1][val[touchNumber-1]-1]; if((XStart-XEnd)>XTHRESH) XMov = TOUCH_GESTURE_RL; else if((XEnd-XStart)>XTHRESH) XMov = TOUCH_GESTURE_LR; else if((XStart-XEnd)<XNOMOV) XMov = TOUCH_X_STABLE; if((YStart-YEnd)>YTHRESH) YMov = TOUCH_GESTURE_DU; else if((YEnd-YStart)>YTHRESH) YMov = TOUCH_GESTURE_UD; else if((YStart-YEnd)<YNOMOV) YMov = TOUCH_Y_STABLE; gestureNow = XMov*YMov; switch(gestureNow){ case 3: // LR and DU = Diagonal bottom left to top right gestureNow = TOUCH_DIAG_DLUR; break; case 4: // LR and UD = Diagonal top left to bottom right gestureNow = TOUCH_DIAG_ULDR; break; case -1: // LR (Y Stable) gestureNow = TOUCH_GESTURE_LR; break; case 6: // RL and DU = Diagonal bottom right to top left gestureNow = TOUCH_DIAG_DRUL; break; case 8: // RL and UD = Diagonal top right to bottom left gestureNow = TOUCH_DIAG_URDL; break; case -2: // RL (Y stable) gestureNow = TOUCH_GESTURE_RL; break; case -4: //UD (X stable) gestureNow = TOUCH_GESTURE_UD; break; case -3 : //DU (X stable) gestureNow = TOUCH_GESTURE_DU; break; case 1: // Tap (X stable and Y stable) gestureNow = TOUCH_GESTURE_TAP; break; } //Blox_LED_Toggle(3); //DEBUG LastGesture[touchNumber-1].timestamp=SysTick_Get_Milliseconds(); LastGesture[touchNumber-1].gesture=gestureNow; val[0]=val[1]=val[2]=val[3]=0; //clear for(counter=0; counter<50; counter++) //clear memory { XVals[touchNumber-1][counter]=0; YVals[touchNumber-1][counter]=0; } }