日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

毕业分享 STM32智能桌面天气预报时钟系统

發布時間:2023/12/29 windows 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 毕业分享 STM32智能桌面天气预报时钟系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 0 前言
  • 1 設計內容
  • 2 軟件設計
  • 3 關鍵代碼
  • 4 最后

0 前言

🔥
這兩年開始畢業設計和畢業答辯的要求和難度不斷提升,傳統的畢設題目缺少創新和亮點,往往達不到畢業答辯的要求,這兩年不斷有學弟學妹告訴學長自己做的項目系統達不到老師的要求。

為了大家能夠順利以及最少的精力通過畢設,學長分享優質畢業設計項目,今天要分享的是

🚩 基于STM32與wifi的天氣預報網時鐘系統

🥇學長這里給一個題目綜合評分(每項滿分5分)

  • 難度系數:3分
  • 工作量:3分
  • 創新點:3分

🧿 項目分享:

https://gitee.com/sinonfin/sharing

1 設計內容

該項目中學長是以實時時鐘芯片DS1302和STM32F103C8T6
單片機為主要研究對象,著重進行嵌入式控制系統的設計研究和如何讀取DS1302內部時鐘信息的研究。以及運用18B20進行實時溫度檢測。

主要內容包括:

  • 1)實時溫度顯示;
  • 2)年月日星期時分秒顯示;
  • 3)年月日星期時分秒調整;
  • 4)鬧鐘定時小時分鐘和秒;


原理圖如下

2 軟件設計

主程序開始初始化,并打開中斷,然后執行掃描鬧鐘、鍵盤及讀取18B20值。當有S1鍵按下時,執行時鐘設置,當有S4鍵按下時,則進入鬧鐘設置,無論是時鐘還是鬧鐘,設置完后退出,溫度、時鐘恢復實時顯示。主程序流程圖如圖

通過單片機判斷S1按下的次數來設置,由s1num標志位來記錄次數,用if語句判斷執行命令。系統程序不斷掃面鍵盤,當s1鍵按下后產生一個低電平,即s1num加一。在調節時間之前首先進行各個變量初始化,及設置起始時間,同時為讀取數據作準備。當s1=1時進入秒的設置,地址指針指向miao顯示位置處,通過兩個if語句分別循環控制顯示秒數的加和減。當s1=2時,地址指針指向fen顯示位置處,變量最大值為59。當s1=3時,地址指針指向shi顯示位置處,變量最大值設為23。當s1=4時,地址指針指向week顯示位置處,最大值設為7,1至7分別用MON、TUE、WED、THU
、FRI、SAT、SUN字符串顯示。隨著s2、s3值的的變化顯示不同的字符串。當s1=5時,地址指針指向day顯示位置,變量最大值為31。當s1=6時,地址指針指向month顯示位置,變量最大值為12。
當s1=7時,地址指針指向year顯示位置,最大值為99。

時間設置程序流程圖如圖3-3所示。在開始時間設置之前程序會關閉全局中斷,直至設置結束,中斷又會重新開啟,進入計時狀態。
鬧鐘的設置時通過S1鍵的按下次數來判斷的。當單片機檢測到S4鍵按下一次時則進入鬧鐘設置界面,光標并自動跳到秒設置位置,可以對秒進行設置,當S1鍵依次按下1、2、3次時,則分別進入鬧鐘的秒、分、時關的設置。:

3 關鍵代碼

