STM32+WIFI获取网络时间+8位数码管显示+0.96OLED显
资料下载地址:STM32+WIFI获取网络时间+8位数码管显示+0.96OLED
1、项目介绍
主控芯片STM32C8T6
接线:串口1:PA9 PA10
OELD :PB6 PB7
数码管使用:MAX7219 8位数码管
Max7219_pinCLK PAout(5)
Max7219_pinCS PAout(3)
Max7219_pinDIN PAout(7)
2、实物图片
3、程序
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "usart.h"
#include "ESP8266.h"
#include "oled.h"
#include "RTC.h"
#include "dht11.h"
#include "7219.h"
int main(void)
{
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为115200
LED_Init(); //LED端口初始化
KEY_Init(); //初始化与按键连接的硬件接口
OLED_Init(); //初始化OLED
OLED_Clear();
ESP8266_Init();
esp8266_get_time();//获取时间
dispose_time_data(); //更新时间
esp8266_get_weather();//获取天气
dispose_wea_data();//更新天气
RTC_Init(); //初始化与按键连接的硬件接口
display_week();//显示星期
SPI1_Init();
Init_MAX7219();
while(1)
{
//0.96OLED显示
OLED_ShowNum(0,0,calendar.w_year,4,16);//年
OLED_ShowNum(48,0,calendar.w_month,2,16);//月
OLED_ShowNum(80,0,calendar.w_date,2,16);//日
OLED_ShowNum(0,2,calendar.hour,2,16);//时
OLED_ShowNum(24,2,calendar.min,2,16);//分
OLED_ShowNum(48,2,calendar.sec,2,16);//秒
OLED_ShowNum(20,4,temperature,2,16);//温度
if((calendar.hour==0)&&(calendar.min==0)&&(calendar.sec==0))
{
calendar.week+=1;
if(calendar.week>8) calendar.week=1;
display_week();//显示星期
}
// 数码管显示
if(calendar.sec<55)
{
Write_Max7219(0x08, calendar.hour/10);
Write_Max7219(0x07, calendar.hour%10);
Write_Max7219(0x06, 0x0A);
Write_Max7219(0x05, calendar.min/10);
Write_Max7219(0x04, calendar.min%10);
Write_Max7219(0x03, 0x0A);
Write_Max7219(0x02, calendar.sec/10);
Write_Max7219(0x01, calendar.sec%10);
delay_ms(100);
}
else
{
Write_Max7219(0x08, calendar.w_month/10); //日期
Write_Max7219(0x07, calendar.w_month%10);
Write_Max7219(0x06, 0x0A);
Write_Max7219(0x05, calendar.w_date/10);
Write_Max7219(0x04, calendar.w_date%10);
Write_Max7219(0x02, temperature/10);//温度
Write_Max7219(0x01, temperature%10);
delay_ms(100);
}
}
}