コード例 #1
0
ファイル: lcdtest.c プロジェクト: EnergyMicro/EFM32TG_STK3300
/**************************************************************************//**
 * @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++;
  }
}
コード例 #2
0
ファイル: lcdtest.c プロジェクト: nopeppermint/openocd_efm32
/**************************************************************************//**
 * @brief LCD Test Routine, shows various text and patterns
 *****************************************************************************/
void Test(void)
{
  int i, numberOfIterations = 0;

  /* Initialize GPIO */
  GPIO_IRQInit();

  /* Loop through funny pattern */
  while (1)
  {
    SegmentLCD_AllOff();

    if (emMode == DEMO_MODE_NONE)
    {
      for (i = 100; i > 0; i--)
      {
        SegmentLCD_Number(i);
        EM2Sleep(10);
      }
      SegmentLCD_NumberOff();

      SegmentLCD_Symbol(LCD_SYMBOL_OLIMEX, 1);
      SegmentLCD_Write(" Gecko ");
      EM2Sleep(1000);

      SegmentLCD_AllOn();
      EM2Sleep(1000);

      SegmentLCD_AllOff();

      SegmentLCD_Write("OPENOCD");
      EM2Sleep(2000);
      SegmentLCD_Write("GDB");
      EM2Sleep(2000);
      SegmentLCD_Write("DONE");
      EM2Sleep(2000);
      SegmentLCD_Write("XXXXXXX");
      EM2Sleep(500);
      SegmentLCD_Write("-EFM32-");
      EM2Sleep(2000);

      /* Various eye candy */
      SegmentLCD_AllOff();
      for (i = 0; i < 17; i++)
      {
        SegmentLCD_LowerNumber( i);
        SegmentLCD_Battery(i);
				SegmentLCD_UnsignedHex(numberOfIterations +i);
        EM2Sleep(200);
      }
			SegmentLCD_Symbol(LCD_SYMBOL_ARR_UP, 1);
			EM2Sleep(200);
			SegmentLCD_Symbol(LCD_SYMBOL_ARR_DN, 1);
			EM2Sleep(200);
			SegmentLCD_Symbol(LCD_SYMBOL_ARR_L, 1);
			EM2Sleep(200);
			SegmentLCD_Symbol(LCD_SYMBOL_ARR_R, 1);
			EM2Sleep(200);
			SegmentLCD_Symbol(LCD_SYMBOL_MINUS, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_PLUS, 1);
			EM2Sleep(100);
			SegmentLCD_Symbol(LCD_SYMBOL_u, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_m, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_H, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_F, 1);
			EM2Sleep(200);
			SegmentLCD_Symbol(LCD_SYMBOL_2COL, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_3COL, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_4COL, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_5COL, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_6COL, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_10COL, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_1DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_2DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_3DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_4DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_5DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_6DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_8DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_10DP, 1);
			SegmentLCD_Symbol(LCD_SYMBOL_11DP, 1);
			EM2Sleep(800);
			SegmentLCD_AllOff();
    /* Energy Modes */

			SegmentLCD_Number(0);
			SegmentLCD_Battery(0);
			SegmentLCD_Write("  EM0  ");
			RTCDRV_Delay(2000, false);
			SegmentLCD_Number(1111);
			SegmentLCD_Battery(1);
			SegmentLCD_Write("  EM1  ");
			EM1Sleep(2000);
			SegmentLCD_Number(2222);
			SegmentLCD_Battery(2);
			SegmentLCD_Write("  EM2  ");
			EM2Sleep(2000);
			ScrollText("Energy Mode demo, Press BUT2 for EM3 or BUT1 for EM4        ");
			EM2Sleep(500);
			SegmentLCD_Write("PRESS x");
			EM2Sleep(2000);
		}
    /* Check if somebody has pressed one of the buttons */
    if (emMode == DEMO_MODE_EM3)
    {
			SegmentLCD_Number(3333);
			SegmentLCD_Battery(3);
			SegmentLCD_Arrows(0, 1); //arrow down, go to sleep in EM3
      ScrollText("Going down to EM3, press BUT2 to wake up    ");
      SegmentLCD_Write("  EM3  ");
      RTCDRV_Delay(1000, false);

      /* Wake up on GPIO interrupt */
      EM3Sleep();
			SegmentLCD_Battery(0);
			SegmentLCD_Arrows(0, 0); 	//arrow down off
			SegmentLCD_Arrows(2, 1);	//arrow up, wakeup from sleep in EM3
			SegmentLCD_Write("wakeup");
			RTCDRV_Delay(1500, false);
			SegmentLCD_Arrows(2, 0);	//arrow up off
      SegmentLCD_Battery(0);
			SegmentLCD_Number(0000);
      SegmentLCD_Write("--EM0--");
      RTCDRV_Delay(500, false);
    }
    /* Check if somebody's joystick down */
    if (emMode == DEMO_MODE_EM4)
    {
			SegmentLCD_Number(4444);
			SegmentLCD_Battery(4);
			SegmentLCD_Arrows(0, 1); //arrow down, go to sleep in EM4
      ScrollText("Going down to EM4, press reset to restart    ");
      SegmentLCD_Write("  EM4  ");
      RTCDRV_Delay(1000, false);

      /* Wake up on reset */
      EM4Sleep();
    }

    /* Scrolltext */
    ScrollText(stext);
    numberOfIterations++;
  }
}