[mw_shl_code=c,true]#include "128x128ARMY_Interface.h"
#include <math.h>
#include <stddef.h>
#include "GUI.h"
#include "global_value.h"
#define DEG2RAD (3.1415926f / 180000)
#define MAG 4
extern GUI_CONST_STORAGE GUI_BITMAP bm128x128; //时钟表盘
//时针的坐标
static const GUI_POINT aNeedle1[] = {
{0,0},
{16,-48},
{1,-120},
{-1,-120},
{-16,-48},
};
//分针的坐标
static const GUI_POINT aNeedle2[] = {
{0,0},
{16,-40},
{1,-240},
{-1,-240},
{-16,-40},
};
//秒针的坐标
static const GUI_POINT aNeedle3[] = {
{-4,60},
{4,60},
{4,-240},
{-4,-240},
};
/*
*
* 绘图函数
*
*/
static void _Draw(void *p)
{
PARAM *pParam;
pParam = (PARAM *)p;
if(pParam->AutoDevInfo.DrawFixed) //绘制背景
{
GUI_ClearRect(0,0,128,128);
GUI_DrawBitmap(&bm128x128,0,0);//显示表盘照片
}
GUI_SetPenSize(1);//设置画笔大小为 1 个像素
//绘制移动的时针指针
GUI_SetColor(GUI_WHITE);
GUI_AA_FillPolygon(pParam->aPoints1,GUI_COUNTOF(aNeedle1),256,256);
//绘制移动的分针指针
GUI_SetColor(GUI_WHITE);
GUI_AA_FillPolygon(pParam->aPoints2,GUI_COUNTOF(aNeedle2),256,256);
//绘制移动的秒针指针
GUI_SetColor(GUI_RED);
GUI_AA_FillPolygon(pParam->aPoints3,GUI_COUNTOF(aNeedle3),256,256);
if(pParam->AutoDevInfo.DrawFixed)
{
GUI_SetColor(GUI_WHITE);
GUI_AA_FillCircle(256,256,15);//绘制实心圆
}
}
/*
*
* 演示函数
*
*/
void Draw_WatchFace(void)
{
int t1 ; //用于指针的计数
int t2 ;
int t3 ;
//GUI_DrawBitmap(&bm128x128,0,0);//显示表盘照片
GUI_SetPenSize(1); //设置画笔大小为 1 个像素
//时针
t1 = 360000 - 30000 * Hour - 500 * Min;
if(t1 < 0)
{
t1 = 360000;
}
//分针
t2 = 360000 - 6000 * Min;
if(t2 < 0)
{
t2 = 360000;
}
//秒针
t3 = 360000 - 6000 * Sec;;
if(t3 < 0)
{
t3 = 360000;
}
//旋转时针
Param.Angle1 = t1;
Param.Angle1 *= DEG2RAD;
GUI_SetColor(GUI_WHITE);
GUI_RotatePolygon(Param.aPoints1,aNeedle1,GUI_COUNTOF(aNeedle1),Param.Angle1);
//旋转分针
Param.Angle2 = t2;
Param.Angle2 *= DEG2RAD;
GUI_SetColor(GUI_WHITE);
GUI_RotatePolygon(Param.aPoints2,aNeedle2,GUI_COUNTOF(aNeedle2),Param.Angle2);
//旋转秒针
Param.Angle3 = t3;
Param.Angle3 *= DEG2RAD;
GUI_SetColor(GUI_RED);
GUI_RotatePolygon(Param.aPoints3,aNeedle3,GUI_COUNTOF(aNeedle3),Param.Angle3);
GUI_MEMDEV_DrawAuto(&AutoDev,&
aram.AutoDevInfo,&_Draw,&
aram);
}
[/mw_shl_code]
万分感谢!!!!