/*********************************************************************
* SEGGER MICROCONTROLLER SYSTEME GmbH *
* Solutions for real time microcontroller applications *
* *
* emWin GSC sample code *
* *
**********************************************************************
----------------------------------------------------------------------
File : MEMDEV_AutoDev.c
Purpose : Example demonstrating the use of GUI_AUTODEV-objects
----------------------------------------------------------------------
*/
/*******************************************************************
*
* structure containing information for drawing routine
*/
typedef struct {
/* Information about what has to be displayed */
GUI_AUTODEV_INFO AutoDevInfo;
/* Polygon data */
GUI_POINT aPoints[7];
float Angle;
} PARAM;
This routine returns the value value to indicate. In a real
application, this value would somehow be measured.
*/
static float _GetAngle(int tDiff) {
if (tDiff < 15000) {
return 225 - 0.006 * tDiff ;
}
tDiff -= 15000;
if (tDiff < 7500) {
return 225 - 90 + 0.012 * tDiff ;
}
tDiff -= 7000;
return 225;
}
/*******************************************************************
*
* _DemoScale
*/
static void _DemoScale(void) {
int Cnt;
int tDiff, t0;
PARAM Param; /* Parameters for drawing routine */
GUI_AUTODEV AutoDev; /* Object for banding memory device */
/* Show message */
GUI_SetBkColor(GUI_BLACK);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_DispStringHCenterAt("MEMDEV_AutoDev - Sample", 160, 5);
GUI_SetFont(&GUI_Font8x16);
GUI_DispStringHCenterAt("Scale using GUI_AUTODEV-object", 160, 50);
/* Enable high resolution for antialiasing */
GUI_AA_EnableHiRes();
GUI_AA_SetFactor(MAG);
while (1) {
t0 = GUI_GetTime();
/* Create GUI_AUTODEV-object */
GUI_MEMDEV_CreateAuto(&AutoDev);
/* Show needle for a fixed time */
for (Cnt = 0; (tDiff = GUI_GetTime() - t0) < 24000; Cnt++) {
/* Get value to display an calculate polygon for needle */
Param.Angle = _GetAngle(tDiff)* DEG2RAD;
GUI_RotatePolygon(Param.aPoints, _aNeedle, countof(_aNeedle), Param.Angle);
GUI_MEMDEV_DrawAuto(&AutoDev, &Param.AutoDevInfo, &_Draw, &Param);
}
/* Display milliseconds / picture */
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font8x16);
GUI_DispStringHCenterAt("Milliseconds / picture:", 160, 200);
GUI_SetTextAlign(GUI_TA_CENTER);
GUI_SetTextMode(GUI_TM_NORMAL);
GUI_DispNextLine();
GUI_GotoX(160);
GUI_DispFloatMin((float)tDiff / (float)Cnt, 2);
/* Delete GUI_AUTODEV-object */
GUI_MEMDEV_DeleteAuto(&AutoDev);
GUI_Delay(3000);
GUI_ClearRect(0, 70, 319, 239);
}
}
/*******************************************************************
*
* MainTask
*
* Demonstrates the use of an auto memory device
*
********************************************************************
*/