Exemplo n.º 1
0
void 
ShowTempEntry(char *format,...)
{
    char text[1024];
    va_list v;

    va_start(v, format);
    vsprintf(text, format, v);

    SetBackColor(ANSI_BLUE);

    if (StatusLine > ScrnHeight - 2) {
	SetForeColor(ANSI_WHITE);
	ScrollText();
	StatusLine--;
    }
    SetForeColor(ANSI_YELLOW);

    MoveCurs(4, StatusLine);
    CPrintf("%s", text);

    StatusLine++;

    TimeUpdate();
}
Exemplo n.º 2
0
void 
ShowWarningEntry(char *format,...)
{
    char text[1024];
    va_list v;

    va_start(v, format);
    vsprintf(text, format, v);

    SetBackColor(ANSI_BLUE);

    if (StatusLine > ScrnHeight - 2) {
	SetForeColor(ANSI_WHITE);
	ScrollText();
	StatusLine--;
    }
    SetForeColor(ANSI_RED);

    MoveCurs(2, StatusLine);
    CPrintf("$f1*** %s", text);

    if (logging) {
	LogFile = fopen("error.log", "a+");
	if (LogFile != NULL)
	    CfPrintf(LogFile, "*** %s", text);
	fclose(LogFile);
    }
    StatusLine++;

    TimeUpdate();
}
Exemplo n.º 3
0
void CursWin::Writes(char* msg, bool ref) {
    if (curRowPos > (maxRowPos-footerWidth)) {
        ScrollText();
    }
    MvWrites(curRowPos,curColPos,msg,false);
    if (ref) refresh();
}
Exemplo n.º 4
0
void CursWin::Putch(char ch, bool ref) {
    if (curRowPos > (maxRowPos-footerWidth)) {
        ScrollText();
    }    
    mvaddch(upperLeftRow+1+curRowPos, upperLeftCol+1+curColPos, ch);
    curColPos++;
    if (curColPos > maxColPos) {
        curColPos = 0;
        curRowPos++;
    }
    if (ref) refresh();
}
Exemplo n.º 5
0
void DisplayText ( char ch)
{
	int x;
	int y;

	//Set Text Color

	if(RxTx_InTxMode())
		GL_SetTextColor(LCD_COLOR_RED);
	else
		GL_SetTextColor(LCD_COLOR_BLACK);

	// handle backspace
	if (ch==8){
		charnum--;
		col--;
		if (row==FIRSTROW){
			if (charnum<0) charnum = 0;
			if (col<FIRSTCOL) col = FIRSTCOL;
		}
		else {
			if (charnum<0)  charnum += NUMCHARS;
			if (col<FIRSTCOL) {
				col += NUMCOLS;
				row--;
			}
			x = OFFSETX_ONAIR + (col-1)*dx;
			y = OFFSETY_ONAIR + (row-1)*dy;
			GL_PrintChar (x,y,BLANK,0);
		}
	}
	else {
		if ((ch<0x20) | (ch>0x7E)) ch=0x20;
		x = OFFSETX_ONAIR + (col-1)*dx;
		y = OFFSETY_ONAIR + (row-1)*dy;
		GL_PrintChar (x,y,ch,0);
		LCD_buffer[charnum] = ch;
		charnum++;
		charnum %= NUMCHARS;
		col++;
		if (col > LASTCOL) {
			row++;
			col = FIRSTCOL;
			if (row > LASTROW) {
				ScrollText();
			}
		}
	}

}
Exemplo n.º 6
0
/**************************************************************************//**
 * @brief  Memory protection fault second level exception handler.
 *****************************************************************************/
void MemManage_HandlerC( uint32_t *stack )
{
  static char text[ 80 ], s[ 5 ];
  uint32_t pc;

  pc = stack[6];                  /* Get stacked return address              */

  strcpy( text, "    MPU FAULT AT PC 0x" );
  s[ 0 ] = Hex2Char( pc >> 12 );
  s[ 1 ] = Hex2Char( pc >> 8 );
  s[ 2 ] = Hex2Char( pc >> 4  );
  s[ 3 ] = Hex2Char( pc );
  s[ 4 ] = '\0';
  strcat( text, s );
  strcat( text, "        " );
  ScrollText( text );

  SCB->CFSR |= 0xFF;              /* Clear all status bits in the            */
                                  /* MMFSR part of CFSR                      */
  __set_CONTROL( 0 );             /* Enter Priviledged state before exit     */
}
Exemplo n.º 7
0
/**************************************************************************//**
 * @brief  Main function.
 *****************************************************************************/
