Пример #1
0
/**************************************************************************//**
 * @brief Update TFT with temperature
 * @param[in] temp Temperature to display.
 *****************************************************************************/
void temperatureUpdate(TEMPSENS_Temp_TypeDef *temp)
{
  TEMPSENS_Temp_TypeDef dtemp;

  /* Work with local copy in case conversion to Fahrenheit is required */
  dtemp = *temp;

  if (showFahrenheit)
  {
    TEMPSENS_Celsius2Fahrenheit(&dtemp);
  }

  /* Round temperature to nearest 0.5 */
  if (dtemp.f >= 0)
  {
    dtemp.i += (dtemp.f + 2500) / 10000;
    dtemp.f  = (((dtemp.f + 2500) % 10000) / 5000) * 5000;
  }
  else
  {
    dtemp.i += (dtemp.f - 2500) / 10000;
    dtemp.f  = (((dtemp.f - 2500) % 10000) / 5000) * 5000;
  }

  if ((dtemp.i < 0) || (dtemp.f < 0))
  {
    putchar('-');
  }
  else
  {
    putchar('+');
  }
  printf("%d.%d %c\n", abs(dtemp.i), (int)(abs(dtemp.f) / 1000),
         showFahrenheit ? 'F' : 'C');
}
Пример #2
0
/**************************************************************************//**
 * @brief Update LCD with temperature
 * @param[in] temp Temperature to display.
 *****************************************************************************/
void temperatureUpdateLCD(TEMPSENS_Temp_TypeDef *temp)
{
    char text[8];
    TEMPSENS_Temp_TypeDef dtemp;

    /* Work with local copy in case conversion to Fahrenheit is required */
    dtemp = *temp;

    memset(text, ' ', sizeof(text) - 1);
    text[sizeof(text) - 1] = 0;

    if (SHOW_FAHRENHEIT)
    {
        text[5] = 'F';
        TEMPSENS_Celsius2Fahrenheit(&dtemp);
    }
    else
    {
        text[5] = 'C';
    }

    /* Round temperature to nearest 0.5 */
    if (dtemp.f >= 0)
    {
        dtemp.i += (dtemp.f + 2500) / 10000;
        dtemp.f = (((dtemp.f + 2500) % 10000) / 5000) * 5000;
    }
    else
    {
        dtemp.i += (dtemp.f - 2500) / 10000;
        dtemp.f = (((dtemp.f - 2500) % 10000) / 5000) * 5000;
    }

    /* 100s */
    if (abs(dtemp.i) >= 100)
        text[0] = '0' + (abs(dtemp.i) / 100);

    /* 10s */
    if (abs(dtemp.i) >= 10)
        text[1] = '0' + ((abs(dtemp.i) % 100) / 10);

    /* 1s */
    text[2] = '0' + (abs(dtemp.i) % 10);

    /* 0.1s */
    text[3] = '0' + (abs(dtemp.f) / 1000);

    SegmentLCD_Write(text);
    SegmentLCD_Symbol(LCD_SYMBOL_DP4, 1);

    if ((dtemp.i < 0) || (dtemp.f < 0))
    {
        SegmentLCD_Symbol(LCD_SYMBOL_MINUS, 1);
    }
    else
    {
        SegmentLCD_Symbol(LCD_SYMBOL_MINUS, 0);
    }
}
Пример #3
0
/**************************************************************************//**
 * @brief Update LCD with temperature
 * @param[in] temp Temperature to display.
 *****************************************************************************/
void temperatureUpdateLCD(TEMPSENS_Temp_TypeDef *temp)
{
  char text[8];
  TEMPSENS_Temp_TypeDef dtemp;

  /* Work with local copy in case conversion to Fahrenheit is required */
  dtemp = *temp;

  /* Show Gecko if debugger is attached. Energy modes do not behave as */
  /* expected when using the debugger. */
  if (DBG_Connected())
  {
    SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 1);
  }
  else
  {
    SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 0);
  }

  memset(text, ' ', sizeof(text) - 1);
  text[sizeof(text) - 1] = 0;

  if (showFahrenheit)
  {
    text[5] = 'F';
    TEMPSENS_Celsius2Fahrenheit(&dtemp);
  }
  else
  {
    text[5] = 'C';
  }

  /* Round temperature to nearest 0.5 */
  if (dtemp.f >= 0)
  {
    dtemp.i += (dtemp.f + 2500) / 10000;
    dtemp.f = (((dtemp.f + 2500) % 10000) / 5000) * 5000;
  }
  else
  {
    dtemp.i += (dtemp.f - 2500) / 10000;
    dtemp.f = (((dtemp.f - 2500) % 10000) / 5000) * 5000;
  }

  /* 100s */
  if (abs(dtemp.i) >= 100)
    text[0] = '0' + (abs(dtemp.i) / 100);

  /* 10s */
  if (abs(dtemp.i) >= 10)
    text[1] = '0' + ((abs(dtemp.i) % 100) / 10);

  /* 1s */
  text[2] = '0' + (abs(dtemp.i) % 10);

  /* 0.1s */
  text[3] = '0' + (abs(dtemp.f) / 1000);

  SegmentLCD_Write(text);
  SegmentLCD_Symbol(LCD_SYMBOL_DP4, 1);

  if ((dtemp.i < 0) || (dtemp.f < 0))
  {
    SegmentLCD_Symbol(LCD_SYMBOL_MINUS, 1);
  }
  else
  {
    SegmentLCD_Symbol(LCD_SYMBOL_MINUS, 0);
  }
}