PROGBAR - Usage (Sample)

From SEGGER Wiki
Jump to: navigation, search
PROGBAR_Usage.c
PROGBAR Usage.gif
File(s) required
  • PROGBAR_Usage.c
Runs in simulation Yes
Runs on target Yes
Download PROGBAR_Usage.c

This sample demonstrates the usage of a PROGBAR widget.

Code

/*********************************************************************
*                    SEGGER Microcontroller GmbH                     *
*        Solutions for real time microcontroller applications        *
**********************************************************************
*                                                                    *
*        (c) 1996 - 2020  SEGGER Microcontroller GmbH                *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
**********************************************************************

** emWin V6.10 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws.   Knowledge of the
source code may not be used to write a similar product.  This file may
only  be used  in accordance  with  a license  and should  not be  re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File        : PROGBAR_Usage.c
Purpose     : Sample that demonstrates the usage of PROGBAR widgets
              in emWin.
Requirements: WindowManager - (x)
              MemoryDevices - ( )
              AntiAliasing  - ( )
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  PROGBAR_Handle hProg;
  int            Cnt;

  //
  // Init GUI and clear background
  //
  GUI_Init();
  GUI_SetBkColor(GUI_WHITE);
  GUI_Clear();
  Cnt = 0;
  //
  // Create PROGBAR handle
  //
  hProg = PROGBAR_CreateEx(10, 10, 80, 20, WM_HBKWIN, WM_CF_SHOW, PROGBAR_CF_HORIZONTAL, GUI_ID_PROGBAR0);

  while (1) {
    //
    // Fill the progress bar
    //
    if (Cnt == 100) {
      Cnt = 0;
    }
    if (Cnt < 100) {
      Cnt++;
    }
    //
    // Set the value of the PROGBAR.
    //
    PROGBAR_SetValue(hProg, Cnt);
    GUI_Delay(100);
  }
}

/*************************** End of file ****************************/