int main( void )
{
  int i;
  MPU_RegionInit_TypeDef flashInit       = MPU_INIT_FLASH_DEFAULT;
  MPU_RegionInit_TypeDef sramInit        = MPU_INIT_SRAM_DEFAULT;
  MPU_RegionInit_TypeDef peripheralInit  = MPU_INIT_PERIPHERAL_DEFAULT;

  /* Chip alignment */
  CHIP_Init();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Enable LCD without voltage boost */
  SegmentLCD_Init( false );
  SegmentLCD_AllOff();
  SegmentLCD_Symbol(LCD_SYMBOL_GECKO, 1);
  SegmentLCD_Symbol(LCD_SYMBOL_EFM32, 1);

  GpioInit();

  RTCDRV_Setup( cmuSelect_LFXO, cmuClkDiv_32);

  ScrollText( "        MPU DEMO  PRESS Pb0 OR Pb1 "
              "TO GENERATE MPU EXCEPTIONS         " );

  MPU_Disable();

  /* Flash memory */
  MPU_ConfigureRegion( &flashInit );

  /* SRAM */
  MPU_ConfigureRegion( &sramInit );

  /* SRAM, a 4k part with priviledged only access, this regions settings  */
  /* will override those of the previous region                           */
  sramInit.regionNo         = 2;
  sramInit.baseAddress      = RAM_MEM_BASE + 0x2000;
  sramInit.size             = mpuRegionSize4Kb;
  sramInit.accessPermission = mpuRegionApPRw;
  MPU_ConfigureRegion( &sramInit );

  /* LCD, priviledged only access */
  peripheralInit.regionNo         = 3;
  peripheralInit.baseAddress      = LCD_BASE;
  peripheralInit.size             = mpuRegionSize128b;
  peripheralInit.accessPermission = mpuRegionApPRw;
  MPU_ConfigureRegion( &peripheralInit );

  MPU_Enable( MPU_CTRL_PRIVDEFENA ); /* Full access to default memory map */
                                     /* in priviledged state              */

  i = 0;
  while ( 1 )
  {
    SegmentLCD_Number( i );          /* Count on numeric diplay */
    i = ( i + 1 ) % 101;
    RTCDRV_Delay( 150 , false);

    if ( PB0_PUSHED() )
    {
      BullsEye( 1 );

      /* Generate an access violation in internal SRAM          */
      __set_CONTROL( 1 );   /* Enter User (unpriviledged) state */
      *(volatile uint32_t *)(RAM_MEM_BASE + 0x2000) = 1;

      BullsEye( 0 );
    }

    if ( PB1_PUSHED() )
    {
      BullsEye( 1 );

      /* Generate an access violation in LCD peripheral         */
      __set_CONTROL( 1 );   /* Enter User (unpriviledged) state */

      BullsEye( 0 );
    }
  }
}
Exemplo n.º 8
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Initialize LCD controller without boost */
  SegmentLCD_Init(false);

  /* Disable all segments */
  SegmentLCD_AllOff();

  /* Copy contents of the userpage (flash) into the userData struct */
  memcpy((void *) &userData, (void *) USERPAGE, sizeof(UserData_TypeDef));

  /* Special case for uninitialized data */
  if (userData.number > 10000)
    userData.number = 0;
  if (userData.numWrites == 0xFFFFFFFF)
    userData.numWrites = 0;

  /* Display the number */
  SegmentLCD_Number(userData.number);

  /* Setup GPIO interrupts. PB0 to increase number, PB1 to save to flash */
  gpioSetup();

  /* No save has occured yet */
  recentlySaved = false;

  /* Main loop - just scroll informative text describing the current state of
   * the system */
  while (1)
  {
    switch (currentError)
    {
    case mscReturnInvalidAddr:
      ScrollText("     ERROR: INVALID ADDRESS      ");
      break;
    case mscReturnLocked:
      ScrollText("     ERROR: USER PAGE IS LOCKED      ");
      break;
    case mscReturnTimeOut:
      ScrollText("     ERROR: TIMEOUT OCCURED      ");
      break;
    case mscReturnUnaligned:
      ScrollText("     ERROR: UNALIGNED ACCESS     ");
    default:
      if (recentlySaved)
      {
        recentlySaved = false;
        SegmentLCD_Number(userData.numWrites);
        ScrollText("     SAVE NUMBER       ");
      }
      else
      {
        SegmentLCD_Number(userData.number);
        ScrollText("     PRESS PB0 TO INCREASE NUMBER. PB1 TO SAVE TO INTERNAL FLASH        ");
      }
      break;
    }
  }
}
Exemplo n.º 9
0
//*****************************************************************************
//
// This function prints the character out the screen and into the command
// buffer.
//
// ucChar is the character to print out.
//
// This function handles all of the detail of printing a character to the
// screen and into the command line buffer.
//
// No return value.
//
//*****************************************************************************
void
UIPrintChar(const char cChar)
{
    bool bNewLine;
    int32_t i32Idx;

    GrContextForegroundSet(&g_sContext, ClrWhite);

    bNewLine = true;

    //
    // Allow new lines to cause the column to go back to zero.
    //
    if(cChar != '\n') {
        //
        // Handle when receiving a backspace character.
        //
        if(cChar != ASCII_BACKSPACE) {
            //
            // This is not a backspace so print the character to the screen.
            //
            GrStringDraw(&g_sContext, &cChar, 1,
                         DISPLAY_TEXT_BORDER_H +
                         (GrFontMaxWidthGet(g_psFontFixed6x8) * g_ui32Column),
                         DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER +
                         (g_ui32EntryLine * GrFontHeightGet(g_psFontFixed6x8)),
                         1);

            g_ppcLines[g_ui32CurrentLine][g_ui32Column] = cChar;

            if(g_ui32Column < g_ui32CharsPerLine) {
                //
                // No line wrap yet so move one column over.
                //
                g_ui32Column++;

                bNewLine = false;
            }
        } else {
            //
            // We got a backspace.  If we are at the top left of the screen,
            // return since we don't need to do anything.
            //
            if(g_ui32Column || g_ui32EntryLine) {
                //
                // Adjust the cursor position to erase the last character.
                //
                if(g_ui32Column > 2) {
                    g_ui32Column--;
                }

                //
                // Print a space at this position then return without fixing up
                // the cursor again.
                //
                GrStringDraw(&g_sContext, " ", 1,
                             DISPLAY_TEXT_BORDER_H +
                             (GrFontMaxWidthGet(g_psFontFixed6x8) * g_ui32Column),
                             DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER +
                             (g_ui32EntryLine * GrFontHeightGet(g_psFontFixed6x8)),
                             true);

                g_ppcLines[g_ui32CurrentLine][g_ui32Column] = ' ';
            }

            bNewLine = false;
        }
    }

    //
    // .
    //
    if(bNewLine) {
        g_ui32Column = 0;

        if(g_ui32EntryLine < (MAX_LINES - 1)) {
            g_ui32EntryLine++;
        } else {
            ScrollText();
        }

        g_ui32CurrentLine++;

        //
        // The line has gone past the end so go back to the first line.
        //
        if(g_ui32CurrentLine >= MAX_LINES) {
            g_ui32CurrentLine = 0;
        }

        //
        // Add a prompt to the new line.
        //
        if(cChar == '\n') {
            DrawPrompt();
        } else {
            //
            // Clear out the current line.
            //
            for(i32Idx = 0; i32Idx < MAX_COLUMNS - 1; i32Idx++) {
                g_ppcLines[g_ui32CurrentLine][i32Idx] = ' ';
            }
            g_ppcLines[g_ui32CurrentLine][i32Idx] = 0;

            GrStringDraw(&g_sContext, g_ppcLines[g_ui32CurrentLine],
                         strlen(g_ppcLines[g_ui32CurrentLine]),
                         DISPLAY_TEXT_BORDER_H,
                         DISPLAY_BANNER_HEIGHT + DISPLAY_TEXT_BORDER +
                         (g_ui32EntryLine * GrFontHeightGet(g_psFontFixed6x8)),
                         1);
        }
    }
}
Exemplo n.º 10
0
/*-------------- main starts here --------------------------*/
extern Int2 Main (void)
{

RecT r1, r2;

#ifdef WIN_MAC
    m = AppleMenu (NULL);
    DeskAccGroup(m);
    m = PulldownMenu(NULL,  "File");
  
    s = SubMenu(m, "Open");
    i = CommandItem(m, "Quit/Q", QuitProc);
#endif

    InitProc(GetArgc(), GetArgv());

    w = RoundWindow(-50, -33,  -10,  -10,  "PDBeast: Taxonomy Assignment",  NULL);

#ifndef WIN_MAC

    SetUpDrawingTools();
/*  Red();
    SetColor(5);  */
    InvertColors();

    wpdb = RoundWindow(-53, -33, -10,  -10, "PDB File Display", NULL);
    p = StaticPrompt(wpdb, "Pdb File", 0, dialogTextHeight,  systemFont,  '1');
    Advance(wpdb);
    PdbOpen = DefaultButton(wpdb, "Open", PdbOpenProc);
    Break(wpdb);

    p = StaticPrompt(wpdb, "Blast Search", 0, dialogTextHeight,  systemFont,  '1');
    Advance(wpdb);
    lBlastChain = SingleList(wpdb, 10, 3, ListBlastChainProc);
    Advance(wpdb);
    BlastSearchAccept = DefaultButton(wpdb, "Send Query", BlastSearchAcceptProc);
    Break(wpdb);
 
    p = StaticPrompt(wpdb, "String Search", 0, dialogTextHeight,  systemFont,  '1');
    Advance(wpdb);
    Pdbfile_string = DialogText(wpdb, "", 15, NULL);
    Advance(wpdb);
    Pdbfile_string_accept = DefaultButton(wpdb, "Find", PdbfileStringAcceptProc);
    Break(wpdb);

    pdbfile_panel = DocumentPanel(wpdb, 650, 20*stdLineHeight);
    Break(wpdb);
    p = StaticPrompt(wpdb,"                ", 0, dialogTextHeight,  systemFont,  '1');
    Advance(wpdb);
    PdbClose = PushButton(wpdb,"Close", PdbCloseProc);
    Break(wpdb);

    m = PulldownMenu(w, "File");
    s1 = SubMenu(m, "Open");
    i = CommandItem(s1, "Entry", EntryProc);
    s2 = SubMenu(s1, "List");
    c = ChoiceGroup(s2, ListOpenProc); 
    ChoiceItem(c, myargs[6].strvalue);
   
/*  s3 = SubMenu(m, "Update");
    c = ChoiceGroup(s3, ListUpdateProc);
    ChoiceItem(c, myargs[6].strvalue);    */
    
    i = CommandItem(m,  "Quit/Q",  QuitProc);

/*  edit = PulldownMenu(w, "Edit");
    i = CommandItem(edit, "cut", StdCutTextProc);
    i = CommandItem(edit, "copy", StdCopyTextProc);
    i = CommandItem(edit, "paste", StdPasteTextProc);   */
#endif

    infilemode = NormalGroup(w, 3, 0, "Data Mode of Input Entry",systemFont, InFileTypeProc);
    RadioButton(infilemode, "Text"); 
    RadioButton(infilemode, "Binary"); 
/*  SafeSetValue(infilemode, 2);  */
    GetPosition(infilemode, &r1);

    outfilemode = NormalGroup(w, 3, 0, "Data Mode of Output Entry",systemFont, OutFileTypeProc);
    RadioButton(outfilemode, "Text"); 
    RadioButton(outfilemode, "Binary"); 
/*  SafeSetValue(outfilemode, 2);  */
    r2.top = r1.top; r2.bottom = r1.bottom; 
    r2.left = r1.right + 80;
    r2. right = r2.left + r1.right - r1.left;
    SetPosition(outfilemode, &r2);      
    Break(w);

    p = StaticPrompt(w, "Seq-entry", 0, dialogTextHeight,  systemFont,  '1');
    Advance (w);
    l = SingleList(w, 20, 3, ListProc);
    Disable(l);
    Advance(w);
    ListEntry_start = DefaultButton(w, "Start", ListEntryStartProc);
    Disable(ListEntry_start);
    Advance(w);
    ListEntry_next = DefaultButton(w, "Next", ListEntryNextProc);
    Disable(ListEntry_next);
    Advance(w);
    ListEntry_specific = DefaultButton(w, "Specific", ListEntrySpecificProc);
    Disable(ListEntry_specific);
    Break(w);
 
    p = StaticPrompt(w, "Enter Entry Code", 0, dialogTextHeight,  systemFont,  '1');
    Advance (w);
    Entry_code = DialogText(w, "", 15, (TxtActnProc) EnableProc);
    Select(Entry_code);
    Advance (w);
    Entry_accept = DefaultButton(w, "Open", EntryOpenProc);    
    Disable(Entry_accept);
    Break(w);

    p = StaticPrompt(w, "Chain", 0, dialogTextHeight,  systemFont,  '1');
    chain_panel = DocumentPanel(w, 200, stdLineHeight);
    Break(w);
    p = StaticPrompt(w, "Pdb Source:", 0, dialogTextHeight,  systemFont,  '1');
    pdb_source = ScrollText(w, 38, 3, systemFont, TRUE, NULL);
    Advance(w);
    Break(w);
    p = StaticPrompt(w, "Taxonomy Data:", 0, dialogTextHeight,  systemFont,  '1');
    org = DocumentPanel(w,400,6*stdLineHeight);
    Break(w);
    
    p = StaticPrompt(w, "Taxonomy Accept?", 0, dialogTextHeight,  systemFont,  '1');
    Break(w);
    Tax_accept = DefaultButton(w, "Yes", TaxAcceptProc);
    Advance(w);
    p = StaticPrompt(w, "to    ", 0, dialogTextHeight,  systemFont,  '1');
    Advance(w);
    Tax_all_accept = DefaultButton(w, "All", TaxAllAcceptProc);
    Disable(Tax_all_accept);
    Advance(w);
    p = StaticPrompt(w, "         or          ", 0, dialogTextHeight,  systemFont,  '1');
    Advance(w);      
    Tax_part_accept = DefaultButton(w, "Chain", TaxPartAcceptProc);
    Disable(Tax_part_accept);
    Advance(w);
    lchain = SingleList(w, 2, 4, TaxPartAssignProc);
    Advance(w);
    Tax_finish = DefaultButton(w, "All Done", TaxFinishProc);
    Disable(Tax_finish);
    Break(w); 
    Tax_reject = DefaultButton(w, "No", ReLookupProc);
    Disable(Tax_accept);
    Disable(Tax_reject);
    Break(w);

    p = StaticPrompt(w, "Look up Taxonomy Database with another String?", 0, dialogTextHeight,  systemFont,  '1');
    Advance(w);
    ReLookup_accept = DefaultButton(w, "Yes", AddStringProc);
    Advance(w);
    ReLookup_reject = DefaultButton(w, "No", ReLookupRejectProc);
    Disable(ReLookup_accept);
    Disable(ReLookup_reject);
    Break(w);

    p = StaticPrompt(w,"Search Taxonomy Database with", 0, dialogTextHeight,  systemFont,  '1');
    Advance(w);
    Source_string = DialogText(w, "", 15, NULL);
    Advance(w);
    Source_string_accept = DefaultButton(w, "Start", SourceStringAcceptProc);
    Disable(Source_string_accept);
    Break(w);

    Show(w);
    Show(wpdb);
    ProcessEvents();

    return 0;
}
Exemplo n.º 11
0
static intptr_t WINAPI MyDlgProc(HANDLE hDlg, intptr_t Msg, intptr_t Param1, void *Param2)
{
	FarGetDialogItem DialogItem={sizeof(FarGetDialogItem)};
	const INPUT_RECORD* record;

	switch (Msg)
	{
	case DN_CONTROLINPUT:
		record=(const INPUT_RECORD *)Param2;
		if (record->EventType==KEY_EVENT &&
			record->Event.KeyEvent.bKeyDown &&
			record->Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED &&
			(record->Event.KeyEvent.dwControlKeyState & LEFT_CTRL_PRESSED ||
			record->Event.KeyEvent.dwControlKeyState & RIGHT_CTRL_PRESSED))
		{
			switch (record->Event.KeyEvent.wVirtualKeyCode) {
			case VK_DOWN:
				ScrollText(stDn);
				return TRUE;
			case VK_UP:
				ScrollText(stUp);
				return TRUE;
			case VK_NEXT:
				ScrollText(stPgDn);
				return TRUE;
			case VK_PRIOR:
				ScrollText(stPgUp);
				return TRUE;
			case VK_END:
				ScrollText(stEnd);
				return TRUE;
			case VK_HOME:
				ScrollText(stHome);
				return TRUE;
			}
		}
		break;

	case DN_BTNCLICK:
		if (Param1==ixCaseSensitive) {
			bool bCaseSensitive = Param2!=0;
			if (bCaseSensitive!=bPrevCaseSensitive)
				UndoAll();
			bPrevCaseSensitive = bCaseSensitive;
		}
		Filter(PrevPattern, bPrevCaseSensitive);
		Info.AdvControl(&PluginId, ACTL_REDRAWALL, 0, NULL);
		break;

	case DN_EDITCHANGE:
		DialogItem.Size = (size_t)Info.SendDlgMessage(hDlg, DM_GETDLGITEM, ixSearchString, NULL);
		DialogItem.Item = (FarDialogItem*)malloc(DialogItem.Size);
		if (DialogItem.Item) {
			Info.SendDlgMessage(hDlg, DM_GETDLGITEM, ixSearchString, &DialogItem);
			size_t nChars = wcslen(DialogItem.Item->Data);
			size_t nPrevChars = Length(PrevPattern);
			bool bFilter = true;
			if (PrevPattern!=NULL) {
				//получается ли новая строка укорачиванием старой на символ
				if (bSequentialInput && nChars+1 == nPrevChars &&
					wcsncmp(DialogItem.Item->Data, PrevPattern, nChars) == 0)
				{
					//да - откатываем одну правку
					Undo();
					bFilter = false;
				}
				else
				{
					//получается ли новая строка добавлением символа к старой
					if (!(nChars == nPrevChars+1 &&
						wcsncmp(DialogItem.Item->Data, PrevPattern, nPrevChars) == 0))
					{
						//если нет - считаем, что откатывать по одной правке нельзя
						bSequentialInput = false;
					}
					//можно ли искать новую строку среди уже отфильтрованных
					if (wcsstr(DialogItem.Item->Data, PrevPattern) == NULL)
					{
						//нет - откатываем все правки
						UndoAll();
					}
				}
			}
			//выделить контекст заново при необходимости
			if (Length(PrevPattern)<MAX_PATTERN_LEN && nChars>=MAX_PATTERN_LEN) {
				SearchFree(ctx);
				ctx = SearchHAlloc();
			}
			else if (Length(PrevPattern)>=MAX_PATTERN_LEN && nChars<MAX_PATTERN_LEN) {
				SearchHFree(ctx);
				ctx = SearchAlloc();
			}

			//запомнить значение фильтра
			if (nChars!=0) {
				SetLength(&PrevPattern, (int)nChars);
				wcscpy(PrevPattern, DialogItem.Item->Data);
			}
			else {
				SetLength(&PrevPattern, 0);
				bSequentialInput = true;
			}
			free(DialogItem.Item);
			if (bFilter)
				Filter(PrevPattern, bPrevCaseSensitive);
			Info.AdvControl(&PluginId, ACTL_REDRAWALL, 0, NULL);
		}
		break;
	}
	return Info.DefDlgProc(hDlg, Msg, Param1, Param2);
}
Exemplo n.º 12
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++;
  }
}
Exemplo n.º 13
0
/**************************************************************************//**
 * @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++;
  }
}