/******************************************************************* * * MainTask * ******************************************************************** */ void MainTask_AppClock(void) { WM_HWIN hWinClock; GUI_AUTODEV AutoDev; PARAM Param; int hour = 0; time_t oldtimestamp = 0; time_t curtimestamp = 0; struct tm *currUtime; //Init time curtimestamp = time(0); oldtimestamp = curtimestamp; currUtime=localtime(&curtimestamp); hWinClock = WM_CreateWindowAsChild(0, 0, 320, 240, WM_HBKWIN, WM_CF_SHOW, _cbClock, 0); WM_SelectWindow(hWinClock); WM_SetCreateFlags(WM_CF_MEMDEV); WM_SetFocus(hWinClock); _MoveShiftWindow(&hWinClock, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0); /*hWinClock = WM_CreateWindow(0, 0, 320, 240, WM_CF_SHOW, _cbClock, 0); WM_SetFocus(hWinClock); //_MoveShiftWindow(&hWinCalendar, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0); WM_EnableMemdev(hWinClock);*/ /* GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK);*/ GUI_AA_EnableHiRes(); GUI_AA_SetFactor(MAG); GUI_MEMDEV_CreateAuto(&AutoDev); while (!GUI_CheckCancel(APP_Clock)) { GUI_Delay(10); curtimestamp = time(0); currUtime = localtime(&curtimestamp); if (1 == curtimestamp - oldtimestamp) { Param.Angle1 = (59 - currUtime->tm_sec) * 6 * (3.1415926f / 180); Param.Angle2 = (3599 - ((currUtime->tm_min * 60) + (currUtime->tm_sec)))*0.1*(3.1415926f / 180); hour = (currUtime->tm_hour>12) ? (currUtime->tm_hour - 12) : (currUtime->tm_hour); Param.Angle3 = (43199 - ((hour * 3600) + (currUtime->tm_min * 60) + (currUtime->tm_sec)))*0.0083333*(3.1415926f / 180); GUI_RotatePolygon(Param.aPoint1, _aNeedle[0], GUI_COUNTOF(_aNeedle[0]), Param.Angle1); GUI_RotatePolygon(Param.aPoint2, _aNeedle[1], GUI_COUNTOF(_aNeedle[1]), Param.Angle2); GUI_RotatePolygon(Param.aPoint3, _aNeedle[2], GUI_COUNTOF(_aNeedle[2]), Param.Angle3); GUI_MEMDEV_DrawAuto(&AutoDev, &Param.AutoDevInfo, &Draw, &Param); } oldtimestamp = curtimestamp; } WM_DeleteWindow(hWinClock); hWinClock = 0; }
/******************************************************************* * * _ShowHiresAntialiasing * * Function description * This function creates the memory auto devices and handle the * rotation of the pointers */ static void _ShowHiresAntialiasing(void) { GUI_AUTODEV aAuto[2]; PARAM Param; unsigned i; Param.Factor = 3; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringAt("AA_HiResAntialiasing - Sample", 160, 5); GUI_SetFont(&GUI_Font6x8); GUI_DispStringHCenterAt("Using\nhigh\nresolution\nmode", 110, 180); GUI_DispStringHCenterAt("Not using\nhigh\nresolution\nmode", 210, 180); // // Create GUI_AUTODEV objects // for (i = 0; i < countof(aAuto); i++) { GUI_MEMDEV_CreateAuto(&aAuto[i]); } // // Calculate pointer for high resolution // for (i = 0; i < countof(_aPointer); i++) { _aPointerHiRes[i].x = _aPointer[i].x * Param.Factor; _aPointerHiRes[i].y = _aPointer[i].y * Param.Factor; } GUI_AA_SetFactor(Param.Factor); /* Set antialiasing factor */ while (1) { for (i = 0; i < 1800; i++) { float Angle = (i >= 900) ? 1800 - i : i; Angle *= 3.1415926f / 1800; // // Draw pointer with high resolution // GUI_AA_EnableHiRes(); GUI_RotatePolygon(Param.aPoints, _aPointerHiRes, countof(_aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[0], &Param.AutoInfo, _DrawHiRes, &Param); // // Draw pointer without high resolution // GUI_AA_DisableHiRes(); GUI_RotatePolygon(Param.aPoints, _aPointer, countof(_aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[1], &Param.AutoInfo, _Draw, &Param); GUI_Delay(2); } } }