分享一个基于STM32F103ZET6的指针式时钟,非GUI设计。
单片机源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "usmart.h"
- #include "rtc.h"
- int main(void)
- {
- u8 t=0;
- delay_init(); //延时函数初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
- uart_init(115200); //串口初始化为115200
- LED_Init(); //LED端口初始化
- LCD_Init();
- usmart_dev.init(SystemCoreClock/1000000); //初始化USMART
- RTC_Init(); //RTC初始化
- Watch_mark(); //指针式时钟刻度显示
- Pointer(); //指针跳动显示函数
-
-
- while(1)
- {
- if(t!=calendar.sec)
- {
- t=calendar.sec;
-
- POINT_COLOR=RED;
- LCD_ShowNum(10,240,calendar.w_year,4,24);
- LCD_ShowNum(60,240,calendar.w_month,2,24);
- LCD_ShowNum(90,240,calendar.w_date,2,24);
- Pointer();
- switch(calendar.week)
- {
- case 0:
- LCD_ShowString(130,240,200,24,24," Sunday ");
- break;
- case 1:
- LCD_ShowString(130,240,200,24,24," Monday ");
- break;
- case 2:
- LCD_ShowString(130,240,200,24,24," Tuesday ");
- break;
- case 3:
- LCD_ShowString(130,240,200,24,24," Wednesday ");
- break;
- case 4:
- LCD_ShowString(130,240,200,24,24," Thursday ");
- break;
- case 5:
- LCD_ShowString(130,240,200,24,24," Friday ");
- break;
- case 6:
- LCD_ShowString(130,240,200,24,24," Saturday ");
- break;
- }
- LCD_ShowNum(55,280,calendar.hour,2,24);
- LCD_ShowNum(103,280,calendar.min,2,24);
- LCD_ShowNum(151,280,calendar.sec,2,24);
- }
- };
- }
复制代码
所有资料51hei附件下载:
STM32指针式时钟显示.7z
(241.54 KB, 下载次数: 22)
|