Exemplo n.º 1
0
/**************************************************************************//**
 * @brief Update rings according to slider position
 * @par sliderPos The current Slider position
 *****************************************************************************/
void capSenseAringUpdate(int sliderPos)
{
  int i;
  int stop;

  if (sliderPos == -1)
  {
    /* No ring if touch slider is not touched */
    stop = -1;
  }
  else
  {
    /* Map 8 segments to 48 slider positions */
    stop = (sliderPos * 8) / 48;
  }

  /* Draw ring */
  for (i=0; i < 8; i++)
  {
    if (i <= stop )
    {
      SegmentLCD_ARing(i, 1);
    }
    else
    {
      SegmentLCD_ARing(i, 0);
    }
  }
}
Exemplo n.º 2
0
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskThree(void *p_arg)
{
  OS_ERR err = OS_ERR_NONE;
  char indxChar;
  char MsgSize;
  char *pMsgContent;
  static char taskStringBuffer[APPDEF_LCD_TXT_SIZE+1U] = {'u','C','/','O','S','-','3','\0'};
  static int  ringPos = 0;


  (void)p_arg; /* Note(1) */

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Turn previous ring segment off                 */
    SegmentLCD_ARing(ringPos, 0);

    /* Increase ring position variable                */
    if (8u == ++ringPos)
    {
      ringPos = 0; /* 3bit overflow */
    }

    /* Turn updated ring segment on                   */
    SegmentLCD_ARing(ringPos, 1);

    /* Non-blocking reception of a message */
    pMsgContent = OSQPend((OS_Q         *) pSerialQueObj,
                          (OS_TICK       ) 0U,
                          (OS_OPT        ) OS_OPT_PEND_NON_BLOCKING,
                          (OS_MSG_SIZE  *)&MsgSize,
                          (CPU_TS       *) 0U,
                          (OS_ERR       *)&err);

    /* If a valid message was received... */
    if ((void *)0 != pMsgContent)
    {
      /* ...shift left the whole string by one... */
      for (indxChar = 0; indxChar < APPDEF_LCD_TXT_SIZE; indxChar++)
      {
        taskStringBuffer[indxChar] = taskStringBuffer[indxChar+1];
      }

      /* ...and concatenate the new character to the end. */
      taskStringBuffer[APPDEF_LCD_TXT_SIZE-1] = *pMsgContent;

      /* Write the string on serial port (USART0) */
      printf("\nBuffer: %s", taskStringBuffer);

      /* Write the string on LCD */
      SegmentLCD_Write(taskStringBuffer);
    }

    /* Delay task for 1 system tick (uC/OS-II suspends this task and executes
     * the next most important task) */
    OSTimeDly(1U, OS_OPT_TIME_DLY, &err);
  }
}
void lcd_show_ring_segments(uint8_t segments)
{
	int i = 0;
	for (;i<8;i++)
	{
		if (segments & 1 << i)
			SegmentLCD_ARing(i, true);
		else
			SegmentLCD_ARing(i, false);
	}
}
Exemplo n.º 4
0
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*             
*             
*********************************************************************************************************
*/
void APP_TaskThree(void *p_arg)
{
  static char taskStringBuffer[APPDEF_LCD_TXT_SIZE+1U] = {'u','C','/','O','S','-','2','\0'};
  static int  ringPos = 0;
  char indxChar;
  char *pMsgContent;
  
  
  (void)p_arg; /* Note(1) */
  
  while (1) 
  { /* Task body, always written as an infinite loop  */
    
    /* Turn previous ring segment off                 */
    SegmentLCD_ARing(ringPos, 0);
    
    /* Increase ring position variable                */
    if (8u == ++ringPos)
    {
      ringPos = 0; /* 3bit overflow */
    }
    
    /* Turn updated ring segment on                   */
    SegmentLCD_ARing(ringPos, 1);
 
    /* Non-blocking reception of a message */
    pMsgContent = OSMboxAccept(pSerialMsgObj);
    
    /* If a valid message was received... */
    if ((void *)0 != pMsgContent)
    {
      /* ...shift left the whole string by one... */
      for (indxChar = 0; indxChar < APPDEF_LCD_TXT_SIZE; indxChar++)
      {
        taskStringBuffer[indxChar] = taskStringBuffer[indxChar+1];
      }
        
      /* ...and concatenate the new character to the end. */
      taskStringBuffer[APPDEF_LCD_TXT_SIZE-1] = *pMsgContent;
        
      /* Write the string on serial port */
      printf("\nBuffer: %s", taskStringBuffer);
      
      /* Write the string on LCD */
      SegmentLCD_Write(taskStringBuffer);
    }
    
    /* Delay task for 1 system tick (uC/OS-II suspends this task and executes
     * the next most important task) */    
    OSTimeDly(100);
  }
}
void lcd_show_ring(int segments)
{
	int i = 0;
	if (segments > 7) segments = 7;
	for (;i<segments;i++)
	{
		SegmentLCD_ARing(i, true);
	}

	for(i=segments;i<8;i++)
	{
		SegmentLCD_ARing(i, false);
	}
}
Exemplo n.º 6
0
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskThree(void *p_arg)
{
  char text[APPDEF_LCD_TXT_SIZE+1U] = {'u','C','/','O','S','-','2','\0'};
  int i;
  int msgContent;
  int ringPos = 0;
  INT8U err;

  (void)p_arg; /* Note(1) */

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Turn previous ring segment off                 */
    SegmentLCD_ARing(ringPos, 0);

    /* Increase ring position variable                */
    if (8u == ++ringPos)
    {
      ringPos = 0; /* 3bit overflow */
    }

    /* Turn updated ring segment on                   */
    SegmentLCD_ARing(ringPos, 1);

    msgContent = (int)OSQPend(pSerialQueObj, 1, &err);

    if ((void*)0 != (void*)msgContent)
    {
      /* Shift left the whole string by one... */
      for (i = 0; i < APPDEF_LCD_TXT_SIZE; i++)
      {
        text[i] = text[i+1];
      }

      /* ...and concatenate the new character to the end */
      text[APPDEF_LCD_TXT_SIZE-1] = (char)msgContent;

      /* Write the string on serial port */
      printf("\nBuffer: %s", text);

      /* Write the string on LCD */
      SegmentLCD_Write(text);
    }

    /* Delay with 100 ms */
    OSTimeDlyHMSM(0, 0, 0, 100);
  }
}
Exemplo n.º 7
0
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskThree(void *p_arg)
{
  OS_ERR err = OS_ERR_NONE;
  static int  ringPos = 0;

/* As USART connectors are not available on the STK by default,
 * therefore printf() functions are turned off.
 * Uncomment the macro definition in includes.h if serial
 * is connected to your STK board (USART1 or LEUART0)!    */
#ifdef USART_CONNECTED
  char indxChar;
  char MsgSize;
  char *pMsgContent;
  static char taskStringBuffer[APPDEF_LCD_TXT_SIZE+1U] = {'u','C','/','O','S','-','3','\0'};
#endif /* end of #ifndef USART_CONNECTED */


  (void)p_arg; /* Note(1) */

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Turn previous ring segment off                 */
    SegmentLCD_ARing(ringPos, 0);

    /* Increase ring position variable                */
    if (8u == ++ringPos)
    {
      ringPos = 0; /* 3bit overflow */
    }

    /* Turn updated ring segment on                   */
    SegmentLCD_ARing(ringPos, 1);

/* As USART connectors are not available on the STK by default,
 * therefore printf() functions are turned off.
 * Uncomment the macro definition in includes.h if serial
 * is connected to your STK board (USART1 or LEUART0)!    */
#ifdef USART_CONNECTED

    /* Non-blocking reception of a message */
    pMsgContent = OSQPend((OS_Q         *) pSerialQueObj,
                          (OS_TICK       ) 0U,
                          (OS_OPT        ) OS_OPT_PEND_NON_BLOCKING,
                          (OS_MSG_SIZE  *)&MsgSize,
                          (CPU_TS       *) 0U,
                          (OS_ERR       *)&err);

    /* If a valid message was received... */
    if ((void *)0 != pMsgContent)
    {
      /* ...shift left the whole string by one... */
      for (indxChar = 0; indxChar < APPDEF_LCD_TXT_SIZE; indxChar++)
      {
        taskStringBuffer[indxChar] = taskStringBuffer[indxChar+1];
      }

      /* ...and concatenate the new character to the end. */
      taskStringBuffer[APPDEF_LCD_TXT_SIZE-1] = *pMsgContent;

      /* Write the string on serial port */
      printf("\nBuffer: %s", taskStringBuffer);

      /* Write the string on LCD */
      SegmentLCD_Write(taskStringBuffer);
    }
#endif /* end of #ifndef USART_CONNECTED */

    /* Delay with 100msec                             */
    OSTimeDlyHMSM(0U, 0U, 0U, 100U, (OS_OPT_TIME_DLY | OS_OPT_TIME_HMSM_STRICT), &err);

    /* Delay task for 1 system tick (uC/OS-III suspends this task and executes
     * the next most important task) */
    OSTimeDly(1U, OS_OPT_TIME_DLY, &err);
  }
}
Exemplo n.º 8
0
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskThree(void *p_arg)
{
/* As USART connectors are not available on the STK by default,
 * therefore printf() functions are turned off.
 * Uncomment the macro definition in includes.h if serial
 * is connected to your STK board (USART1 or LEUART0)!    */
#ifdef USART_CONNECTED
  static char taskStringBuffer[APPDEF_LCD_TXT_SIZE+1U] = {'u','C','/','O','S','-','2','\0'};
  char indxChar;
  char *pMsgContent;
#endif /* end of #ifndef USART_CONNECTED */
  static int  ringPos = 0;


  (void)p_arg; /* Note(1) */

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Turn previous ring segment off                 */
    SegmentLCD_ARing(ringPos, 0);

    /* Increase ring position variable                */
    if (8u == ++ringPos)
    {
      ringPos = 0; /* 3bit overflow */
    }

    /* Turn updated ring segment on                   */
    SegmentLCD_ARing(ringPos, 1);

/* As USART connectors are not available on the STK by default,
 * therefore printf() functions are turned off.
 * Uncomment the macro definition in includes.h if serial
 * is connected to your STK board (USART1 or LEUART0)!    */
#ifdef USART_CONNECTED
    pMsgContent = OSMboxAccept(pSerialMsgObj);
    if ((void *)0 != pMsgContent)
    {
      /* Shift left the whole string by one... */
      for (indxChar = 0; indxChar < APPDEF_LCD_TXT_SIZE; indxChar++)
      {
        taskStringBuffer[indxChar] = taskStringBuffer[indxChar+1];
      }

      /* ...and concatenate the new character to the end */
      taskStringBuffer[APPDEF_LCD_TXT_SIZE-1] = *pMsgContent;

      /* Write the string on serial port     */
      printf("\nBuffer: %s", taskStringBuffer);

      /* Write the string on LCD */
      SegmentLCD_Write(taskStringBuffer);
    }
#endif /* end of #ifndef USART0_CONNECTED */
    OSTimeDlyHMSM(0, 0, 0, 100);

    /* Delay task for 1 system tick (uC/OS-II suspends this task and executes
     * the next most important task) */
    OSTimeDly(1);
  }
}
Exemplo n.º 9
0
/**************************************************************************//**
 * @brief LCD Test Routine, shows various text and patterns
 *****************************************************************************/
