/** * @brief Display the application header on the USER_LCD screen * @param header: pointer to the string to be displayed * @retval None */ void USER_LCD_LOG_SetTestArea (uint16_t x0,uint16_t y0,uint16_t xSize,uint16_t ySize) { GUI_SetFont(&USER_LCD_LOG_TEXT_FONT); GUI_SetColor(USER_LCD_LOG_BACKGROUND_COLOR); GUI_FillRect(x0, y0-GUI_GetFontSizeY(), x0+xSize, y0+ySize); GUI_SetColor(USER_LCD_LOG_BACKGROUND_COLOR_EX); GUI_DrawRect(x0, y0-GUI_GetFontSizeY(), x0+xSize, y0+ySize); }
/********************************************************************* * * _UserDraw * * Function description * This routine is called by the GRAPH object before anything is drawn * and after the last drawing operation. */ void Main_UserDraw (WM_HWIN hWin, int Stage) { if (Stage == GRAPH_DRAW_LAST) { static char ycText[] = "Amplitude ";//纵坐标单位说明 static char xcText[] = "Time ";//横坐标单位说明 static GUI_RECT RectY; static GUI_RECT RectX; static GUI_RECT RectInvalid; static int FontSizeY;//字体高度 GUI_SetFont(&GUI_Font13_ASCII);//设置字体 FontSizeY = GUI_GetFontSizeY();//返回字体高度 WM_GetInsideRect(&RectY);//返回窗口尺寸 WM_GetInsideRect(&RectX); WM_GetInvalidRect(hWin, &RectInvalid);//返回窗口尺寸减去边界尺寸后的坐标 RectY.x1 = RectY.x0 + FontSizeY; RectX.y0 = SCALE_H_Pos + FontSizeY - 2; RectX.y1 = RectX.y0 + FontSizeY; GUI_SetColor(GUI_YELLOW); GUI_DispStringInRectEx(ycText, &RectY, GUI_TA_CENTER, strlen(ycText), GUI_ROTATE_CCW);//纵向显示(GUI_ROTATE_CCW),水平对齐(GUI_TA_HCENTER) GUI_DispStringInRectEx(xcText, &RectX, GUI_TA_HCENTER, strlen(xcText), GUI_ROTATE_0);//从左到右显示(GUI_ROTATE_0),水平对齐(GUI_TA_HCENTER) /*内存监视-------------------------------------------------------*/ #ifdef MEM_DEBUG__ MemDisp(200, 200); #endif /*-------------------------------------------------------*/ } }
/********************************************************************* * * GUI_EditHex */ U32 GUI_EditHex(U32 Value, U32 Min, U32 Max, int Len, int xsize) { U32 Ret = Value; int Key, x, y, ysize, Id; EDIT_Handle hEdit; EDIT_Obj* pObj; const GUI_FONT GUI_UNI_PTR * pOldFont = GUI_SetFont(EDIT_GetDefaultFont()); x = GUI_GetDispPosX(); y = GUI_GetDispPosY(); if (xsize == 0) xsize = GUI_GetCharDistX('X') * Len + 6; ysize = GUI_GetFontSizeY(); Id = 0x1234; hEdit = EDIT_Create(x, y, xsize, ysize, Id, Len, 0); pObj = EDIT_H2P(hEdit); EDIT_SetHexMode(hEdit, Value, Min, Max); WM_SetFocus(hEdit); do { Key = GUI_WaitKey(); } while ((Key != GUI_KEY_ESCAPE) && (Key != GUI_KEY_ENTER) && (Key != 0)); GUI_SetFont(pOldFont); if (Key == GUI_KEY_ENTER) Ret = pObj->CurrentValue; EDIT_Delete(hEdit); return Ret; }
/********************************************************************* * * GUI_EditString */ void GUI_EditString(char * pString, int Len, int xsize) { int Key, x, y, ysize, Id; EDIT_Handle hEdit; EDIT_Obj* pObj; const GUI_FONT GUI_UNI_PTR * pOldFont; WM_LOCK(); pOldFont = GUI_SetFont(EDIT_GetDefaultFont()); x = GUI_GetDispPosX(); y = GUI_GetDispPosY(); if (xsize == 0) { xsize = GUI_GetCharDistX('X') * Len + 6; } ysize = GUI_GetFontSizeY(); Id = 0x1234; hEdit = EDIT_Create(x, y, xsize, ysize, Id, Len, 0); EDIT_SetText(hEdit, pString); pObj = EDIT_H2P(hEdit); WM_SetFocus(hEdit); do { Key = GUI_WaitKey(); } while ((Key != GUI_KEY_ESCAPE) && (Key != GUI_KEY_ENTER) && (Key != 0)); if (Key == GUI_KEY_ENTER) { EDIT_GetText(hEdit, pString, pObj->MaxLen); } GUI_SetFont(pOldFont); EDIT_Delete(hEdit); WM_UNLOCK(); }
static void _DispStringInRect(const char GUI_FAR *s, GUI_RECT* pRect, int TextAlign) { GUI_RECT r; GUI_RECT rLine; int y = 0; int NumLines; const char *sOrg =s; int FontYSize; int xLine = 0; FontYSize = GUI_GetFontSizeY(); if (pRect) { r = *pRect; } else { GUI_GetClientRect(&r); } /* Count the number of lines for vertical alignment */ for (NumLines=1; ;NumLines++) { int LineLen= GUI__GetLineLen(s,0x7fff); s += LineLen; if (GUI__HandleEOLine(&s)) break; } /* Do the vertical alignment */ switch (TextAlign & GUI_TA_VERTICAL) { case GUI_TA_TOP: y = r.y0; break; case GUI_TA_BASELINE: case GUI_TA_BOTTOM: y = r.y1 -NumLines * FontYSize+1; break; case GUI_TA_VCENTER: y = r.y0+(r.y1-r.y0+1 -NumLines * FontYSize) /2; break; } for (s=sOrg; ;) { int LineLen= GUI__GetLineLen(s,0x7fff); int xLineSize = GUI_GetLineDistX(s, LineLen); switch (TextAlign & GUI_TA_HORIZONTAL) { case GUI_TA_HCENTER: xLine = r.x0+(r.x1-r.x0-xLineSize)/2; break; case GUI_TA_LEFT: xLine = r.x0; break; case GUI_TA_RIGHT: xLine = r.x1 -xLineSize; } rLine.x0 = GUI_Context.DispPosX = xLine; rLine.x1 = rLine.x0 + xLineSize-1; rLine.y0 = GUI_Context.DispPosY = y; rLine.y1 = y + FontYSize-1; GUI__DispLine(s, LineLen, &rLine); s += LineLen; y += GUI_GetFontDistY(); if (GUI__HandleEOLine(&s)) break; } }
/********************************************************************* * * _Paint */ static void _Paint(PROGBAR_Handle hObj) { PROGBAR_Obj* pObj = PROGBAR_H2P(hObj); WM_HWIN hWin = hObj; int xsize = WM_GetWindowSizeX(hWin); int ysize = WM_GetWindowSizeY(hWin); int tm; GUI_SetFont(pObj->pFont); { int x1; int FontSizeY = GUI_GetFontSizeY(); int xText = 0; int yText = (ysize-FontSizeY)/2; GUI_RECT r; int XSizeChar; char ac[5]; /* Just enough for the percentage */ char*s = ac; const char* pText; if (pObj->hpText != WM_HMEM_NULL) { pText = (const char*) WM_HMEM2Ptr(pObj->hpText); } else { GUI_AddDecMin((100*(I32)(pObj->v-pObj->Min))/(pObj->Max-pObj->Min), &s); *s = '%'; *(s+1) =0; pText = &ac[0]; } /* Calculate text positions */ XSizeChar = GUI_GetStringDistX(pText); x1 = _Value2X(hObj, pObj->v); switch (pObj->TextAlign &GUI_TA_HORIZONTAL) { case GUI_TA_CENTER: xText = (xsize-XSizeChar)/2; break; case GUI_TA_LEFT: xText = 0; break; case GUI_TA_RIGHT: xText = xsize-XSizeChar-1; break; } xText += pObj->XOff; yText += pObj->YOff; tm = GUI_SetTextMode(GUI_TM_TRANS); /* Draw left bar */ r.x0=0; r.x1=x1-1; r.y0=0; r.y1 = GUI_YMAX; WM_SetUserClipArea(&r); _DrawPart(pObj, 0, xText, yText, pText); /* Draw right bar */ r.x0=r.x1+1; r.x1=GUI_XMAX; WM_SetUserClipArea(&r); _DrawPart(pObj, 1, xText, yText, pText); } WM_SetUserClipArea(NULL); GUI_SetTextMode(tm); }
/* Note on usage of this routine: If at all possible, try to avoid using this, since every call will invoke the window manager. If possible, use the string routines. */ static void CL_DispChar(U16 c) { GUI_RECT r; WM_ADDORG(GUI_Context.DispPosX, GUI_Context.DispPosY); r.x1 = (r.x0 = GUI_Context.DispPosX) + GUI_GetCharDistX(c)-1; r.y1 = (r.y0 = GUI_Context.DispPosY) + GUI_GetFontSizeY()-1; WM_ITERATE_START(&r) { GL_DispChar(c); if (c != '\n') GUI_Context.DispPosX = r.x1 + 1; } WM_ITERATE_END(); WM_SUBORG(GUI_Context.DispPosX,GUI_Context.DispPosY); }
void GUIDEMO_Speed(void) { int t = GUI_GetTime(); int i = 0; int XSize = LCD_GET_XSIZE(); int YSize = LCD_GET_YSIZE(); I32 NumPixels=0; U16 aColorIndex[8]; GUIDEMO_ShowIntro("High speed", "Multi layer clipping" "\nHighly optimized drivers" ); for (i = 0; i< 8; i++) { aColorIndex[i] = GUI_Color2Index(_aColor[i]); } for (i = 0; (((t + 8000) - (int)GUI_GetTime()) > 0) && !GUIDEMO_CheckCancel(); i++) { GUI_RECT r; GUI_SetColorIndex(aColorIndex[i&7]); /* Calculate random positions */ r.x0 = rand() % XSize - XSize / 2; r.y0 = rand() % YSize - YSize / 2; r.x1 = r.x0 + rand() % XSize; r.y1 = r.y0 + rand() % YSize; GUI_FillRect(r.x0, r.y0, r.x1, r.y1); /* Clip rectangle to visible area and add the number of pixels (for speed computation) */ if (r.x1 >= XSize) r.x1 = XSize - 1; if (r.y1 >= YSize) r.y1 = YSize - 1; if (r.x0 < 0 ) r.x0 = 0; if (r.y1 < 0) r.y1 = 0; NumPixels += (r.x1 - r.x0) * (r.y1 - r.y0); /* Allow short breaks so we do not use all available CPU time ... */ } t = (GUI_GetTime() - t) / 100; GUI_Clear(); GUIDEMO_NotifyStartNext(); #if GUIDEMO_LARGE GUI_SetFont(&GUI_FontComic24B_ASCII); #else GUI_SetFont(&GUI_Font16B_ASCII); #endif GUI_SetColor(GUI_WHITE); GUI_DispStringAt("Pixels/sec: ", 10, (LCD_GetYSize() - GUI_GetFontSizeY()) / 2); if (t == 0) t++; GUI_DispDecMin(10 * (NumPixels / t)); GUIDEMO_Wait(); }
/********************************************************************* * * _UserDraw * * Purpose: * This routine is called by the GRAPH object before anything is drawn * and after the last drawing operation. */ static void _UserDraw(WM_HWIN hWin, int Stage) { if (Stage == GRAPH_DRAW_LAST) { char acText[] = "Flow Rate L/s"; GUI_RECT Rect, RectInvalid; int FontSizeY; GUI_SetFont(&GUI_Font13_ASCII); FontSizeY = GUI_GetFontSizeY(); WM_GetInsideRect(&Rect); WM_GetInvalidRect(hWin, &RectInvalid); Rect.x1 = Rect.x0 + FontSizeY; GUI_SetColor(GUI_RED); GUI_DispStringInRectEx(acText, &Rect, GUI_TA_HCENTER, strlen(acText), GUI_ROTATE_CCW); } }
/***************************************************************************** * Function - Constructor * DESCRIPTION: * *****************************************************************************/ DataPointTime::DataPointTime() { GUI_SetFont(*DEFAULT_FONT_11_LANGUAGE_INDEP); // Select Font to use SetClientArea(0,0,GUI_GetFontSizeY(),50); SetAlign(GUI_TA_LEFT + GUI_TA_BOTTOM); mSecCounter = 0; mShowColon = false; mColon = ' '; mLastColonPosition = -1; ActTime::GetInstance()->Subscribe(this); SetTime(*(ActTime::GetInstance())); }
/********************************************************************* * * _GetPhysValues * * Function description * Asks the user to press the touch screen at the given position * and returns the physical A/D values */ static void _GetPhysValues(int LogX, int LogY, int * pPhysX, int * pPhysY, const char * pString) { char acText[] = "Press here"; GUI_RECT Rect; int FontSizeY; int Align; FontSizeY = GUI_GetFontSizeY(); GUI_Clear(); GUI_SetColor(GUI_BLACK); _DispStringCentered("Runtime calibration,\n" "please touch the screen\n" "at the center of the ring."); /* Ask user to press the touch */ // // Calculate the rectangle for the string // Rect.y0 = LogY - FontSizeY; Rect.y1 = LogY + FontSizeY; if (LogX < LCD_GetXSize() / 2) { Rect.x0 = LogX + 15; Rect.x1 = LCD_GetXSize(); Align = GUI_TA_LEFT; } else { Rect.x0 = 0; Rect.x1 = LogX - 15; Align = GUI_TA_RIGHT; } // // Show the text nearby the ring // GUI_DispStringInRect(acText, &Rect, Align | GUI_TA_TOP); GUI_DispStringInRect(pString, &Rect, Align | GUI_TA_BOTTOM); // // Draw the ring // GUI_FillCircle(LogX, LogY, 10); GUI_SetColor(GUI_WHITE); GUI_FillCircle(LogX, LogY, 5); GUI_SetColor(GUI_BLACK); // // Wait until touch is pressed // _WaitForPressedState(1); *pPhysX = GUI_TOUCH_GetxPhys(); *pPhysY = GUI_TOUCH_GetyPhys(); // // Wait until touch is released // _WaitForPressedState(0); }
/********************************************************************* * * _OnPaintVert */ static void _OnPaintVert(GRAPH_SCALE_OBJ * pScaleObj, GUI_RECT * pRectInvalid) { int BorderT, BorderB, EffectSize; GRAPH_OBJ * pObj; int xPos, xPosScreen, y0, y1, i, yStart, FontSizeY, TextOffY; GUI_RECT Rect; if (!pScaleObj->TickDist) { return; } pObj = (GRAPH_OBJ *)GUI_ALLOC_h2p(pScaleObj->PaintObj.hGraph); EffectSize = pObj->Widget.pEffect->EffectSize; xPos = pScaleObj->Pos + EffectSize; xPosScreen = xPos + WM_GetOrgX(); switch (pScaleObj->TextAlign) { case GUI_TA_RIGHT: if (pRectInvalid->x0 > xPosScreen) { return; } break; case GUI_TA_LEFT: if (pRectInvalid->x1 < xPosScreen) { return; } break; } WM_GetInsideRectExScrollbar(pScaleObj->PaintObj.hGraph, &Rect); BorderT = pObj->Props.BorderT; BorderB = pObj->Props.BorderB; FontSizeY = GUI_GetFontSizeY(); TextOffY = FontSizeY / 2; y0 = Rect.y0 + BorderT; y1 = Rect.y1 - BorderB; yStart = y1 - pScaleObj->Off + pObj->ScrollStateV.v; while (yStart < y1) { yStart += pScaleObj->TickDist; } for (i = yStart; i >= y0; i -= pScaleObj->TickDist) { if ((i >= y0) && (i <= y1)) { float Value; GUI_SetTextAlign(pScaleObj->TextAlign); Value = (y1 - i - pScaleObj->Off + pObj->ScrollStateV.v) * pScaleObj->Factor; GUI_GotoXY(xPos, i - TextOffY); GUI_DispFloatMin(Value, pScaleObj->NumDecs); } } }
/********************************************************************* * * _GetPhysValues * * Purpose: * Asks the user to press the touch screen at the given position * and returns the physical pixels(A/D) values */ static void _GetPhysValues(int LogX, int LogY, int * pPhysX, int * pPhysY, const char * pString) { char acText[] = "Press here"; GUI_RECT Rect; GUI_PID_STATE State; int FontSizeY, Align; FontSizeY = GUI_GetFontSizeY(); /*获取字体的高度*/ GUI_Clear(); GUI_SetColor(GUI_BLACK); _DispStringCentered("Runtime calibration,\n" "please touch the corners of the screen\n" "at the center of the rings."); /* Ask user to press the touch */ /* Calculate the rectangle for the string(根据触摸点的位置,设置文字显示的区域) */ if (LogX < LCD_GetXSize() / 2) {/*判断是左上角的点,还是有下角的点*/ Rect.x0 = LogX + 25; Rect.x1 = LCD_GetXSize(); Rect.y0 = LogY - FontSizeY + 5; /*设置大小能显示两行字符*/ Rect.y1 = LogY + FontSizeY + 5; Align = GUI_TA_LEFT; } else { Rect.x0 = 0; Rect.x1 = LogX - 25; Rect.y0 = LogY - FontSizeY - 5; Rect.y1 = LogY + FontSizeY - 5; Align = GUI_TA_RIGHT; } /* Show the text nearby the ring */ GUI_DispStringInRect(acText, &Rect, Align | GUI_TA_TOP); GUI_DispStringInRect(pString, &Rect, Align | GUI_TA_BOTTOM); /* Draw the ring */ GUI_FillCircle(LogX, LogY, 10); GUI_SetColor(GUI_WHITE); GUI_FillCircle(LogX, LogY, 7); GUI_SetColor(GUI_BLACK); /* Wait until touch is pressed */ _WaitForPressedState(1); /*得到触摸点的值*/ GUI_TOUCH_GetState(&State); *pPhysX = State.x; *pPhysY = State.y; /* Wait until touch is released */ _WaitForPressedState(0); }
/** * @brief Displays a maximum of 60 char on the USER_LCD. * @param X: pointer to x position (in pixel) * @param Y: pointer to y position (in pixel) * @param pText: pointer to string to display on USER_LCD * @param mode: The display mode * This parameter can be one of the following values: * @arg CENTER_MODE * @arg RIGHT_MODE * @arg LEFT_MODE * @retval None */ void USER_LCD_LOG_DisplayStringAt(uint16_t X, uint16_t Y, char *pText, USER_Text_AlignModeTypdef mode, GUI_COLOR color) { /* Clear first */ GUI_SetFont(&USER_LCD_LOG_TEXT_FONT); #ifdef __USER_USE_SOLID_BK_ GUI_SetColor(USER_LCD_LOG_BACKGROUND_COLOR); GUI_FillRect(X,Y,X0+XSIZE,Y+GUI_GetFontSizeY()); #endif GUI_SetColor(color); GUI_SetTextMode(GUI_TEXTMODE_TRANS); switch (mode) { case USER_CENTER_MODE: { GUI_SetTextAlign(GUI_TA_HCENTER); //GUI_DispStringAtCEOL(pText,X,Y); GUI_DispStringAt(pText,X,Y); break; } case USER_LEFT_MODE: { GUI_SetTextAlign(GUI_TA_LEFT); //GUI_DispStringAtCEOL(pText,X,Y); GUI_DispStringAt(pText,X,Y); break; } case USER_RIGHT_MODE: { GUI_SetTextAlign(GUI_TA_RIGHT); //GUI_DispStringAtCEOL(pText,X,Y); GUI_DispStringAt(pText,X,Y); break; } default: { GUI_SetTextAlign(GUI_TA_LEFT); //GUI_DispStringAtCEOL(pText,X,Y); GUI_DispStringAt(pText,X,Y); break; } } }
/********************************************************************* * * _cbDialogIntro * * Function description * Callback routine of DialogIntro */ static void _cbDialogIntro(WM_MESSAGE * pMsg) { GUI_RECT Rect; WM_HWIN hDlg; int Id; unsigned i; int ySizeText; int yPos; yPos = 40; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: WM_GetClientRect(&Rect); GUI_SetBkColor(GUI_WHITE); GUI_SetColor(GUI_BLACK); GUI_Clear(); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringHCenterAt("Virtual screens", 160, 5); GUI_SetFont(&GUI_Font13B_ASCII); GUI_DrawBitmap(&_bmLogoBitmap, (Rect.x1 - _bmLogoBitmap.XSize) / 2, yPos); ySizeText = GUI_GetFontSizeY(); yPos += _bmLogoBitmap.YSize + 15; for (i = 0; i < GUI_COUNTOF(_apDialogIntro); i++) { GUI_DispStringHCenterAt(_apDialogIntro[i], Rect.x1 / 2, yPos); yPos += ySizeText; } break; case WM_NOTIFY_PARENT: if (pMsg->Data.v == WM_NOTIFICATION_RELEASED) { Id = WM_GetId(pMsg->hWinSrc); // Id of widget if (Id == GUI_ID_BUTTON0) { GUI_EndDialog(hDlg, 0); } } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _GetTextRect */ static void _GetTextRect(const PROGBAR_Obj* pObj, GUI_RECT* pRect, const char* pText) { int xSize = pObj->Widget.Win.Rect.x1 - pObj->Widget.Win.Rect.x0 + 1; int ySize = pObj->Widget.Win.Rect.y1 - pObj->Widget.Win.Rect.y0 + 1; int TextWidth = GUI_GetStringDistX(pText); int TextHeight = GUI_GetFontSizeY(); int EffectSize = pObj->Widget.pEffect->EffectSize; switch (pObj->TextAlign & GUI_TA_HORIZONTAL) { case GUI_TA_CENTER: pRect->x0 = (xSize - TextWidth) / 2; break; case GUI_TA_RIGHT: pRect->x0 = xSize - TextWidth - 1 - EffectSize; break; default: pRect->x0 = EffectSize; } pRect->y0 = (ySize - TextHeight) / 2; pRect->x0 += pObj->XOff; pRect->y0 += pObj->YOff; pRect->x1 = pRect->x0 + TextWidth - 1; pRect->y1 = pRect->y0 + TextHeight - 1; }
static void _ShowCharacters(const char*s, const GUI_FONT* pFont, int IncX) { int i; int ix=0, y; int FontSizeY; GUI_SetFont(pFont); FontSizeY = GUI_GetFontSizeY(); _Label(s); GUI_SetFont(pFont); y = _GetYPos(); for (i = 0; i < 20000; i++) { if (GUI_IsInFont(NULL, (U16)i)) { GUI_GotoXY(ix * IncX, y); if (ix++ > 20) { ix = 0; y += FontSizeY; } GUI_DispChar((U16)i); } } GUIDEMO_Delay(2000); GUIDEMO_NotifyStartNext(); }
/********************************************************************* * * _OnPaintHorz */ static void _OnPaintHorz(GRAPH_SCALE_OBJ * pScaleObj, GUI_RECT * pRectInvalid) { int BorderL, BorderR, EffectSize; GRAPH_OBJ * pObj; int yPos, yPosScreen, x0, x1, i, xStart, FontSizeY, xAdd; GUI_RECT Rect; if (!pScaleObj->TickDist) { return; } pObj = (GRAPH_OBJ *)GUI_ALLOC_h2p(pScaleObj->PaintObj.hGraph); EffectSize = pObj->Widget.pEffect->EffectSize; FontSizeY = GUI_GetFontSizeY(); yPos = pScaleObj->Pos - EffectSize; yPosScreen = yPos + WM_GetOrgY(); if (yPosScreen > pRectInvalid->y1) { return; } if ((yPosScreen + FontSizeY) < pRectInvalid->y0) { return; } WM_GetInsideRectExScrollbar(pScaleObj->PaintObj.hGraph, &Rect); BorderL = pObj->Props.BorderL; BorderR = pObj->Props.BorderR; x0 = Rect.x0 + BorderL; x1 = Rect.x1 - BorderR; xAdd = (pObj->Flags & GRAPH_CF_GRID_FIXED_X) ? 0 : pObj->ScrollStateH.v; xStart = x0 + pScaleObj->Off + xAdd; while (xStart > x0) { xStart -= pScaleObj->TickDist; } for (i = xStart; i <= x1; i += pScaleObj->TickDist) { if ((i > x0) && (i <= x1)) { float Value; GUI_SetTextAlign(pScaleObj->TextAlign); Value = (i - pScaleObj->Off - BorderL - EffectSize - xAdd) * pScaleObj->Factor; GUI_GotoXY(i, yPos); GUI_DispFloatMin(Value, pScaleObj->NumDecs); } } }
/********************************************************************* * * _DrawLabel */ static void _DrawLabel(GUI_MEMDEV_Handle hMem, int xPos, int yPos) { GUI_MEMDEV_Handle hMemOld; int FontSizeY; int x0; int y0; int i; hMemOld = GUI_MEMDEV_Select(hMem); GUI_SetFont(&GUI_FontD9_AA4); GUI_SetTextMode(GUI_TM_TRANS); FontSizeY = GUI_GetFontSizeY(); for (i = 0; i < 5; i++) { x0 = xPos - 7; y0 = yPos + 96 - i * 20 - 7; GUI_DrawBitmap(&_bmCircleOrange_14x14, x0, y0); GUI_GotoXY(x0 + 7, y0 + 7 - FontSizeY / 2); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_SetColor(GUI_BLACK); GUI_DispDecMin((i + 1) * 2); } GUI_MEMDEV_Select(hMemOld); }
static void DrawCursor(int xOnBase, int yOnBase, GUI_COLOR color) { double basex = screen_hcenter+(xOnBase-half_x)*Diff; double basey = screen_vcenter-(yOnBase-half_y)*Diff; GUI_SetLineStyle(GUI_LS_SOLID); GUI_SetColor(color); GUI_DrawPoint(basex, basey); GUI_DrawHLine(basey, basex - 10, basex - 2); GUI_DrawHLine(basey, basex + 2, basex + 10); GUI_DrawVLine(basex, basey - 10, basey - 2); GUI_DrawVLine(basex, basey + 2, basey + 10); GUI_SetFont(GUI_FONT_13_1); GUI_SetColor(pColor->textColor); sprintf(pStrBuf,"name:%s",pSnapLink->Boat.name); GUI_DispStringAt(pStrBuf, basex + 10, basey + 10); GUI_DispStringAt("N", basex + 10, basey + 10 + GUI_GetFontSizeY()); lltostr(pSnapLink->Boat.latitude, pStrBuf); GUI_DispStringAt(pStrBuf, basex + 23, basey+10+GUI_GetFontSizeY()); GUI_DispStringAt("E", basex + 10, basey + 10+GUI_GetFontSizeY()*2); lltostr(pSnapLink->Boat.longitude, pStrBuf); GUI_DispStringAt(pStrBuf, basex + 23, basey+10+GUI_GetFontSizeY()*2); GUI_DispStringAt("SOG:", basex + 10, basey +10+ GUI_GetFontSizeY()*3); sprintf(pStrBuf, "%2d.%d", pSnapLink->Boat.SOG/10, pSnapLink->Boat.SOG%10); GUI_DispStringAt(pStrBuf, basex + 45, basey +10+ GUI_GetFontSizeY()*3); GUI_DispStringAt("COG:", basex + 10, basey + 10+GUI_GetFontSizeY()*4); sprintf(pStrBuf, "%3d", pSnapLink->Boat.COG/10); pStrBuf[3] = 194; pStrBuf[4] = 176; pStrBuf[5] = '\0'; GUI_DispStringAt(pStrBuf, basex + 45, basey + 10+GUI_GetFontSizeY()*4); }
/********************************************************************* * * MainTask */ void MainTask(void) { GUI_MOVIE_INFO Info; GUI_MOVIE_HANDLE hMovie; int xSize, ySize; #ifdef WIN32 HANDLE hFile; const char acFileName[] = "C:\\Work\\Grafik\\Video\\FFmpeg\\FFmpeg.emf"; #define PARAM &hFile #else FS_FILE * pFile; const char acFileName[] = "\\FFmpeg.emf"; #define PARAM pFile #endif GUI_Init(); // // Get display size // xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); // // Create file handle // #ifdef WIN32 hFile = CreateFile(acFileName, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); #else FS_Init(); pFile = FS_FOpen(acFileName, "r"); #endif // // Get physical size of movie // if (GUI_MOVIE_GetInfoEx(_GetData, PARAM, &Info) == 0) { // // Check if display size fits // if ((Info.xSize <= xSize) && (Info.ySize <= ySize)) { // // Create and play movie // hMovie = GUI_MOVIE_CreateEx(_GetData, PARAM, _cbNotify); if (hMovie) { GUI_MOVIE_Show(hMovie, (xSize - Info.xSize) / 2, (ySize - Info.ySize) / 2, 1); } } else { // // Error message // GUI_SetFont(GUI_FONT_13_ASCII); GUI_DispStringHCenterAt("Video can not be shown.\n\nDisplay size too small.", xSize / 2, (ySize - GUI_GetFontSizeY()) / 2); } } while (1) { GUI_Exec(); GUI_X_Delay(1); } }
/********************************************************************* * * _LCDBench */ static void _LCDBench(void) { GUI_POINT Point; float aPixelrateBitmap[5] = {0, 0, 0, 0, 0}; float PixelrateBigFont; float PixelrateF6x8; float FillratePPS; char * s; char ac[80]; int BitsPerPixel; int xSizeString; int ySizeFont; int NumColors; int MirrorX; int MirrorY; int SwapXY; int xSize; int ySize; BitsPerPixel = LCD_GetBitsPerPixelEx(0); xSize = LCD_GetXSizeEx(0); ySize = LCD_GetYSizeEx(0); MirrorX = LCD_GetMirrorXEx(0); MirrorY = LCD_GetMirrorYEx(0); SwapXY = LCD_GetSwapXYEx(0); NumColors = (1 << BitsPerPixel); _InitXbppDDP(); // // Say hi ! // GUI_X_Log("\nLCD driver benchmark. All values are \xb5""s/pixel"); GUI_X_Log("\nLower values are better."); GUI_SetBkColor(GUI_RED); GUI_SetColor(GUI_WHITE); GUI_Clear(); GUI_SetFont(&GUI_FontComic18B_1); GUI_DispStringHCenterAt("LCD driver", xSize / 2, ySize / 3 - 10); GUI_DispStringHCenterAt("Benchmark" , xSize / 2, ySize / 3 + 20); GUI_Delay(1000); GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetLBorder(1); // // Log color depth, controller, orientation and cache // sprintf(ac, "\nColor depth: %d", BitsPerPixel); GUI_X_Log(ac); sprintf(ac, "\nOrientation: LCD_MIRROR_X = %d, LCD_MIRROR_Y = %d, LCD_SWAP_XY = %d", MirrorX, MirrorY, SwapXY); GUI_X_Log(ac); // // Measure filling // Point.x = xSize; Point.y = ySize; FillratePPS = _Measure(&_ExecFill, &Point) * (float)(2 * ((U32)xSize - 4) * ((U32)ySize - 4)); sprintf(ac, "\nFill: %f", (float)1E6 / FillratePPS); GUI_X_Log(ac); // // Measure small font // GUI_SetFont(&GUI_Font6x8); s = _acSmall; xSizeString = GUI_GetStringDistX(s); ySizeFont = GUI_GetFontSizeY(); PixelrateF6x8 = _Measure(&_ExecSmallFont, s) * (float)2 * xSizeString * ySizeFont * 8; sprintf(ac, "\nF6x8: %f", (float)1E6 / PixelrateF6x8); GUI_X_Log(ac); // // Measure big font // GUI_SetFont(&GUI_FontComic18B_ASCII); s = _acBig; xSizeString = GUI_GetStringDistX(s); ySizeFont = GUI_GetFontSizeY(); PixelrateBigFont = _Measure(&_ExecBigFont, s) * (float)2 * xSizeString * ySizeFont * 2; sprintf(ac, "\nFBig: %f", (float)1E6 / PixelrateBigFont); GUI_X_Log(ac); // // Measure 1bpp bitmap // aPixelrateBitmap[0] = _Measure(&_Exec1bpp, NULL) * (float)2 * _bm_1bpp_58x8.XSize * 8; sprintf(ac, "\n1bpp: %f", (float)1E6 / aPixelrateBitmap[0]); GUI_X_Log(ac); // // Measure 2bpp bitmap // aPixelrateBitmap[1] = _Measure(&_Exec2bpp, NULL) * (float)2 * _bm_2bpp_32x11.XSize * 11; sprintf(ac, "\n2bpp: %f", (float)1E6 / aPixelrateBitmap[1]); GUI_X_Log(ac); // // Measure 4bpp bitmap // aPixelrateBitmap[2] = _Measure(&_Exec4bpp, NULL) * (float)2 * _bm_4bpp_32x11.XSize * 11; sprintf(ac, "\n4bpp: %f", (float)1E6 / aPixelrateBitmap[2]); GUI_X_Log(ac); // // Measure 8bpp bitmap // aPixelrateBitmap[3] = _Measure(&_Exec8bpp, NULL) * (float)2 * _bm_8bpp_32x11.XSize * 11; sprintf(ac, "\n8bpp: %f", (float)1E6 / aPixelrateBitmap[3]); GUI_X_Log(ac); // // Measure device dependent bitmap // aPixelrateBitmap[4] = _Measure(&_ExecXbppDDP, NULL) * (float)2 * XSIZE_XBPP * YSIZE_XBPP; sprintf(ac, "\nXDDP: %f", (float)1E6 / aPixelrateBitmap[4]); GUI_X_Log(ac); // // Show results on display // GUI_Clear(); if (xSize < 320) { GUI_SetFont(&GUI_Font6x8); } else { GUI_SetFont(&GUI_Font8x16); } GUI_GotoXY(0, 0); GUI_DispDecMin(BitsPerPixel); GUI_DispString(" bpp, "); GUI_DispDecMin(NumColors); GUI_DispString(" colors\n\nMIRROR_X "); GUI_DispDecMin(MirrorX); GUI_DispString(", MIRROR_Y "); GUI_DispDecMin(MirrorY); GUI_DispString(", SWAPXY "); GUI_DispDecMin(SwapXY); GUI_SetLBorder(1); GUI_SetFont(&GUI_Font6x8); GUI_DispChar('\n'); _DispFillrate("\nFill: ", FillratePPS, " Fill"); _DispFillrate("\nF6x8: ", PixelrateF6x8, " F6x8"); _DispFillrate("\nFBig: ", PixelrateBigFont, " FComic18"); _DispFillrate("\n1bpp: ", aPixelrateBitmap[0], " Bitmap 1bpp"); _DispFillrate("\n2bpp: ", aPixelrateBitmap[1], " Bitmap 2bpp"); _DispFillrate("\n4bpp: ", aPixelrateBitmap[2], " Bitmap 4bpp"); _DispFillrate("\n8bpp: ", aPixelrateBitmap[3], " Bitmap 8bpp"); _DispFillrate("\nXDDP: ", aPixelrateBitmap[4], " 8/16bppDDP"); }
/** * @brief Update the text area display * @param None * @retval None */ void USER_LCD_LOG_UpdateDisplay (void) { #ifndef __USER_USE_SOLID_BK_ GUI_MEMDEV_Handle tempMem; void *pbk; void *ptemp; #endif uint8_t cnt = 0 ; uint16_t length = 0 ; uint16_t ptr = 0, index = 0; if((USER_LCD_CacheBuffer_yptr_bottom < (USER_YWINDOW_SIZE -1)) && (USER_LCD_CacheBuffer_yptr_bottom >= USER_LCD_CacheBuffer_yptr_top)) { if(u8_enable_display) { USER_LCD_LOG_DisplayStringAtLine ((USER_YWINDOW_MIN + Y0/GUI_GetFontSizeY()+ USER_LCD_CacheBuffer_yptr_bottom), (char *)(USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].line), USER_LCD_CacheBuffer[cnt + USER_LCD_CacheBuffer_yptr_bottom].color); } } else { if(USER_LCD_CacheBuffer_yptr_bottom < USER_LCD_CacheBuffer_yptr_top) { /* Virtual length for rolling */ length = USER_LCD_CACHE_DEPTH + USER_LCD_CacheBuffer_yptr_bottom ; } else { length = USER_LCD_CacheBuffer_yptr_bottom; } ptr = length - USER_YWINDOW_SIZE + 1; GUI_SetFont(&USER_LCD_LOG_TEXT_FONT); #ifdef __USER_USE_SOLID_BK_ for (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++) { index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ; if(u8_enable_display) { USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), (char *)(USER_LCD_CacheBuffer[index].line), USER_LCD_CacheBuffer[index].color); } } #else tempMem=GUI_MEMDEV_Create(GUI_MEMDEV_GetXPos(backgroundDisplayMem),GUI_MEMDEV_GetYPos(backgroundDisplayMem),GUI_MEMDEV_GetXSize(backgroundDisplayMem),GUI_MEMDEV_GetYSize(backgroundDisplayMem)); if(tempMem) { pbk=GUI_MEMDEV_GetDataPtr(backgroundDisplayMem); ptemp=GUI_MEMDEV_GetDataPtr(tempMem); memcpy((uint8_t *)ptemp,(uint8_t *)pbk,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem)); GUI_MEMDEV_Select(backgroundDisplayMem); for (cnt = 0 ; cnt < USER_YWINDOW_SIZE ; cnt ++) { index = (cnt + ptr )% USER_LCD_CACHE_DEPTH ; if(u8_enable_display) { USER_LCD_LOG_DisplayStringAtLine ((cnt + Y0/(GUI_GetFontSizeY()) + USER_YWINDOW_MIN), (char *)(USER_LCD_CacheBuffer[index].line), USER_LCD_CacheBuffer[index].color); } } GUI_MEMDEV_CopyToLCD(backgroundDisplayMem); GUI_MEMDEV_Select(0); memcpy((uint8_t *)pbk,(uint8_t *)ptemp,4*GUI_MEMDEV_GetXSize(backgroundDisplayMem)*GUI_MEMDEV_GetYSize(backgroundDisplayMem)); GUI_MEMDEV_Delete(tempMem); tempMem=0; } #endif } }
/********************************************************************* * * _Paint */ static void _Paint(CHECKBOX_Obj* pObj, CHECKBOX_Handle hObj) { GUI_RECT RectBox = {0}; int ColorIndex, EffectSize, Index; EffectSize = pObj->Widget.pEffect->EffectSize; ColorIndex = WM__IsEnabled(hObj); /* Clear inside ... Just in case */ /* Fill with parents background color */ #if WM_SUPPORT_TRANSPARENCY if (!WM_GetHasTrans(hObj)) #endif { if (pObj->Props.BkColor == GUI_INVALID_COLOR) { LCD_SetBkColor(WIDGET__GetBkColor(hObj)); } else { LCD_SetBkColor(pObj->Props.BkColor); } GUI_Clear(); } /* Get size from bitmap */ RectBox.x1 = pObj->Props.apBm[CHECKBOX_BI_ACTIV]->XSize - 1 + 2 * EffectSize; RectBox.y1 = pObj->Props.apBm[CHECKBOX_BI_ACTIV]->YSize - 1 + 2 * EffectSize; WM_SetUserClipRect(&RectBox); /* Clear inside ... Just in case */ LCD_SetBkColor(pObj->Props.aBkColorBox[ColorIndex]); GUI_Clear(); Index = pObj->CurrentState * 2 + ColorIndex; if (pObj->Props.apBm[Index]) { GUI_DrawBitmap(pObj->Props.apBm[Index], EffectSize, EffectSize); } /* Draw the effect arround the box */ WIDGET__EFFECT_DrawDownRect(&pObj->Widget, &RectBox); WM_SetUserClipRect(NULL); /* Draw text if needed */ if (pObj->hpText) { const char * s; GUI_RECT RectText; /* Draw the text */ s = (const char *) GUI_ALLOC_h2p(pObj->hpText); WM_GetClientRect(&RectText); RectText.x0 += RectBox.x1 + 1 + pObj->Props.Spacing; GUI_SetTextMode(GUI_TM_TRANS); LCD_SetColor(pObj->Props.TextColor); GUI_SetFont(pObj->Props.pFont); GUI_DispStringInRect(s, &RectText, pObj->Props.Align); /* Draw focus rectangle */ if (pObj->Widget.State & WIDGET_STATE_FOCUS) { int xSizeText = GUI_GetStringDistX(s); int ySizeText = GUI_GetFontSizeY(); GUI_RECT RectFocus = RectText; switch (pObj->Props.Align & ~(GUI_TA_HORIZONTAL)) { case GUI_TA_VCENTER: RectFocus.y0 = (RectText.y1 - ySizeText + 1) / 2; break; case GUI_TA_BOTTOM: RectFocus.y0 = RectText.y1 - ySizeText; break; } switch (pObj->Props.Align & ~(GUI_TA_VERTICAL)) { case GUI_TA_HCENTER: RectFocus.x0 += ((RectText.x1 - RectText.x0) - xSizeText) / 2; break; case GUI_TA_RIGHT: RectFocus.x0 += (RectText.x1 - RectText.x0) - xSizeText; break; } RectFocus.x1 = RectFocus.x0 + xSizeText - 1; RectFocus.y1 = RectFocus.y0 + ySizeText - 1; LCD_SetColor(pObj->Props.FocusColor); GUI_DrawFocusRect(&RectFocus, -1); } } }
/********************************************************************* * * GUIDEMO_Speed */ void GUIDEMO_Speed(void) { GUI_RECT ClipRect; GUI_RECT Rect; unsigned aColorIndex[8]; char cText[40] = { 0 }; U32 PixelsPerSecond; int TimeStart; int vySize; int xSize; int ySize; int i; xSize = LCD_GetXSize(); ySize = LCD_GetYSize(); vySize = LCD_GetVYSize(); if (vySize > ySize) { ClipRect.x0 = 0; ClipRect.y0 = 0; ClipRect.x1 = xSize; ClipRect.y1 = ySize; GUI_SetClipRect(&ClipRect); } GUIDEMO_ShowIntro("High speed", "Multi layer clipping\nHighly optimized drivers"); GUIDEMO_HideControlWin(); for (i = 0; i< 8; i++) { aColorIndex[i] = GUI_Color2Index(_aColor[i]); } TimeStart = GUIDEMO_GetTime(); for (i = 0; ((GUIDEMO_GetTime() - TimeStart) < 5000) && (GUIDEMO_CheckCancel() == 0); i++) { GUI_SetColorIndex(aColorIndex[i&7]); // // Calculate random positions // Rect.x0 = rand() % xSize - xSize / 2; Rect.y0 = rand() % ySize - ySize / 2; Rect.x1 = Rect.x0 + 20 + rand() % xSize; Rect.y1 = Rect.y0 + 20 + rand() % ySize; GUI_FillRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1); // // Clip rectangle to visible area and add the number of pixels (for speed computation) // if (Rect.x1 >= xSize) { Rect.x1 = xSize - 1; } if (Rect.y1 >= ySize) { Rect.y1 = ySize - 1; } if (Rect.x0 < 0 ) { Rect.x0 = 0; } if (Rect.y1 < 0) { Rect.y1 = 0; } GUI_Exec(); // // Allow short breaks so we do not use all available CPU time ... // } GUIDEMO_NotifyStartNext(); PixelsPerSecond = _GetPixelsPerSecond(); GUI_SetClipRect(NULL); GUIDEMO_DrawBk(); GUI_SetColor(GUI_WHITE); GUI_SetTextMode(GUI_TM_TRANS); GUI_SetFont(&GUI_FontRounded22); GUI_DrawBitmap(&bmSeggerLogo70x35, 5, 5); GUIDEMO_AddStringToString(cText, "Pixels/sec: "); GUIDEMO_AddIntToString(cText, PixelsPerSecond); GUI_DispStringHCenterAt(cText, xSize / 2, (ySize - GUI_GetFontSizeY()) / 2); GUIDEMO_Delay(4000); }
/********************************************************************* * * GUI__DispStringInRect */ void GUI__DispStringInRect(const char GUI_UNI_PTR *s, GUI_RECT* pRect, int TextAlign, int MaxNumChars) { GUI_RECT r; GUI_RECT rLine; int y = 0; const char GUI_UNI_PTR *sOrg =s; int FontYSize; int xLine = 0; int LineLen; int NumCharsRem; /* Number of remaining characters */ FontYSize = GUI_GetFontSizeY(); if (pRect) { r = *pRect; } else { GUI_GetClientRect(&r); } /* handle vertical alignment */ if ((TextAlign & GUI_TA_VERTICAL) == GUI_TA_TOP) { y = r.y0; } else { int NumLines; /* Count the number of lines */ for (NumCharsRem = MaxNumChars, NumLines = 1; NumCharsRem ;NumLines++) { LineLen = GUI__GetLineNumChars(s, NumCharsRem); if(LineLen == 0) { break; } NumCharsRem -= LineLen; s += GUI_UC__NumChars2NumBytes(s, LineLen); if (GUI__HandleEOLine(&s)) break; } /* Do the vertical alignment */ switch (TextAlign & GUI_TA_VERTICAL) { case GUI_TA_BASELINE: case GUI_TA_BOTTOM: y = r.y1 -NumLines * FontYSize+1; break; case GUI_TA_VCENTER: y = r.y0+(r.y1-r.y0+1 -NumLines * FontYSize) /2; break; } } /* Output string */ for (NumCharsRem = MaxNumChars, s = sOrg; NumCharsRem;) { int xLineSize; LineLen = GUI__GetLineNumChars(s, NumCharsRem); if(LineLen == 0) { break; } NumCharsRem -= LineLen; xLineSize = GUI__GetLineDistX(s, LineLen); switch (TextAlign & GUI_TA_HORIZONTAL) { case GUI_TA_HCENTER: xLine = r.x0+(r.x1-r.x0-xLineSize)/2; break; case GUI_TA_LEFT: xLine = r.x0; break; case GUI_TA_RIGHT: xLine = r.x1 -xLineSize + 1; } rLine.x0 = GUI_Context.DispPosX[GUI_Context.SelLayer] = xLine; rLine.x1 = rLine.x0 + xLineSize-1; rLine.y0 = GUI_Context.DispPosY[GUI_Context.SelLayer] = y; rLine.y1 = y + FontYSize-1; GUI__DispLine(s, LineLen, &rLine); s += GUI_UC__NumChars2NumBytes(s, LineLen); y += GUI_GetFontDistY(); if (GUI__HandleEOLine(&s)) break; } }