专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
miniSTM32指针时钟画出指针后怎么让指针动起来
2019-08-19 18:17
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
12873
14
1496
求教过说是设置清屏,具体源代码有谁可以提供下么,小白求助
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
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:
---------------------------------
可以参考原子哥探索者开发板时钟代码,综合实验
加载中...
1
2
3
下一页
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
STM32WLE5CC连接SX1268在LoRa模式下能与 SX1278互通吗?
2 个回答
STM32开发板免费用活动
7 个回答
stm32 处理 DHT11占用太多时间,大家程序是怎么设计的
8 个回答
分享一个STM32单片机做的离线编程器代码
9 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
欲练此功必先自宫之STM32汇编启动,放慢是为了更好的前行
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
{
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);
}
}
}
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;
}
}
{
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;
}
}
}
}
---------------------------------
可以参考原子哥探索者开发板时钟代码,综合实验
一周热门 更多>