Example #1
0
/**
  * @brief  Display sensors information on LEDs and LCD
  * @param  status TSL user status
  * @retval None
  */
void Process_Sensors(tsl_user_status_t status)
{
#if USE_LCD > 0  
  uint8_t TheLine[20];
  uint8_t str_value[6]; /* sign + 4 digits + empty char */
#endif

#if USE_LCD > 0
  /* Display TS1 sensor information */
  LcdValue2String(str_value, MyTKeys[0].p_ChD->Delta);
  LcdMakeLine(TheLine, (uint8_t *)("TS1"), LcdState2String(MyTKeys[0].p_Data->StateId), str_value);
  BSP_LCD_DisplayStringAtLine(7, TheLine);
  /* Display TS2 sensor information */
  LcdValue2String(str_value, MyTKeys[1].p_ChD->Delta);
  LcdMakeLine(TheLine, (uint8_t *)("TS2"), LcdState2String(MyTKeys[1].p_Data->StateId), str_value);
  BSP_LCD_DisplayStringAtLine(8, TheLine);
  BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
#endif
    
  /* LED1 is ON when TS1 on board is touched */
  if (MyTKeys[0].p_Data->StateId == TSL_STATEID_DETECT)
  {
    BSP_LED_On(LED2);
  }
  else
  {
    BSP_LED_Off(LED2);
  }

  /* LED2 is ON when TS2 on board is touched */
  if (MyTKeys[1].p_Data->StateId == TSL_STATEID_DETECT)
  {
    BSP_LED_On(LED1);
  }
  else
  {
    BSP_LED_Off(LED1);
  }
  
  /* ECS information */
  switch (status)
  {
    case TSL_USER_STATUS_OK_ECS_OFF:
      BSP_LED_Off(LED4);
#if USE_LCD > 0
      BSP_LCD_DisplayStringAtLine(4, (uint8_t *)("ECS OFF"));
#endif      
      break;
    case TSL_USER_STATUS_OK_ECS_ON:
      BSP_LED_Toggle(LED4);
#if USE_LCD > 0
      BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
      BSP_LCD_DisplayStringAtLine(4, (uint8_t *)("ECS ON "));
      BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
#endif      
      break;
    default:
      break;
  }
}
Example #2
0
/**
  * @brief  Display sensors information on LEDs and LCD
  * @param  status TSL user status
  * @retval None
  */
void Process_Sensors(tsl_user_status_t status)
{
#if USE_LCD > 0  
  uint8_t TheLine[20];
  uint8_t str_value[6]; /* sign + 4 digits + empty char */
#endif

#if USE_LCD > 0
    /* Display state and position */
    LcdValue2String(str_value, MyLinRots[0].p_Data->Position);
    LcdMakeLine(TheLine, (uint8_t *)("S1 "), LcdState2String(MyLinRots[0].p_Data->StateId), str_value);
    BSP_LCD_DisplayStringAtLine(6, TheLine);
    BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
    /* Display channel's delta values */
    LcdValue2String(str_value, MyLinRots[0].p_ChD[0].Delta);
    LcdMakeLine(TheLine, (uint8_t *)("CH0"), (uint8_t *)("DELTA   "), str_value);
    BSP_LCD_DisplayStringAtLine(7, TheLine);
    LcdValue2String(str_value, MyLinRots[0].p_ChD[1].Delta);
    LcdMakeLine(TheLine, (uint8_t *)("CH1"), (uint8_t *)("DELTA   "), str_value);
    BSP_LCD_DisplayStringAtLine(8, TheLine);
    LcdValue2String(str_value, MyLinRots[0].p_ChD[2].Delta);
    LcdMakeLine(TheLine, (uint8_t *)("CH2"), (uint8_t *)("DELTA   "), str_value);
    BSP_LCD_DisplayStringAtLine(9, TheLine);
#endif    
  
  /* LEDs follow the linear position */
  BSP_LED_Off(LED1);
  BSP_LED_Off(LED2);
  BSP_LED_Off(LED3);

  if (MyLinRots[0].p_Data->StateId == TSL_STATEID_DETECT)
  {
    /* The resolution is set to 4 bits (see TSLPRM_LINROT_RESOLUTION parameter in tsl_conf_stm32f3xx.h) */
    if (MyLinRots[0].p_Data->Position >= 2)
    {
      BSP_LED_On(LED3);
    }
    
    if (MyLinRots[0].p_Data->Position >= 7)
    {
      BSP_LED_On(LED2);
    }

    if (MyLinRots[0].p_Data->Position >= 12)
    {
      BSP_LED_On(LED1);
    }
  }

  /* ECS information */
  switch (status)
  {
    case TSL_USER_STATUS_OK_ECS_OFF:
      BSP_LED_Off(LED4);
#if USE_LCD > 0
      BSP_LCD_DisplayStringAtLine(4, (uint8_t *)("ECS OFF"));
#endif      
      break;
    case TSL_USER_STATUS_OK_ECS_ON:
      BSP_LED_Toggle(LED4);
#if USE_LCD > 0
      BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
      BSP_LCD_DisplayStringAtLine(4, (uint8_t *)("ECS ON "));
      BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
#endif      
      break;
    default:
      break;
  }
}