#include "stm32f10x.h" #include "delay.h" #include "usart.h" #include "sys.h" #include "1302.h" #include "key.h" #include "timer.h" #include "flash.h" #include "ds18b20.h" #include "time2.h" #include "beep.h" #include "lcd1602.h" u8 key = 0; u8 keyflag = 0; u8 time[8]; int flag1 = 0; u8 flag2 = 0;//鬧鐘開關狀態 u8 flag3; int beepflag1 = 0; u8 n = ' '; u8 memory_flag=0; extern u8 flag4; extern u8 flag5; extern my_time TIME; extern u8 time4flag; u8 nolock[] = {15,30}; #define size sizeof(nolock) u8 nolock1[size]; short temperature; //接收讀取到的溫度 //#define FLASH_SAVE_ADDR 0X0800b000 //存儲的地址p //#define FLASH_SAVE_ADDR1 0X0800C000 //存儲的地址 //#define FLASH_SAVE_ADDR2 0X0800CB00 //存儲的地址 u8 state,s0; u8 key1_flag=1,key2_flag=1,key3_flag=1,key4_flag=1; u8 sec1,sec2; u8 ms=0; u8 read_flag=1; u8 time_data[7]; u8 time_data_1[7]; u8 time_data_2[7]; u8 time_data_3[7]; u8 time_data_4[7]; u8 beep1=0;void memory() {//08002400STMFLASH_Write(0X0800b000,(u16*)nolock1,2);STMFLASH_Write(0X0800C000,(u16*)&flag2,1); }void read_memory() {STMFLASH_Read(0X0800b000,(u16*)nolock1,2);STMFLASH_Read(0X0800C000,(u16*)&flag2,1);if(nolock1[0]>23||nolock1[1]>59||flag2>1){nolock1[0]=6;nolock1[1]=30;flag2=1;} }void dis_play() {if(state<7){LCD1602_Set_Cursor(0,0);if(state==1&&s0){LCD1602_Show_Str(" ");}else{LCD1602_Show_Str("20");LCD1602_Set_Cursor(2,0);LCD1602_Write_Dat('0'+TIME.year/10%10);LCD1602_Write_Dat('0'+TIME.year%10); //年}LCD1602_Show_Str("-");if(state==2&&s0){LCD1602_Show_Str(" ");}else{LCD1602_Write_Dat('0'+TIME.month/10%10);LCD1602_Write_Dat('0'+TIME.month%10); //月}LCD1602_Show_Str("-");if(state==3&&s0){LCD1602_Show_Str(" "); }else{LCD1602_Write_Dat('0'+TIME.date/10%10);LCD1602_Write_Dat('0'+TIME.date%10); //日}LCD1602_Show_Str(" "); switch(Conver_week(TIME.year,TIME.month,TIME.date)) //星期{case 0:LCD1602_Show_Str("Sun"); break;case 1:LCD1602_Show_Str("Mon"); break;case 2:LCD1602_Show_Str("Tue"); break;case 3:LCD1602_Show_Str("Wed"); break;case 4:LCD1602_Show_Str("Thu"); break;case 5:LCD1602_Show_Str("Fri"); break;case 6:LCD1602_Show_Str("Sat"); break;}LCD1602_Set_Cursor(0,1);if(state==4&&s0){LCD1602_Show_Str(" ") ;}else{LCD1602_Write_Dat('0'+TIME.hour/10%10);LCD1602_Write_Dat('0'+TIME.hour%10); //時}LCD1602_Show_Str(":");if(state==5&&s0){LCD1602_Show_Str(" "); }else{LCD1602_Write_Dat('0'+TIME.minute/10%10); //分LCD1602_Write_Dat('0'+TIME.minute%10);}LCD1602_Show_Str(":");if(state==6&&s0){LCD1602_Show_Str(" "); }else{LCD1602_Write_Dat('0'+TIME.second/10%10); //秒LCD1602_Write_Dat('0'+TIME.second%10);}LCD1602_Show_Str(" ");if(temperature<0){ temperature=-temperature;LCD1602_Write_Dat('-');LCD1602_Write_Dat(0x30+temperature/100%10); //取出第一位LCD1602_Write_Dat(0x30+temperature%100/10); //取出第二位LCD1602_Write_Dat(0x2E); LCD1602_Write_Dat(0x30+temperature%10); //取出最后一位LCD1602_Write_Dat(0xDF);LCD1602_Write_Dat('C');}else if(temperature>999){LCD1602_Write_Dat(0x30+temperature/1000%10); //取出第一位LCD1602_Write_Dat(0x30+temperature%1000/100); //取出第一位LCD1602_Write_Dat(0x30+temperature%1000/10%10); //取出第二位LCD1602_Write_Dat(0x2E); LCD1602_Write_Dat(0x30+temperature%10); //取出最后一位LCD1602_Write_Dat(0xDF);LCD1602_Write_Dat('C');}else{//LCD1602_Write_Cmd(0x80+0x40+0x09);LCD1602_Write_Dat(' ');LCD1602_Write_Dat(0x30+temperature/100%10); //取出第一位LCD1602_Write_Dat(0x30+temperature%100/10); //取出第二位LCD1602_Write_Dat(0x2E); LCD1602_Write_Dat(0x30+temperature%10); //取出最后一位LCD1602_Write_Dat(0xDF);LCD1602_Write_Dat('C');}}else{LCD1602_Set_Cursor(0,0);LCD1602_Show_Str(" clock: ");LCD1602_Set_Cursor(0,1);LCD1602_Show_Str(" ");if(state==7&&s0){LCD1602_Show_Str(" ");}else{LCD1602_Write_Dat('0'+nolock1[0]/10%10);LCD1602_Write_Dat('0'+nolock1[0]%10); //鬧鐘-時}LCD1602_Show_Str(":");if(state==8&&s0){LCD1602_Show_Str(" ");}else{LCD1602_Write_Dat('0'+nolock1[1]/10%10);LCD1602_Write_Dat('0'+nolock1[1]%10); //鬧鐘-分}LCD1602_Show_Str(" ");if(state==9&&s0){LCD1602_Show_Str(" ");}else{if(flag2 == 0) LCD1602_Show_Str(" on");else if(flag2 == 1) LCD1602_Show_Str("off");}LCD1602_Show_Str(" ");} }void key_scan() //系統按鍵控制程序 {if(key1==0){if(key1_flag){key1_flag=0;state=(state+1)%10;}}else{key1_flag=1;}if(!key2) //手動上轉動控制{if(key2_flag){key2_flag=0;if(state>0&&state<7){if(state==1){TIME.year=(TIME.year+1)%100;}else if(state==2){TIME.month=TIME.month%12+1;if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){if(TIME.date>29)TIME.date=29;}else{if(TIME.date>28) TIME.date=28;}}else if(TIME.month==4||TIME.month==6||TIME.month==9||TIME.month==11){if(TIME.date>30) TIME.date=30;}}else if(state==3){if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){TIME.date=TIME.date%29+1;}else{TIME.date=TIME.date%28+1;}}else if(TIME.month==1||TIME.month==3||TIME.month==5||TIME.month==7||TIME.month==8||TIME.month==10||TIME.month==12){TIME.date=TIME.date%31+1;}else {TIME.date=TIME.date%30+1;}}else if(state==4){TIME.hour=(TIME.hour+1)%24;}else if(state==5){TIME.minute=(TIME.minute+1)%60;}else if(state==6){TIME.second=(TIME.second+1)%60;}}else if(state!=0){if(state==7){nolock1[0]=(nolock1[0]+1)%24;}else if(state==8){nolock1[1]=(nolock1[1]+1)%60;}else if(state==9){flag2=0;}}}if(sec1==0) //判斷是否長按,如果長按,實現連加效果{if(state!=0&&state<7) //設置萬年歷{if(state==1){TIME.year=(TIME.year+1)%100;}else if(state==2){TIME.month=TIME.month%12+1;if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){if(TIME.date>29)TIME.date=29;}else{if(TIME.date>28) TIME.date=28;}}else if(TIME.month==4||TIME.month==6||TIME.month==9||TIME.month==11){if(TIME.date>30) TIME.date=30;}}else if(state==3){if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){TIME.date=TIME.date%29+1;}else{TIME.date=TIME.date%28+1;}}else if(TIME.month==1||TIME.month==3||TIME.month==5||TIME.month==7||TIME.month==8||TIME.month==10||TIME.month==12){TIME.date=TIME.date%31+1;}else {TIME.date=TIME.date%30+1;}}else if(state==4){TIME.hour=(TIME.hour+1)%24;}else if(state==5){TIME.minute=(TIME.minute+1)%60;}else if(state==6){TIME.second=(TIME.second+1)%60;}}else if(state!=0){if(state==7){nolock1[0]=(nolock1[0]+1)%24;}else if(state==8){nolock1[1]=(nolock1[1]+1)%60;}else if(state==9){flag2=0;}}} }else {sec1=2;if(key2_flag==0){memory_flag=1;key2_flag=1;}}if(!key3) //手動下轉動控制監測{if(key3_flag){key3_flag=0;if(state!=0&&state<7){if(state==1){TIME.year--;if(TIME.year>120) TIME.year=99; }else if(state==2){TIME.month--;if(TIME.month==0) TIME.month=12; if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){if(TIME.date>29)TIME.date=29;}else{if(TIME.date>28) TIME.date=28;}}else if(TIME.month==4||TIME.month==6||TIME.month==9||TIME.month==11){if(TIME.date>30) TIME.date=30;}}else if(state==3){TIME.date--;if(TIME.date==0){if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){TIME.date=29;}else{TIME.date=28;}}else if(TIME.month==1||TIME.month==3||TIME.month==5||TIME.month==7||TIME.month==8||TIME.month==10||TIME.month==12){TIME.date=31;}else {TIME.date=30;}} }else if(state==4){TIME.hour--;if(TIME.hour>25) TIME.hour=23;}else if(state==5){TIME.minute--;if(TIME.minute>60) TIME.minute=59;}else if(state==6){TIME.second--;if(TIME.second>60) TIME.second=59;}}else if(state!=0){if(state==7){nolock1[0]--;if(nolock1[0]>25) nolock1[0]=23;}else if(state==8){nolock1[1]--;if(nolock1[1]>60) nolock1[1]=59;}else if(state==9){flag2=1;}}}if(sec2==0) //判斷是否長按,如果長按,實現連減效果{if(state!=0&&state<7){if(state==1){TIME.year--;if(TIME.year>120) TIME.year=99; }else if(state==2){TIME.month--;if(TIME.month==0) TIME.month=12; if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){if(TIME.date>29)TIME.date=29;}else{if(TIME.date>28) TIME.date=28;}}else if(TIME.month==4||TIME.month==6||TIME.month==9||TIME.month==11){if(TIME.date>30) TIME.date=30;}}else if(state==3){TIME.date--;if(TIME.date==0){if(TIME.month==2){if((TIME.year%4==0&&TIME.year%100!=0)||TIME.year==0){TIME.date=29;}else{TIME.date=28;}}else if(TIME.month==1||TIME.month==3||TIME.month==5||TIME.month==7||TIME.month==8||TIME.month==10||TIME.month==12){TIME.date=31;}else {TIME.date=30;}} }else if(state==4){TIME.hour--;if(TIME.hour>25) TIME.hour=23;}else if(state==5){TIME.minute--;if(TIME.minute>60) TIME.minute=59;}else if(state==6){TIME.second--;if(TIME.second>60) TIME.second=59;}}else if(state!=0){if(state==7){nolock1[0]--;if(nolock1[0]>25) nolock1[0]=23;}else if(state==8){nolock1[1]--;if(nolock1[1]>60) nolock1[1]=59;}else if(state==9){flag2=1;}}}}else //否則上下轉動標志位清0{if(key3_flag==0){memory_flag=1;key3_flag=1;}sec2=2;}if(key4==0){if(key4_flag){key4_flag=0;state=0;}}else {key4_flag=1;} }void clock_dispose() {if(state==0&&flag2==0&&nolock1[0]==TIME.hour&&nolock1[1] == TIME.minute) {if(TIME.second==0) beep1=1;}else {beep1=0;} }int main(void) { delay_init();BEEP_Init();delay_ms(20); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //設置NVIC中斷分組2:2位搶占優先級,2位響應優先級LCD1602_Init();KEY_Init();ds1302_gpio_init();do{temperature=DS18B20_Get_Temp();}while(temperature == 850);TIM3_Int_Init(4999, 7199);TIM4_Int_Init(499 ,7199);read_memory();while(1) { if(read_flag){read_flag=0;temperature=DS18B20_Get_Temp(); //獲取溫度 返回的是一個三位數short型的整數}read_time1();clock_dispose();dis_play();if(memory_flag){memory_flag=0;memory();}} }void TIM4_IRQHandler(void) //TIM4中斷 {if (TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET) //檢查TIM2更新中斷發生與否{if(beep1){if(key1==0||key2==0||key3==0||key4==0){beep1=0;}}else{key_scan();}ms++;if(ms%5==0) {if(beep1){BEEP=~BEEP;}else{BEEP=0;}s0=~s0; }if(ms%10==0){if(sec1!=0) sec1--;if(sec2!=0) sec2--;}if(ms>=20){ms=0;read_flag=1;}}TIM_ClearITPendingBit(TIM4, TIM_IT_Update ); }

4 最后

🧿 項目分享:

https://gitee.com/sinonfin/sharing

總結

以上是生活随笔為你收集整理的毕业分享 STM32智能桌面天气预报时钟系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。