⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2dgl_drawscale.c

📁 ucgui源码3.32
💻 C
字号:
/*
*********************************************************************************************************
*                                                uC/GUI
*                        Universal graphic software for embedded applications
*
*                       (c) Copyright 2002, Micrium Inc., Weston, FL
*                       (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
*
*              礐/GUI 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 redistributed
*              in any way. We appreciate your understanding and fairness.
*
----------------------------------------------------------------------
File        : 2DGL_DrawScale.c
Purpose     : Drawing a scale using GUI-functions
----------------------------------------------------------------------
*/

#include "gui.h"
#include <math.h>
#include <stddef.h>

/*******************************************************************
*
*       static code
*
********************************************************************
*/

/*******************************************************************
*
*       _DrawScale

  Drawing a scale using GUI-functions
*/
static void _DrawScale(void) {
  int XSize = LCD_GetXSize();
  int YSize = LCD_GetYSize();
  int XMid  = XSize / 2;
  int i;
  int r1   = 110;
  int r2   = 140;
  int rt   = 100;
  int y    = 240;
  int step =  15;
  int r = (r1 + r2) / 2;
  GUI_SetBkColor(GUI_BLACK);
  GUI_Clear();
  GUI_SetColor(GUI_WHITE);
  GUI_SetFont(&GUI_Font24_ASCII);
  GUI_SetTextAlign(GUI_TA_HCENTER);
  GUI_DispStringAt("DrawScale - Sample", 160, 5);
  while (1) {
    int c = 0;
    GUI_SetColor(GUI_WHITE);
    GUI_SetFont(&GUI_Font8x16);
    GUI_SetTextAlign(GUI_TA_LEFT);
    GUI_Delay(1000);
    GUI_DispStringAtCEOL("using", 5, 40);
    GUI_DispStringAtCEOL("GUI_AA_DrawArc", 5, 55);
    GUI_Delay(1750);
    GUI_SetPenSize(r2 - r1);
    GUI_SetColor(0x0000AA);
    GUI_AA_DrawArc(XMid, y, r, r, 45, 60);
    GUI_Delay(1500);
    GUI_SetColor(0x00AA00);
    GUI_AA_DrawArc(XMid, y, r, r, 60, 90);
    GUI_Delay(1500);
    GUI_SetPenSize(2);
    GUI_SetColor(GUI_WHITE);
    GUI_AA_DrawArc(XMid, y, r1, r1, 45, 135);
    GUI_Delay(1500);
    GUI_AA_DrawArc(XMid, y, r2, r2, 45, 135);
    GUI_Delay(2000);
    GUI_DispStringAtCEOL("", 5, 55);
    GUI_Delay(200);
    GUI_DispStringAtCEOL("using", 5, 40);
    GUI_DispStringAtCEOL("GUI_AA_DrawLine & GUI_DispCharAt", 5, 55);
    GUI_Delay(5000);
    for (i = 45; i <= 135; i += step) {
      float co = cos(i * 3.1415926 / 180);
      float si = sin(i * 3.1415926 / 180);
      int   x1 = XMid - r1 * co;
      int   y1 = y    - r1 * si;
      int   x2 = XMid - (r2 - 1) * co;
      int   y2 = y    - (r2 - 1) * si;
      int   xt = XMid - rt * co;
      int   yt = y    - rt * si;
      GUI_SetColor(GUI_WHITE);
      GUI_SetPenSize(2);
      GUI_AA_DrawLine(x1, y1, x2, y2);
      GUI_SetColor(GUI_GREEN);
      GUI_SetFont(&GUI_Font8x8);
      GUI_DispCharAt('0' + c++, xt - 4, yt - 4);
      GUI_Delay(750);
    }
    GUI_Delay(5250);
    GUI_ClearRect(0, 30, 320, 240);
  }
}

/*******************************************************************
*
*       MainTask
*
*       Demonstrates GUI-functions
*
********************************************************************
*/

void MainTask(void) {
  GUI_Init();
  _DrawScale();
  while(1); 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -