实验效果
LCD屏幕显示 年月日时分秒 设置任意时间 到时间蜂鸣器启动
主函数
- 简单说 就是初始化各个部件
- 然后让LED1 闪烁来提示系统的正常运行
- 显示屏显示实时时间
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "usmart.h"
- #include "rtc.h"
- #include "oled.h"
- #include "beep.h"
- int main(void)
- {
- u8 t=0;
- delay_init();
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
- uart_init(115200); //
- LED_Init(); //
- LCD_Init();
- OLED_Init(); //
- OLED_Clear();
- usmart_dev.init(SystemCoreClock/1000000); //
- BEEP_Init();
- RTC_Init(); //
- POINT_COLOR=RED;//
- LCD_ShowString(60,50,200,16,16,"Elite STM32");
- LCD_ShowString(60,70,200,16,16,"RTC TEST");
- LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
- LCD_ShowString(60,110,200,16,16,"2015/1/14");
- //ÏÔʾʱ¼ä
- POINT_COLOR=BLUE;//
- LCD_ShowString(60,130,200,16,16," - - ");
- LCD_ShowString(60,162,200,16,16," : : ");
- while(1)
- {
- if(t!=calendar.sec)
- {
- t=calendar.sec;
- //LCD_ShowNum(60,130,calendar.w_year,4,16);
- OLED_ShowNum(0,2,calendar.w_year,4,16);
- //LCD_ShowNum(100,130,calendar.w_month,2,16);
- OLED_ShowNum(0,4,calendar.w_month,2,16);
- //LCD_ShowNum(124,130,calendar.w_date,2,16);
- OLED_ShowNum(0,6,calendar.w_date,2,16);
- switch(calendar.week)
- {
- case 0:
- LCD_ShowString(60,148,200,16,16,"Sunday ");
- break;
- case 1:
- LCD_ShowString(60,148,200,16,16,"Monday ");
- break;
- case 2:
- LCD_ShowString(60,148,200,16,16,"Tuesday ");
- break;
- case 3:
- LCD_ShowString(60,148,200,16,16,"Wednesday");
- break;
- case 4:
- LCD_ShowString(60,148,200,16,16,"Thursday ");
- break;
- case 5:
- LCD_ShowString(60,148,200,16,16,"Friday ");
- break;
- case 6:
- LCD_ShowString(60,148,200,16,16,"Saturday ");
- break;
- }
- LCD_ShowNum(60,162,calendar.hour,2,16);
- LCD_ShowNum(84,162,calendar.min,2,16);
- LCD_ShowNum(108,162,calendar.sec,2,16);
- LED0=!LED0;
- }
- delay_ms(10);
- };
- }
复制代码
|
|