Esempio n. 1
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  int16_t accData[3];
#ifdef WITH_USART
  char msg[3] = {'0','\r','\n'};
#endif

  HAL_Init();
  HW_Init();
  BlueNRG_Init();

  while (1)
  {
    HCI_Process();
    if (set_connectable) {
      set_bluenrg_connectable();
      set_connectable = 0;
    }

    /* Blink the orange LED */
    if (HAL_GetTick() % 500 == 0)
      BSP_LED_Toggle(LED3);

    if (HAL_GetTick() % 100 == 0) {
      BSP_ACCELERO_GetXYZ(accData);
      Acc_Update(accData);
    }

#ifdef WITH_USART
    msg[0] = (msg[0] == '9')? '0' : msg[0]+1;
    if (HAL_USART_Transmit(&UsartHandle, (uint8_t *)msg, 3, 5000) != HAL_OK)
      ColorfulRingOfDeath();
#endif
  }
}
Esempio n. 2
0
/**
 * @brief  Process user input (i.e. pressing the USER button on Nucleo board)
 *         and send the updated acceleration data to the remote client.
 *
 * @param  AxesRaw_t* p_axes
 * @retval None
 */
void User_Process(AxesRaw_t* p_axes)
{
  if(set_connectable){
    setConnectable();
    set_connectable = FALSE;
  }  

  /* Check if the user has pushed the button */
  if(BSP_PB_GetState(BUTTON_KEY) == RESET)
  {
    while (BSP_PB_GetState(BUTTON_KEY) == RESET);
    
    //BSP_LED_Toggle(LED2); //used for debugging (BSP_LED_Init() above must be also enabled)
    
    if(connected)
    {
      /* Update acceleration data */
      p_axes->AXIS_X += 100;
      p_axes->AXIS_Y += 100;
      p_axes->AXIS_Z += 100;
      //PRINTF("ACC: X=%6d Y=%6d Z=%6d\r\n", p_axes->AXIS_X, p_axes->AXIS_Y, p_axes->AXIS_Z);
      Acc_Update(p_axes);
    }
  }
}
Esempio n. 3
0
/**
 * @brief  Process user input (i.e. pressing the USER button on Nucleo board)
 *         and send the updated acceleration data to the remote client.
 *
 * @param  Acc_t* p_axes
 * @retval None
 */
void User_Process(short pitch, short roll)
{
  if(set_connectable){
    setConnectable();
    set_connectable = FALSE;
  }  

  /* Check if the user has pushed the button */
  if(BSP_PB_GetState(BUTTON_KEY) == RESET)
  {
    while (BSP_PB_GetState(BUTTON_KEY) == RESET);
    
    //BSP_LED_Toggle(LED2); //used for debugging (BSP_LED_Init() above must be also enabled)
    
    if(connected)
    {
      PRINTF("User pressed button! ACC: X=%6d Y=%6d\n", pitch, roll);
      Acc_Update(pitch, roll);
    }
  }
}