miniSTM32指针时钟画出指针后怎么让指针动起来

2019-08-19 18:17发布

求教过说是设置清屏,具体源代码有谁可以提供下么,小白求助
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
14条回答
fanghuiopenedv
1楼-- · 2019-08-19 19:23
void Draw_big_line(u16 x1, u16 y1, u16 x2, u16 y2,u8 num,u16 color)
{
switch(num)
{
case 1:
    LCD_Draw_Line(x1,y1,x2,y2,color);
break;
        case 2:
LCD_Draw_Line(x1-1,y1-1,x2-1,y2-1,color);
LCD_Draw_Line(x1,y1,x2,y2,color);
    break;
case 3:
LCD_Draw_Line(x1-1,y1-1,x2-1,y2-1,color);
LCD_Draw_Line(x1,y1,x2,y2,color);
    LCD_Draw_Line(x1+1,y1+1,x2+1,y2+1,color);
    break;
default:
    break;
}
}
//画时分秒指针
void DrawClockPointer(u8 hour, u8 min, u8 sec,u16 hour_color,u16 min_color,u16 sec_color)
{
x_temp[0] = CLOCK_CENTER_X + (CLOCK_RADIUS-SEC_PTR_OFFSET) * cos(PI/2-PI/30*sec);
y_temp[0] = CLOCK_CENTER_Y - (CLOCK_RADIUS-SEC_PTR_OFFSET) * sin(PI/2-PI/30*sec);
x_temp[1] = CLOCK_CENTER_X + (CLOCK_RADIUS_M+2) * cos(PI/2-PI/30*sec);
y_temp[1] = CLOCK_CENTER_Y - (CLOCK_RADIUS_M+2) * sin(PI/2-PI/30*sec);

Draw_big_line(x_temp[0], y_temp[0], x_temp[1], y_temp[1],1,sec_color);

x_temp[2] = CLOCK_CENTER_X + (CLOCK_RADIUS-MIN_PTR_OFFSET) * cos(PI/2-PI/30*min-PI/30/60*sec);
y_temp[2] = CLOCK_CENTER_Y - (CLOCK_RADIUS-MIN_PTR_OFFSET) * sin(PI/2-PI/30*min-PI/30/60*sec);
x_temp[3] = CLOCK_CENTER_X + (CLOCK_RADIUS_M+2) * cos(PI/2-PI/30*min);
y_temp[3] = CLOCK_CENTER_Y - (CLOCK_RADIUS_M+2) * sin(PI/2-PI/30*min);

Draw_big_line(x_temp[2], y_temp[2], x_temp[3], y_temp[3],2,min_color);

x_temp[4] = CLOCK_CENTER_X + (CLOCK_RADIUS-HOUR_PTR_OFFSET) * cos(PI/2-PI/6*hour-PI/6/60*min);
y_temp[4] = CLOCK_CENTER_Y - (CLOCK_RADIUS-HOUR_PTR_OFFSET) * sin(PI/2-PI/6*hour-PI/6/60*min);
x_temp[5] = CLOCK_CENTER_X + (CLOCK_RADIUS_M+2) * cos(PI/2-PI/6*hour-PI/6/60*min);
y_temp[5] = CLOCK_CENTER_Y - (CLOCK_RADIUS_M+2) * sin(PI/2-PI/6*hour-PI/6/60*min);

Draw_big_line(x_temp[4], y_temp[4], x_temp[5], y_temp[5],3,hour_color);
}
//清时分秒指针
void ClearClockPointer(u8 hour, u8 min, u8 sec,u16 color)
{
Draw_big_line(x_temp[0], y_temp[0], x_temp[1], y_temp[1],1,color);
Draw_big_line(x_temp[2], y_temp[2], x_temp[3], y_temp[3],2,color);
Draw_big_line(x_temp[4], y_temp[4], x_temp[5], y_temp[5],3,color);
}
//画时钟的边界
void DrawClockBorder(u16 color)
{
u16 x, y; //定义时钟x, y坐标
u16 x_temp, y_temp; //定义临时的x,y坐标
u8 i;

//画时钟外部的大圆
for(i=0; i<CLOCK_RADIUS_M; i++)
{
LCD_Draw_Circle(CLOCK_CENTER_X, CLOCK_CENTER_Y, CLOCK_RADIUS+i,color);
}
//画时钟内部的小圆
LCD_Draw_Circle(CLOCK_CENTER_X, CLOCK_CENTER_Y, CLOCK_RADIUS_M,color);
for(i=0; i><60; i++)
{
x = CLOCK_CENTER_X + (CLOCK_RADIUS) * cos(PI/2-PI/30*i);
y = CLOCK_CENTER_Y - (CLOCK_RADIUS) * sin(PI/2-PI/30*i);
if(i%5 == 0) //如果在整点的位置
{
x_temp = CLOCK_CENTER_X + (CLOCK_RADIUS-SCALL_OFFSET_B) * cos(PI/2-PI/30*i);
y_temp = CLOCK_CENTER_Y - (CLOCK_RADIUS-SCALL_OFFSET_B) * sin(PI/2-PI/30*i);
Draw_big_line(x_temp, y_temp, x, y,2,color);
x_temp = CLOCK_CENTER_X + (CLOCK_RADIUS-NUMBER_OFFSET) * cos(PI/2-PI/30*i);
y_temp = CLOCK_CENTER_Y - (CLOCK_RADIUS-NUMBER_OFFSET) * sin(PI/2-PI/30*i);

if(i == 0)
{
LCD_ShowNum(x_temp-5,y_temp-8,12,2,color,BLACK);
}
else
{
if(i < 50)
{
LCD_ShowNum(x_temp-5,y_temp-8,i/5,1,color,BLACK);
}
else
{
LCD_ShowNum(x_temp-5,y_temp-8,i/5,2,color,BLACK);
}
}
}
else
{
x_temp = CLOCK_CENTER_X + (CLOCK_RADIUS-SCALL_OFFSET_S) * cos(PI/2-PI/30*i);
y_temp = CLOCK_CENTER_Y - (CLOCK_RADIUS-SCALL_OFFSET_S) * sin(PI/2-PI/30*i);
            Draw_big_line(x_temp, y_temp, x, y,1,color);
}
}
}
fanghuiopenedv
2楼-- · 2019-08-19 20:51
调用的时候是这样的:
if(delay_time1==0){
delay_time1=20;//200ms
if(sec!= timer.sec)
{
sec = timer.sec;
LCD_Show24Num(746,50,timer.sec,2,WHITE,BLACK);
LCD_Show24Num(710,50,timer.min,2,WHITE,BLACK);
if(min!=timer.min){
min=timer.min;
LCD_Show24Num(650,20,timer.w_year,4,WHITE,BLACK);
    LCD_Show24Num(710,20,timer.w_month,2,WHITE,BLACK);
    LCD_Show24Num(746,20,timer.w_date,2,WHITE,BLACK);
LCD_Show24Num(674,50,timer.hour,2,WHITE,BLACK);
}
    ClearClockPointer(hour, min, sec,BLACK); //如果更新了,清除原来的指针
DrawClockPointer(timer.hour,timer.min,timer.sec,BLUE,BLUE,RED); //画指针
hour = timer.hour;
min = timer.min;
sec = timer.sec;
}
}
fanghuiopenedv
3楼-- · 2019-08-20 01:39
u8 time_RTC(u8 rtn)
{
u8 sec=0,hour=0,min=0;//day=0,month=0;
LCD_Clear(BLACK);
DrawClockBorder(BLUE);
hour = timer.hour;
min = timer.min;
sec = timer.sec;

DrawClockPointer(hour,min,sec,BLUE,BLUE,RED); //画指针
while(1)
{
if(delay_time1==0){
delay_time1=20;//200ms
if(sec!= timer.sec)
{
sec = timer.sec;
        ClearClockPointer(hour, min, sec,BLACK); //如果更新了,清除原来的指针
DrawClockPointer(timer.hour,timer.min,timer.sec,BLUE,BLUE,RED); //画指针
hour = timer.hour;
min = timer.min;
sec = timer.sec;
}
}
}

}
花戒
4楼-- · 2019-08-20 02:41
清除上一指针,在下一位置画指针。方便点的就是清屏,画时钟背景,然后画线。
NPCLALA
5楼-- · 2019-08-20 06:47
 精彩回答 2  元偷偷看……
八度空间
6楼-- · 2019-08-20 10:47
回复【3楼】NPCLALA:
---------------------------------
可以参考原子哥探索者开发板时钟代码,综合实验

一周热门 更多>