void _TestCalibration(void) {
  int IdleCnt=0;
  BUTTON_Handle hButton;
  GUI_SetBkColor(GUI_RED);  
  GUI_SetColor(GUI_WHITE);  
  GUI_Clear();
  hButton =  BUTTON_Create( 225, 15, 80, 40, 1, BUTTON_CF_SHOW );
  BUTTON_SetText (hButton, "ABORT");
  BUTTON_SetFont (hButton, &GUI_FontComic18B_ASCII);
  while ((IdleCnt<50) && (GUI_GetKey()==0)) {
    static GUI_PID_STATE StateLast;
    GUI_PID_STATE State;
    GUI_TOUCH_GetState(&State);
    if ((StateLast.Pressed != State.Pressed) && (State.Pressed == 0)) {
      GUI_Clear();
    }
    if ((StateLast.x != State.x) || ((StateLast.y != State.y))) {
      if (State.Pressed) {
        GUI_FillCircle(State.x, State.y, 5);
      }
      StateLast = State;
    }
    if (State.Pressed) {
      IdleCnt =0;
    } else {
      IdleCnt++;
    }
    GUI_Delay (100);
  }
  EDIT_Delete(hButton);
}
Esempio n. 2
0
/*******************************************************************
*
*       _DemoButton
*/
static void _DemoButton(void) {
  BUTTON_Handle hButton;
  int Stat = 0;
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringHCenterAt("Click on phone button...", 160,80);
  GUI_Delay(500);
  /* Create the button */
  hButton = BUTTON_Create(142, 100, 36, 40, GUI_ID_OK, WM_CF_SHOW);
  /* Modify the button attributes */
  BUTTON_SetBkColor(hButton, 1, GUI_RED);
  BUTTON_SetBitmapEx(hButton, 0, &bm_1bpp_0, 2, 4);
  BUTTON_SetBitmapEx(hButton, 1, &bm_1bpp_1, 2, 4);
  /* Loop until button is pressed */
  while(GUI_GetKey() != GUI_ID_OK) {
    if (Stat ^= 1) {
      BUTTON_SetState(hButton, 
                      BUTTON_STATE_HASFOCUS | BUTTON_STATE_INACTIVE);
    } else {
      BUTTON_SetState(hButton, 
                      BUTTON_STATE_HASFOCUS | BUTTON_STATE_PRESSED);
    }
    GUI_Delay(500);
  }
  /* Delete button object */
  BUTTON_Delete(hButton);
  GUI_ClearRect(0, 50, 319, 239);
  GUI_Delay(1750);
}
Esempio n. 3
0
/*********************************************************************
*
*       _GetFileName
*
* Purpose:
*   Returns the file name of the XBF file to be used
*/
static void _GetFileName(char * pPath, unsigned MaxSize) {
  WM_HWIN hWin;
  
  /* Set default value on first call */
  if (!strlen(pPath)) {
    strcpy(pPath, "Sample\\GUI\\FONT_ShowXBF\\ExtBinFont.xbf");
  }
  /* Display small hint */
  GUI_SetFont(&GUI_Font10_ASCII);
  GUI_DispStringHCenterAt("Please enter the file name of the XBF-file:", 160, 80);
  /* Create edit widget */
  hWin = EDIT_Create(10, 120, 300, 20, 0, MaxSize, WM_CF_SHOW);
  EDIT_SetText(hWin, pPath);
  WM_SetFocus(hWin);
  /* Wait until GUI_KEY_ENTER has been pressed */
  while (GUI_GetKey() != GUI_KEY_ENTER) {
    GUI_Delay(100);
  }
  /* Get filename from EDIT widget */
  EDIT_GetText(hWin, pPath, MaxSize);
  /* Create edit widget */
  WM_DeleteWindow(hWin);
  /* Clear screen */
  GUI_ClearRect(0, 40, 319, 239);
}
Esempio n. 4
0
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
	LISTBOX_Handle hListBox;
	int iCharKey;

	GUI_Init();
	GUI_SetBkColor(GUI_BLUE);
	GUI_Clear();
	GUI_SetColor(GUI_WHITE);
	GUI_SetFont(&GUI_Font32_ASCII);
	//GUI_DispStringHCenterAt("WIDGET_SimpleListBox - Sample", 160, 5);
	hListBox = GListBox_Init();
	if (NULL == hListBox)
	{
		return;
	}

	while(1)
	{
		iCharKey = GUI_GetKey();
		switch (iCharKey)
		{
			case 0://进入测试面积
				break;
			case 1://进入测量周长
				break;
			default:
				break;
		}
	}

	while(1) {
		_DemoListBox(hListBox);
	}
}
int GUIDEMO_CheckCancel(void) {
  int c = GUI_GetKey();
  #if GUI_WINSUPPORT
    WM_ExecIdle();
  #endif
  if ((c == 'n') || (c=='N'))
    _CmdNext =1;
  if ((c == 's') || (c=='S')) {
    GUI_Delay(500);
    do {
      GUI_Delay(10);
      #if GUI_WINSUPPORT
        WM_ExecIdle();
      #endif
      c = GUI_GetKey();
    } while (!c);
  }
  return _CmdNext;
}
Esempio n. 6
0
int GUI_WaitKey(void) {
  int r;
  do {
    r =  GUI_GetKey();
    if (r)
      break;
    GUI_Exec();
  } while (1);
  return r;
}
/*******************************************************************
*
*       _Wait
*/
static int _Wait(int Delay) {
  int EndTime, r = 1;
  EndTime = GUI_GetTime() + Delay;
  while (GUI_GetTime() < EndTime) {
    GUI_Exec();
    if (GUI_GetKey() == GUI_ID_OK) {
      r = 0;
      break;
    }
  }
  return r;
}
Esempio n. 8
0
/*********************************************************************
*
*       GUI_WaitKey
*/
int GUI_WaitKey(void) {
  int r;
  do {
    r =  GUI_GetKey();
    if (r) {
      break;
    }
    if (!GUI_Exec()) {
      GUI_WaitEvent();      /* Wait for event (keyboard, mouse or whatever) */
    }
  } while (1);
  return r;
}
int GUIDEMO_WaitKey(void) {
  int r = 0;
  int tMax = GUI_GetTime() + 4000;
  int tDiff; 
  #if GUI_WINSUPPORT
    PROGBAR_Handle hProg = PROGBAR_Create(LCD_GetXSize() - 70, 
                                          LCD_GetYSize() - 40, 
                                          80, 5, WM_CF_SHOW);
  #endif
  while (tDiff = tMax-GUI_GetTime(), (tDiff > 0) && !GUIDEMO_CheckCancel()) {
    if ((r = GUI_GetKey()) != 0)
      break;
  }
  #if GUI_WINSUPPORT
    PROGBAR_Delete(hProg);
    WM_ExecIdle();
  #endif
  return r;
}
/*******************************************************************
*
*       _DemoEdit
*
  Edit a string until ESC or ENTER is pressed
*/
static void _DemoEdit(void) {
  EDIT_Handle hEdit;
  char aBuffer[28];
  int Key;
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_DispStringHCenterAt("WIDGET_Edit - Sample", 160, 5);
  GUI_SetFont(&GUI_Font8x16);
  GUI_DispStringHCenterAt("Use keyboard to modify string...", 160, 90);
  /* Create edit widget */
  hEdit = EDIT_Create( 50, 110, 220, 25, ' ', sizeof(aBuffer), WM_CF_SHOW);
  /* Modify edit widget */
  EDIT_SetText(hEdit, "Press <ENTER> when done...");
  EDIT_SetFont(hEdit, &GUI_Font8x16);
  EDIT_SetTextColor(hEdit, 0, GUI_RED);
  /* Set keyboard focus to edit widget */
  WM_SetFocus(hEdit);
  /* Handle keyboard until ESC or ENTER is pressed */
  do {
    WM_Exec();
    Key = GUI_GetKey();
  } while ((Key != GUI_KEY_ENTER) && (Key != GUI_KEY_ESCAPE));
  /* Fetch result from edit widget */
  if (Key == GUI_KEY_ENTER) {
    EDIT_GetText(hEdit, aBuffer, sizeof(aBuffer));
  }
  /* Delete the edit widget */
  EDIT_Delete(hEdit);
  GUI_ClearRect(0, 50, 319, 239);
  /* Display the changed string */
  if (Key == GUI_KEY_ENTER) {
    GUI_Delay(250);
    GUI_DispStringHCenterAt("The string you have modified is:", 160, 90);
    GUI_DispStringHCenterAt(aBuffer, 160, 110);
    GUI_Delay(3000);
    GUI_ClearRect(0, 50, 319, 239);
  }
  GUI_Delay(500);
}
/*********************************************************************
*
*       _Demo
*/
static void _Demo(void) {
  int Key = 0;
  int Cnt = 10;
  char acInfoText[] = "-- sec to play with header control";
  _ChangeInfoText("HEADER_AddItem");
  HEADER_AddItem(_hHeader, 100, "Red"  , GUI_TA_VCENTER | GUI_TA_HCENTER);
  HEADER_AddItem(_hHeader,   0, "Green", GUI_TA_VCENTER | GUI_TA_HCENTER);
  HEADER_AddItem(_hHeader,   0, ":-)"  , GUI_TA_VCENTER | GUI_TA_HCENTER);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetItemWidth");
  HEADER_SetItemWidth(_hHeader, 1, 60);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetItemText");
  HEADER_SetItemWidth(_hHeader, 2, 100);
  HEADER_SetItemText(_hHeader, 2, "Blue");
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetFont");
  HEADER_SetFont(_hHeader, &GUI_Font8x8);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetHeight");
  HEADER_SetHeight(_hHeader, 50);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetTextColor");
  HEADER_SetTextColor(_hHeader, GUI_YELLOW);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetBkColor");
  HEADER_SetBkColor(_hHeader, GUI_DARKGRAY);
  GUI_Delay(750);
  _ChangeInfoText("HEADER_SetTextAlign");
  HEADER_SetTextAlign(_hHeader, 0, GUI_TA_HCENTER);
  while (!Key && (Cnt > 0)) {
    acInfoText[0] = '0' + (Cnt / 10);
    acInfoText[1] = '0' + (Cnt-- % 10);
    _ChangeInfoText(acInfoText);
    GUI_Delay(1000);
    Key = GUI_GetKey();
  }
}
Esempio n. 12
0
/*********************************************************************
*
*       _ShowXBF
*
* Purpose:
*   Small sub routine which creates (and selects) a XBF font,
*   shows 'Hello world!' and waits for a keypress
*/
static void _ShowXBF(void * pVoid) {
  GUI_FONT     Font;
  GUI_XBF_DATA XBF_Data;

  /* Create XBF font */
  GUI_XBF_CreateFont(&Font,             /* Pointer to GUI_FONT structure in RAM */
                     &XBF_Data,         /* Pointer to GUI_XBF_DATA structure in RAM */
                     GUI_XBF_TYPE_PROP, /* Font type to be created */
                     _cbGetData,        /* Pointer to callback function */
                     pVoid);            /* Pointer to be passed to GetData function */
  /* Show 'Hello world!' */
  GUI_DispStringHCenterAt("Hello world!", 160, 80);
  /* Display hint */
  GUI_SetFont(&GUI_Font13_ASCII);
  GUI_DispStringHCenterAt("Press any key to continue...", 160, 120);
  /* Wait for pressing a key */
  while (!GUI_GetKey()) {
    GUI_Delay(100);
  }
  /* Delete XBF font and clear display */
  GUI_XBF_DeleteFont(&Font);
  GUI_ClearRect(0, 40, 319, 239);
}
Esempio n. 13
0
/*******************************************************************
*
*       _ShowSeveralFunctions
*/
static void _ShowSeveralFunctions(DROPDOWN_Handle hDropDown) {
  int NumEntries, i, Key = 0, Cnt = 15;
  char ac[] = "-- sec to play with dropdown control";
  /* Set focus */
  GUI_DispStringAtCEOL("WM_SetFocus", 5, 55);
  GUI_Delay(SPEED * 0.9);
  WM_SetFocus(hDropDown);
  GUI_Delay(SPEED * 0.7);
  /* Add strings */
  GUI_DispStringAtCEOL("DROPDOWN_AddString", 5, 55);
  GUI_Delay(SPEED * 0.8);
  DROPDOWN_AddString(hDropDown, "English");
  DROPDOWN_AddString(hDropDown, "Deutsch");
  DROPDOWN_AddString(hDropDown, "Fran鏰is");
  DROPDOWN_AddString(hDropDown, "Japanese");
  DROPDOWN_AddString(hDropDown, "Italiano");
  DROPDOWN_AddString(hDropDown, "Espa駉l");
  DROPDOWN_AddString(hDropDown, "Other language ...");
  GUI_Delay(SPEED * 0.6);
  /* Increment selection */
  GUI_DispStringAtCEOL("DROPDOWN_IncSel", 5, 55);
  GUI_Delay(SPEED);
  NumEntries = DROPDOWN_GetNumItems(hDropDown);
  for (i = 0; i < (NumEntries - 2); i++) {
    DROPDOWN_IncSel(hDropDown);
    GUI_Delay(SPEED / 6);
	}
  GUI_Delay(SPEED / 4);
  /* Expand dropdown */
  GUI_DispStringAtCEOL("DROPDOWN_Expand", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_Expand(hDropDown);
  GUI_Delay(SPEED * 0.75);
  /* Add scrollbar */
  GUI_DispStringAtCEOL("DROPDOWN_SetAutoScroll", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetAutoScroll(hDropDown, 1);
  GUI_Delay(SPEED * 0.75);
  /* Set font */
  GUI_DispStringAtCEOL("DROPDOWN_SetFont", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetFont(hDropDown, &GUI_Font16B_1);
  GUI_Delay(SPEED * 0.75);
  /* Set text color */
  GUI_DispStringAtCEOL("DROPDOWN_SetTextColor", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetTextColor(hDropDown, 0, 0x00BB00);
  DROPDOWN_SetTextColor(hDropDown, 2, GUI_BLACK);
  GUI_Delay(SPEED * 0.75);
  /* Set background color */
  GUI_DispStringAtCEOL("DROPDOWN_SetBkColor", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_SetBkColor(hDropDown, 0, GUI_YELLOW);
  DROPDOWN_SetBkColor(hDropDown, 2, GUI_RED);
  GUI_Delay(SPEED * 0.75);
  /* Delete item */
  GUI_DispStringAtCEOL("DROPDOWN_DeleteItem", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_DeleteItem(hDropDown, 5);
  GUI_Delay(SPEED * 0.75);
  /* Collapse dropdown */
  GUI_DispStringAtCEOL("DROPDOWN_Collapse", 5, 55);
  GUI_Delay(SPEED);
  DROPDOWN_Collapse(hDropDown);
  GUI_Delay(SPEED * 0.75);
  /* Decrement selection */
  GUI_DispStringAtCEOL("DROPDOWN_DecSel", 5, 55);
  GUI_Delay(SPEED);
  NumEntries = DROPDOWN_GetNumItems(hDropDown);
  for (i = 0; i < (NumEntries - 2); i++) {
    DROPDOWN_DecSel(hDropDown);
    GUI_Delay(SPEED / 6);
	}
  GUI_Delay(SPEED / 4);
  /* Let user play with dropdown control */
  GUI_DispStringAtCEOL("", 5, 55);
  while (!Key && (Cnt > 0)) {
    ac[0] = '0' + (Cnt / 10);
    ac[1] = '0' + (Cnt-- % 10);
    GUI_DispStringAtCEOL(ac, 5, 40);
    GUI_Delay(1000);
    Key = GUI_GetKey();
  }
  /* Delete dropdown widget */
  GUI_DispStringAtCEOL("DROPDOWN_Delete", 5, 55);
  GUI_Delay(SPEED * 1.1);
  DROPDOWN_Delete(hDropDown);
  GUI_Delay(SPEED * 0.75);
}
Esempio n. 14
0
/*********************************************************************
*
*       _Demo
*/
static void _Demo(void) {
  unsigned int i, j;
  int Key = 0;
  int Cnt = 15;
  char acInfoText[] = "-- sec to play with header control";
  HEADER_Handle hHeader;
  hHeader = LISTVIEW_GetHeader(_hListView);
  WM_SetFocus(_hListView);
  _ChangeInfoText("LISTVIEW_AddColumn");
  LISTVIEW_AddColumn(_hListView, 100, "EAN",         GUI_TA_CENTER);
  GUI_Delay(SPEED / 2);
  LISTVIEW_AddColumn(_hListView,  50, "Order #\0x0", GUI_TA_CENTER);
  GUI_Delay(SPEED / 2);
  LISTVIEW_AddColumn(_hListView, 100, "Description", GUI_TA_CENTER);
  GUI_Delay(SPEED / 2);
  _ChangeInfoText("SCROLLBAR_CreateAttached");
  SCROLLBAR_CreateAttached(_hListView, SCROLLBAR_CF_VERTICAL);
  GUI_Delay(SPEED / 2);
  _ChangeInfoText("LISTVIEW_AddRow");
  for (i = 0; i < GUI_COUNTOF(_aTable_1); i++) {
    LISTVIEW_AddRow(_hListView, _aTable_1[i]);
    GUI_Delay(SPEED / 3);
  }
  _ChangeInfoText("LISTVIEW_IncSel");
  for (i = 0; i < LISTVIEW_GetNumRows(_hListView); i++) {
    LISTVIEW_IncSel(_hListView);
    GUI_Delay(SPEED / 4);
  }
  GUI_Delay(SPEED / 4);
  _ChangeInfoText("LISTVIEW_DecSel");
  for (i = 0; i < LISTVIEW_GetNumRows(_hListView); i++) {
    LISTVIEW_DecSel(_hListView);
    GUI_Delay(SPEED / 4);
  }
  GUI_Delay(SPEED / 4);
  _ChangeInfoText("LISTVIEW_SetTextAlign");
  LISTVIEW_SetTextAlign(_hListView, 0, GUI_TA_RIGHT);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("LISTVIEW_SetColumnWidth");
  LISTVIEW_SetColumnWidth(_hListView, 1, 70);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("HEADER_SetTextColor");
  HEADER_SetTextColor(hHeader, GUI_BLUE);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("LISTVIEW_SetItemText");
  for (i = 0; i < GUI_COUNTOF(_aTable_2); i++) {
    for (j = 0; j < GUI_COUNTOF(_aTable_2[i]); j++) {
      LISTVIEW_SetItemText(_hListView, j, i, _aTable_2[i][j]);
    }
  }
  GUI_Delay(SPEED / 2);
  _ChangeInfoText("LISTVIEW_SetBkColor");
  LISTVIEW_SetBkColor(_hListView, 0, GUI_YELLOW);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("LISTVIEW_SetGridVis");
  LISTVIEW_SetGridVis(_hListView, 1);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("HEADER_SetHeight");
  HEADER_SetHeight(hHeader, 30);
  GUI_Delay(SPEED * 0.7);
  _ChangeInfoText("HEADER_SetBitmapEx");
  HEADER_SetBitmap(hHeader, 0, &bmBarCode);
  GUI_Delay(SPEED * 0.7);
  while ((Key != GUI_KEY_ENTER) && (Cnt > 0)) {
    acInfoText[0] = '0' + (Cnt / 10);
    acInfoText[1] = '0' + (Cnt-- % 10);
    _ChangeInfoText(acInfoText);
    GUI_Delay(1000);
    Key = GUI_GetKey();
  }
}
Esempio n. 15
0
void vHeartbeatTask (void * pvParameters){

	int Key, Entries, ySize;
	uint16_t click_cnt=0;
	int8_t Item_nb;
	BUTTON_Handle hOK_Button, hTest_Key;
	LISTBOX_Handle hStationListBox;
	static enum GuiState eGuiState = SELECT;
	static const GUI_ConstString StationList[] = {"ZET", "RMFFM", "RMFMAXXX", "SKY.FM", "ESKA ROCK", "TERMINAL", NULL};

	vSemaphoreCreateBinary(xButton_pushed_Semaphore);
	if(xDMAch1_Semaphore != NULL){
		xSemaphoreTake(xButton_pushed_Semaphore, 0);
	}else{
		// The semaphore was not created
	}
	BUTTON_Config();	//INT0 Button as source of interrupt
	xSemaphoreTake(xButton_pushed_Semaphore, 0);

	xListBoxQueue = xQueueCreate(2, sizeof(int8_t));


	GUI_Init();
	if(0){
		_ExecCalibration();
	}else{
		_DefaultCalibration();
	}

	GUI_SetBkColor(GUI_BLUE);
	GUI_Clear();



	if (xSemaphoreTake(xDhcpCmplSemaphore_1, portMAX_DELAY) == pdTRUE) {
		/* OK button */
		hOK_Button = BUTTON_CreateEx(120, 210, 80, 20, 0, WM_CF_SHOW, 0, 12);
		GUI_SetFont(&GUI_Font32_ASCII);
		BUTTON_SetText(hOK_Button, "OK");

		/* Cancel button */
		hTest_Key = BUTTON_CreateEx(120, 180, 80, 20, 0, WM_CF_SHOW, 0, 13);
		GUI_SetFont(&GUI_Font16B_ASCII);
		BUTTON_SetText(hTest_Key, "CLICK");
		WM_SetStayOnTop(hTest_Key, 1);

		/* Station list */
		Entries = 6;//countof(StationList) - 1;
		ySize = GUI_GetYDistOfFont(&GUI_Font16B_ASCII)*Entries;
		hStationListBox = LISTBOX_CreateEx(100, 10, 120, ySize, 0, WM_CF_SHOW, 0, 5, StationList);
		SCROLLBAR_CreateAttached(hStationListBox, SCROLLBAR_CF_VERTICAL);

	}

	while(1){
		Key = GUI_GetKey();
		//top = WM_GetStayOnTop(hTest_Key);

		switch(eGuiState){
		case SELECT:
			switch (Key){
			case 12:
				Item_nb = LISTBOX_GetSel(hStationListBox);
				if(Item_nb >= 0){
					if(xQueueSendToBack(xListBoxQueue, &Item_nb, 50/portTICK_RATE_MS) == pdPASS){
						/* OK button delete */
						BUTTON_Delete(hOK_Button);
						GUI_SetBkColor(GUI_BLUE);
						GUI_ClearRect(120, 210, 200, 230);
						GUI_ClearKeyBuffer();

						/* Listbox delete */
						LISTBOX_Delete(hStationListBox);
						GUI_ClearRect(100, 10, 220, ySize+10);

						eGuiState = PLAYING;
					}
				}
				vTaskResume(xShoutcastTaskHandle);
				break;
			case 13:
				click_cnt++;
				GUI_SetFont(&GUI_Font16B_ASCII);
				Item_nb = LISTBOX_GetSel(hStationListBox);
				GUI_DispStringAt("CNT = ", 0, 210);
				GUI_DispDecSpace(Item_nb, 3);
				break;
			default:
				break;
			}

			break;
		case PLAYING:
			switch (Key){
			case 13:
				click_cnt++;
				GUI_SetFont(&GUI_Font16B_ASCII);
//				Item_nb = LISTBOX_GetSel(hStationListBox);
				GUI_DispStringAt("CNT = ", 0, 210);
				GUI_DispDecSpace(123, 3);
				break;
			default:
				break;
			}
		}
		vTaskDelay(20/portTICK_RATE_MS);
	}
}
Esempio n. 16
0
int main(void) {
	BUTTON_Handle hButton, hB1, hB2, hB3, hB4;
	PROGBAR_Handle hProgbar;
	uint8_t i;
	
	/* Initialize system */
	SystemInit();
	
	/* Initialize delay functions */
	TM_DELAY_Init();
	
	/* Initialize LEDs */
	TM_DISCO_LedInit();
	
	/* Initialize emWin */
	if (TM_EMWIN_Init() != TM_EMWIN_Result_Ok) {
		/* Initialization error */
		while (1) {
			/* Toggle RED led */
			TM_DISCO_LedToggle(LED_RED);
			
			/* Delay */
			Delayms(100);
		}
	}
	
	/* Create progress bar at location x = 10, y = 10, length = 219, height = 30 */
	hProgbar = PROGBAR_CreateEx(10, 10, 219, 30, 0, WM_CF_SHOW, 0, GUI_ID_PROGBAR0);
	/* Set progress bar font */
	PROGBAR_SetFont(hProgbar, &GUI_Font8x16);
	/* Set progress bar text */
	PROGBAR_SetText(hProgbar, "LOADING..Please wait..");
	
	/* Imitate loading */
	for (i = 1; i <= 100; i++) {
		/* Set bar */
		PROGBAR_SetValue(hProgbar, i);
		/* Little delay, update value on LCD */
		GUI_Delay(20);
	}
	
	/* Create button with GUI_ID_OK ID number */
	hButton = BUTTON_CreateEx(10, 50, 219, 30, 0, WM_CF_SHOW, 0, GUI_ID_BUTTON0);
	/* Set text and font */
	BUTTON_SetText(hButton, "Click me to continue..");
	BUTTON_SetFont(hButton, &GUI_Font8x15B_ASCII);
	
	/* Execute, show button */
	GUI_Exec();
	
	/* Wait till button pressed */
	while (1) {
		/* Check if button was pressed */
		if (GUI_GetKey() == GUI_ID_BUTTON0) {
			/* Led Off */
			TM_DISCO_LedOff(LED_GREEN);
			
			/* Stop while loop */
			break;
		}
		/* Toggle green led */
		TM_DISCO_LedToggle(LED_GREEN);
		/* Delay 100ms */
		GUI_Delay(100);
	}

	/* Delete button functionality */
	BUTTON_Delete(hButton);
	/* Delete button from LCD */
	GUI_ClearRect(10, 50, 269, 90);
	
	/* Create buttons for leds control */
	hB1 = BUTTON_CreateEx(10, 90, 105, 50, 0, WM_CF_SHOW, 0, GUI_ID_BUTTON1);
	hB2 = BUTTON_CreateEx(124, 90, 105, 50, 0, WM_CF_SHOW, 0, GUI_ID_BUTTON2);
	hB3 = BUTTON_CreateEx(10, 150, 105, 50, 0, WM_CF_SHOW, 0, GUI_ID_BUTTON3);
	hB4 = BUTTON_CreateEx(124, 150, 105, 50, 0, WM_CF_SHOW, 0, GUI_ID_BUTTON4);
	
	/* Set font for buttons */
	BUTTON_SetFont(hB1, &GUI_Font13HB_ASCII);
	BUTTON_SetFont(hB2, &GUI_Font13HB_ASCII);
	BUTTON_SetFont(hB3, &GUI_Font13HB_ASCII);
	BUTTON_SetFont(hB4, &GUI_Font13HB_ASCII);
	
	/* Set button text */
	BUTTON_SetText(hB1, "GREEN on");
	BUTTON_SetText(hB2, "GREEN off");
	BUTTON_SetText(hB3, "RED on");
	BUTTON_SetText(hB4, "RED off");
	
	/* Button styling */
	/* Background color when button is not pressed */
	BUTTON_SetBkColor(hB1, BUTTON_CI_UNPRESSED, GUI_DARKGREEN);
	/* Background color when button is pressed */
	BUTTON_SetBkColor(hB1, BUTTON_CI_PRESSED, GUI_GREEN);
	
	/* Background color when button is not pressed */
	BUTTON_SetBkColor(hB3, BUTTON_CI_UNPRESSED, GUI_DARKRED);
	/* Background color when button is pressed */
	BUTTON_SetBkColor(hB3, BUTTON_CI_PRESSED, GUI_RED);
	
	/* Show buttons */
	GUI_Exec();
	
	while (1) {
		/* Get pressed key */
		switch (GUI_GetKey()) {
			case GUI_ID_BUTTON1:
				/* Button 1 pressed */
				TM_DISCO_LedOn(LED_GREEN);
				break;
			case GUI_ID_BUTTON2:
				/* Button 2 pressed */
				TM_DISCO_LedOff(LED_GREEN);
				break;
			case GUI_ID_BUTTON3:
				/* Button 3 pressed */
				TM_DISCO_LedOn(LED_RED);
				break;
			case GUI_ID_BUTTON4:
				/* Button 4 pressed */
				TM_DISCO_LedOff(LED_RED);
				break;
			default:
				break;
		}
	}
}