void Test(void)
{
  int i, numberOfIterations = 0;

  /* Initialize GPIO */
  GPIO_IRQInit();

  /* Initialize RTC */
  RTCDRV_Setup(cmuSelect_LFRCO, cmuClkDiv_32);

  /* Loop through funny pattern */
  while (1)
  {
    SegmentLCD_AllOff();
#if VBOOST_SUPPORT
    checkVoltage();
#endif

    if (emMode != DEMO_MODE_NONE)
    {
      SegmentLCD_Symbol(LCD_SYMBOL_PAD0, 1);
      SegmentLCD_Symbol(LCD_SYMBOL_PAD1, 1);
    }
    else
    {
      for (i = 100; i > 0; i--)
      {
        SegmentLCD_Number(i);
        EM2Sleep(10);
      }
      SegmentLCD_NumberOff();

      SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 1);
      SegmentLCD_Symbol(LCD_SYMBOL_EFM32, 1);
      SegmentLCD_Write(" TINY  ");
      EM2Sleep(500);
      SegmentLCD_Write(" Gecko ");
      EM2Sleep(1000);
      SegmentLCD_AllOn();
      EM2Sleep(1000);

      SegmentLCD_AllOff();
    }
    if (emMode != DEMO_MODE_NONE)
    {
      SegmentLCD_Symbol(LCD_SYMBOL_PAD0, 1);
      SegmentLCD_Symbol(LCD_SYMBOL_PAD1, 1);
    }
    else
    {
      SegmentLCD_Write("OOOOOOO");
      EM2Sleep(62);
      SegmentLCD_Write("XXXXXXX");
      EM2Sleep(62);
      SegmentLCD_Write("+++++++");
      EM2Sleep(62);
      SegmentLCD_Write("@@@@@@@");
      EM2Sleep(62);
      SegmentLCD_Write("ENERGY ");
      EM2Sleep(250);
      SegmentLCD_Write("@@ERGY ");
      EM2Sleep(62);
      SegmentLCD_Write(" @@RGY ");
      EM2Sleep(62);
      SegmentLCD_Write(" M@@GY ");
      EM2Sleep(62);
      SegmentLCD_Write(" MI@@Y ");
      EM2Sleep(62);
      SegmentLCD_Write(" MIC@@ ");
      EM2Sleep(62);
      SegmentLCD_Write(" MICR@@");
      EM2Sleep(62);
      SegmentLCD_Write(" MICRO@");
      EM2Sleep(62);
      SegmentLCD_Write(" MICRO ");
      EM2Sleep(250);
      SegmentLCD_Write("-EFM32-");
      EM2Sleep(250);

      /* Various eye candy */
      SegmentLCD_AllOff();
      if (emMode != DEMO_MODE_NONE)
      {
        SegmentLCD_Symbol(LCD_SYMBOL_PAD0, 1);
        SegmentLCD_Symbol(LCD_SYMBOL_PAD1, 1);
      }
      for (i = 0; i < 8; i++)
      {
        SegmentLCD_Number(numberOfIterations + i);
        SegmentLCD_ARing(i, 1);
        EM2Sleep(20);
      }
      for (i = 0; i < 8; i++)
      {
        SegmentLCD_Number(numberOfIterations + i);
        SegmentLCD_ARing(i, 0);
        EM2Sleep(100);
      }

      for (i = 0; i < 5; i++)
      {
        SegmentLCD_Number(numberOfIterations + i);
        SegmentLCD_Battery(i);
        SegmentLCD_EnergyMode(i, 1);
        EM2Sleep(100);
        SegmentLCD_EnergyMode(i, 0);
        EM2Sleep(100);
      }
      SegmentLCD_Symbol(LCD_SYMBOL_ANT, 1);
      for (i = 0; i < 4; i++)
      {
        SegmentLCD_EnergyMode(i, 1);
        EM2Sleep(100);
      }
      SegmentLCD_Symbol(LCD_SYMBOL_ANT, 0);
      SegmentLCD_Battery(0);
    }
    /* Energy Modes */
    SegmentLCD_NumberOff();
    SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 1);
    SegmentLCD_Symbol(LCD_SYMBOL_EFM32, 1);
    if ((emMode != DEMO_MODE_EM3) && (emMode != DEMO_MODE_EM4))
    {
      ScrollText("Energy Mode demo, Press PB0 for EM3 or PB1 for EM4       ");
    }
    SegmentLCD_Write("  EM0  ");
    SegmentLCD_Number(0);
    SegmentLCD_EnergyMode(0, 1);
    SegmentLCD_EnergyMode(1, 1);
    SegmentLCD_EnergyMode(2, 1);
    SegmentLCD_EnergyMode(3, 1);
    SegmentLCD_EnergyMode(4, 1);
    RTCDRV_Delay(4000, false);
    SegmentLCD_Write("  EM1  ");
    SegmentLCD_Number(1111);
    SegmentLCD_EnergyMode(0, 0);
    EM1Sleep(4000);
    SegmentLCD_Write("  EM2  ");
    SegmentLCD_Number(2222);
    SegmentLCD_EnergyMode(1, 0);
    EM2Sleep(4000);

    /* Check if somebody has pressed one of the buttons */
    if (emMode == DEMO_MODE_EM3)
    {
      ScrollText("Going down to EM3, press PB0 to wake up    ");
      SegmentLCD_Write("  EM3  ");
      SegmentLCD_Number(3333);
      RTCDRV_Delay(1000, false);

      /* Wake up on GPIO interrupt */
      EM3Sleep();
      SegmentLCD_Number(0000);
      SegmentLCD_Write("--EM0--");
      RTCDRV_Delay(500, false);
      SegmentLCD_Symbol(LCD_SYMBOL_PAD0, 0);
      SegmentLCD_Symbol(LCD_SYMBOL_PAD1, 0);
      emMode = DEMO_MODE_NONE;
    }
    /* Check if somebody's joystick down */
    if (emMode == DEMO_MODE_EM4)
    {
      ScrollText("Going down to EM4, press reset to restart    ");
      SegmentLCD_Write("  EM4  ");
      SegmentLCD_Number(4444);
      RTCDRV_Delay(1000, false);

      /* Wake up on reset */
      EM4Sleep();
    }
    SegmentLCD_EnergyMode(0, 0);
    SegmentLCD_EnergyMode(1, 0);
    SegmentLCD_EnergyMode(2, 0);
    SegmentLCD_EnergyMode(3, 0);
    SegmentLCD_EnergyMode(4, 0);

    /* Scrolltext */
    ScrollText(stext);

    /* Blink and animation featurs */
    BlinkTest();

    numberOfIterations++;
  }
}