家庭语音健康助手程序代码_第1页
家庭语音健康助手程序代码_第2页
家庭语音健康助手程序代码_第3页
家庭语音健康助手程序代码_第4页
家庭语音健康助手程序代码_第5页
已阅读5页,还剩191页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

上位机主程序#include"thread.h"#include"qtextedit.h"#include"qdatetime.h"#include"qtimer.h"#include"qpushbutton.h"#include<QDebug>#include<QDesktopWidget>#include<QScreen>#include<QMessageBox>#include<QMetaEnum>#include"qcustomplot.h"#include"qstring.h"#include"source.cpp"#include"qwidget.h"#include"qframe.h"#include"qlcdnumber.h"#include"qlineedit.h"#include"qpixmap.h"#include"qslider.h"#include#include"qwidget.h"#include#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<termios.h>#defineRS_DEVICE"/dev/ttySAC3"#include"qmovie.h"size_tone=QStringtemp_h,temp_m,hh,m;QStringMytime;QTimeCT=QTime::currentTime();QStringhour,min,sec;QString*btnadd=newQString; usedforanimotionhandler QTimer*time_environment=newQTimer;QTimer*time_health=newQTimer;QTimer*time_setup=newQStringtemp_lb,hu_lb,hcho_lb,pm25_lb,pm10_lb,pm1_lb;QStringsettime,Qhour,Qmin;ui(newUi::MainWindow){yy=newThread();kk=newthread2();kk->ss=1;yy-yy- QTimer*timenew QTimer*biubiubiu=newQTimer(this); ui->widget_voice_selections_2->setVisible(0)语音播报另一部分先设置不可见 //homebutton connectindex1 connectindex2 connectindex3 /*****************设置界面(时间、语音、信息)**************/ 测血压、心率、体 链接按 // 语音设置界面 作品信息和简介之间跳 QTimer*gif=newQTimer(this); } 温度计的动画*************************/voidMainWindow::gif_start(){ QMovie*movie=new QMovie*heartB=newQMovie("/mnt/disk/8- } voidMainWindow::timeThread(){Mytime=local.toString("hh:mm:ss");kk->ss= 把QString转换成数字 temp_lb=QString::number(yy->te,10);hu_lb=QString::number(yy->hu,10);hcho_lb=QString::number(yy->hcho,'f',2);pm25_lb=QString::number(yy->pm25,10);pm1_lb=QString::number(yy->pm1,10);pm10_lb=QString::number(yy->pm10,10);= ////环境检测缩略图 } //显示评估标 时间函void{QPixmap//pm2.5{}elseif(pm25_lb.toInt()>35&&{}else &&{{{}else{}{{}else{}//煤气弹if(yy->gas=={}if(yy->bp_status=={();//} {case'D': a=1;case'C': a=0;case'E': //'E'GSMcase'F': //'F'GSMcase'A': b=1;case'B': case case //'I'PM2.5case case case case case'G': case'O': case'P': case'Q': case'R': case'S': case'T': case'U': case'V': case }} QStringblH,blLvoid{blL=QString::number(yy->final_blood_l,10); }voidMainWindow::hide_finalbloodP{ }/************************关闭煤气泄漏弹窗*********************************/voidMainWindow::stopGasAlarm(){);//d=}void {yy->hour=}void {yy->min=}void //{//判断是否退压测量,显示中止测量//1{ {} {}} 主页3个按 点击之后stackedLabel跳转到相应的pagevoidMainWindow::index1_environment() {}void {}void //{} index2环境信息缩略 void{}void{}void{}void{}void{}void{} {QPixmappmap;{casecase2:case3:case4:case5:case6:}} 环境信息的实时波形图页面 void{}void{}void{}void{}voidvoidvoidMainWindow::index3_handle(inti) //调用函数(index3的)label的颜色以及更新{ QPixmappmap; //定义一个pixmap{caseyy->datatype=1; //setdatatype(toshowintemplabel)pmap.load("/mnt/disk/stackedlabel01.png");caseyy->datatype=2; //setdatatype(toshowintemplabel)pmap.load("/mnt/disk/stackedlabel02.gif");caseyy->datatype=3; //setdatatype(toshowintemplabel)pmap.load("/mnt/disk/stackedlabel03.png");caseyy->datatype=4; //setdatatype(toshowintemplabel)pmap.load("/mnt/disk/stackedlabel04.gif");caseyy->datatype=5; //setdatatype(toshowintemplabel)pmap.load("/mnt/disk/stackedlabel05.gif");caseyy->datatype=6; //setdatatype(toshowintemplabel)pmap.load("/mnt/disk/stackedlabel06.gif");}}void {QPixmap} voidMainWindow::index6_setTime() {QDateTimelocal(QDateTime::currentDateTime()); }void {}void {}voidMainWindow::setTime_confirm() {settime="date-s"+hour+":"+min; } index4(测体温、血压、心率界面按钮的函数void { //home }void{}void{= // //home}//void void{}void {= // //home}void { //home}void //中止测量血压{ //0,表示停止血压测量//移除 //home键,3钮}void { //home} 语音设置界面*************************/voidMainWindow::button_speechRecognition_slot()voidvoidvoidvoidvoidvoid{}void{}void{}void{}void{} //语音设置调用函数{QPixmapvoice_pixmap;{case1: {}{}a=!a;case2: {}}b=case //GSM{}{}c=case4: {}{}d=case //pm2.5{}{}e=case {}{}f=case7: {}{}g=case8: {}{}h=case9: {}{}ii=case10: {}{}j=case11: {}{}k=}}boolsss=void{{{}sss=}void{{}{}}void{{}{}}{delete}#include"thread.h"#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<termios.h>#include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<strings.h>#include<qstring.h>//#defineRS_DEVICE"/dev/ttySAC3"#defineRS_DEVICE"/dev/usbdev1.4"QStringQStringspm25,ste,shcho,shu,spm1,spm10,sblp,sbodytemp,shb,sgas,sstatus,sbH,sbL,ssignal;//stringformatintvoid //jinruxiancheng{ //makesuretheserialportcanwork{}set_opt(fd,115200,8,'N',{ //timedriven{{arr[u]=}str=ste //shu shcho=str.section(',',11,11); //PPMspm25=str.section(',',8,8); spm1=str.section(',',7,7); spm10= sblp=str.section(',',13,13); sbodytemp=str.section(',',3,3); shb sgas sstatusstr.section(',',12,12)血压测量状态sbH=str.section(',',14,14);sbL==te=ste.toInt();hu=shu.toInt();hcho=shcho.toFloat();pm25=spm25.toInt();pm1=spm1.toInt();pm10=spm10.toInt();blP=sblp.toInt();hb=shb.toInt();gas=sgas.toInt();bodytemp=sbodytemp.toFloat();bp_status=sstatus.toInt();final_blood_h=sbH.toInt();final_blood_l=sbL.toInt(); =ba.data(); }} }intset_opt(intfd,intnSpeed,intnBits,charnEvent,int{structtermios (tcgetattr(fd,&oldtio) 0){perror("SetupSerial1");}bzero(&newtio,sizeof(newtio)); CLOCAL|CREAD;newtio.c_cflag&=~CSIZE;switch(nBits{casenewtio.c_cflag|=CS7;casenewtio.c_cflag|=CS8;}{casenewtio.c_cflag|=PARENB;newtio.c_iflag|=(IK|ISTRIP);casenewtio.c_iflag|=(IK|ISTRIP);newtio.c_cflag|=PARENB;newtio.c_cflag&=~PARODD;casenewtio.c_cflag&=~PARENB;}switch(nSpeed{casecfsetispeed(&newtio,B2400);casecfsetispeed(&newtio,B4800);casecfsetispeed(&newtio,B9600);casecfsetispeed(&newtio,B115200);casecfsetispeed(&newtio,B460800);cfsetispeed(&newtio,B9600);}if(nStop==1newtio.c_cflag&= elseif(nStop==2)newtio.c_cflag|= =0;newtio.c_cc[VMIN]=0;{perror("comseterror");return-1;}return}label#includemylabel::mylabel(QWidget*parent):{}{emitthis->clicked();}{}{#ifQT_VERSION<QT_VERSION_CHECK(4,7,QMessageBox::critical(this,"","You'reusingQt<4.7,therealtimedatademoneedsfunctionsthatareavailablewithQt4.7toworkproperly");customPlot->addGraph();//bluecustomPlot->addGraph();//blue//makeleftandbottomaxestransfertheirrangestorightandtop //setupatimerthatrepeatedlycallsconnect(&dataTimer,SIGNAL(timeout()),this,SLOT(realtimeDataSlot())); //drawlinedataTimer.start(50);//Interval0meanstorefreshasfastaspossibleconnect(&xdataTimer,SIGNAL(timeout()),this,SLOT(xtimeDataSlot())); xdataTimer.start(300);//Interval0meanstorefreshasfastaspossible}doublevaluevoid{//calculatetwonewdata#ifQT_VERSION<QT_VERSION_CHECK(4,7,doublekey=0; QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;//toMSecsSinceEpochReturnsthe//asthenumberofmillisecondsthathavdpassedsince1970-01-01,CoordinatedUniversalstaticdoublelastPointKey=//usedforupdatingif(key-lastPointKey>0.01)//atmostaddpointevery10{//adddatato //setdataof //removedataoflinesthat'soutsidevisible //rescalevalue(vertical)axistofitthecurrent lastPointKey=key;}//makekeyaxisrangescrollwiththedata(ataconstantrangesizeof{casevalueyy->tecasevalueyy- casevalue=yy->hcho;if(value<0.2){}elseif(value>0.2&&value{}case4:value= {}elseif(value>100&&value<200{}}case5:value=yy->pm1; {}elseif(value>100&&value<200{}}case6:value=yy->pm10; {}elseif(value>100&&value<200{}}case7:valueyy- //casevalueyy- case value=yy- }}//usedforupdatingimformationfordotsandlineper voidMainWindow::xtimeDataSlot(){#ifQT_VERSION<QT_VERSION_CHECK(4,7,doublekey=0; QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;//toMSecsSinceEpochReturnsthe//asthenumberofmillisecondsthathavdpassedsince1970-01-01,Coordinated{casevalueyy->te;case2:value=yy->hu; casevalue=yy->hcho;casevalue= casevalue=yy->pm1;casevalue=yy->pm10;casevalue=yy->blP;casevalue=yy->hb;casevalue=yy->bodytemp;}staticdoublelastPointKey=if(key-lastPointKey>0.01)//atmostaddpointevery10{}}{switch{}setWindowTitle("QCustomPlot:"+demoName); } {}void{#ifQT_VERSION<QT_VERSION_CHECK(5,0,QPixmappm=QPixmap::grabWindow(qApp->desktop()->winId(),this->x()+2,this->y()+2,this->frameGeometry().width()-4,this->frameGeometry().height()-4);QPixmappm=qApp->primaryScreen()->grabWindow(qApp->desktop()->winId(),this->x()+2,this->y()+2,this->frameGeometry().width()-4,this->frameGeometry().height()-4);QStringfileName=fileName.rece("",}void{#ifQT_VERSION<QT_VERSION_CHECK(5,0,QPixmappm=QPixmap::grabWindow(qApp->desktop()->winId(),this->x()+2,this->y()+2,this->frameGeometry().width()-4,this->frameGeometry().height()-4);QPixmappm=qApp->primaryScreen()->grabWindow(qApp->desktop()->winId(),this->x()+2,this->y()+2,this->frameGeometry().width()-4,this->frameGeometry().height()-4);QStringfileName=demoName.toLower()+".png";fileName.rece("","");if(currentDemoIndex<{if(dataTimer.isActive())deleteui->customPlot; vertical //setupdelayfordemosthatneedtimetodevelopproperlook:intdelay=250;if(currentDemoIndex==10)//NextisRealtimedatademodelay=12000;elseif(currentDemoIndex==15)//NextisItemdemodelay=5000;}{}}void{#ifQT_VERSION<QT_VERSION_CHECK(4,7,doublesecs=0;doublesecs=QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;//updatedatatomakephasemove:intn=500;doublephase=secs*5;doublek=3;QVector<double>x(n),y(n);for(inti=0;i<n;++i){x[i]=i/(double)(n-1)*34-y[i]=qExp(-}//calculateframesper doublekey= staticdouble staticint if(key-lastFpsKey>2)//averagefpsover2 QString("%1FPS,TotalDatapoints: , lastFpsKey= frameCount= }程程 main.cpp:#include<QApplication>#include"qtextcodec.h"intmain(intargc,char{QApplicationa(argc,argv);MainWindoww;returna.exec();}#ifndefMAINWINDOW_H#defineMAINWINDOW_H#include<QtGui>#include#include<QTextEdit>#include<QDateTime>#include<QTime>#include<QMainWindow>#include#include#include<QMouseEvent>#include"qstring.h"#include"thread2.h"#includenamespaceUiclass}classMainWindow:public{// explicitMainWindow(QWidget*parent=voidsetupDemo(intvoidsetupSimpleDemo(QCustomPlot*customPlot);voidsetupSincScatterDemo(QCustomPlot*customPlot);voidsetupLineStyleDemo(QCustomPlot*customPlot);voidsetupMultiAxisDemo(QCustomPlot*customPlot);voidsetupLogarithmicDemo(QCustomPlot*customPlot);voidsetupRealtimeDataDemo(QCustomPlot*customPlot);voidsetupBarChartDemo(QCustomPlot*customPlot);voidsetupStatisticalDemo(QCustomPlot*customPlot);voidsetupSimpleItemDemo(QCustomPlot*customPlot);voidsetupItemDemo(QCustomPlot*customPlot);voidsetupAdvancedAxesDemo(QCustomPlot*customPlot);voidsetupColorMapDemo(QCustomPlot*customPlot);voidsetupFinancialDemo(QCustomPlot*customPlot);voidsetupyground(QCustomPlot*customPlot); 自定义供调用的函数*****************************/voidindex2_handle(inti); //customedfunctionvoidindex3_handle(inti);voidindex3_labelInit();voidvoice_CallFuntion(inti); voidshowFinalBloodPressure();bool publicvoidvoidvoidrealtimeDataSlot();voidxtimeDataSlot();voidbracketDataSlot();voidscreenShot();voidallScreenShots();voidHourSlot();voidvoid // labeltobuttonslots voidhomeButtonEvent();//leftcorner.homebuttonvoidindex1_health();void index2:blankbuttons voidindex2_temp();voidindex2_humidy();voidindex2_hcho();voidindex2_pm10();voidindex2_pm2();voidindex2_pm1(); index3:leftsidelabels voidindex3_temp();voidindex3_humidy();voidindex3_hcho();voidindex3_pm10();voidindex3_pm2();voidindex3_pm1(); index6:系统设置 voidindex6_setTime();voidvoidsetTime_confirm();/****************slots*******************/voidbloodSlot();voidheartRateSlot();voidyes();voidvoidbutton_StopTest_no_slot();voidgif_start();voidpressHeart(); void 语音设置界面,7slots************************/voidbutton_speechRecognition_slot();voidvoidbutton_pm2_slot();voidbutton_gas_slot();voidbutton_TH_slot();voidbutton_wifi_slot();voidbutton_bp_slot();voidbutton_bo2_slot();voidnext();void 跳转*****************************/voidProfileAndInfo();voidthread2*kk;Thread*yy;Ui::MainWindow*ui;QStringdemoName;QTimerdataTimer;QTimerxdataTimer;intcurrentDemoIndex;charprotected //#ifndefTHREAD_H#define#includeclassThread:public{public{}charbuf[100];volatileboolstopped;volatileboolwrite_rs;volatileboolread_rs;volatileintpm25;volatileintte;volatilefloathcho;volatileinthu;volatileintpm1;volatileintpm10;volatileintblP;volatileinthb;volatileintvolatileintbloodpressure;volatileintgas;volatileintindex;volatileintdatatype;volatileintbp_status; volatileintfinal_blood_h; //Final血压volatileintvolatilechar* volatileinthour;volatileintmin;intvirtualvoid#endif//Main.c//数据 //11333255133#include#include"lcd.h"#include"stdio.h"#include"dht11.h"#include"SysTick.h"#include"uart1.h"#include"uart2.h"#include"uart3.h"#include"led.h"#include"timer2.h"#include"exti.h"#include"uart4.h"#include"uart5.h"#include"i2c.h"#include//0代表关闭功 1代表能 0 0 1//1//PM2.5//PM10//PM25//PM1//PPM比较的变//Mg比较的变//0//2//1//2//4//5 //21 //打印数据缓冲区//PM2.5//5//wifi//2//2//串口2接收计数变 //PM2.5测量结果数 = //PM2.5//WIFI//WIFI//WIFI//温湿度完成标//WIFI5S PM25_Bobao_Flag=0; //语音播报PM2.5标志 Jiaquan_Bobao_Flag=0; //GSM煤气标志 WIFI_Bobao_Flag//WIFI//PM//PM//WIFI//GMS//PM//WIFI//WIFI//PM25//播报数值标float //数据结果缓uint8_t //DHT11externvoidSysTick_Init(void); externvoidDHT11Read(uint8_t*Data_Array); externvoidDelay_us(IOuint32_tnTime int{ //APPESP8266_Init(); //wifiAPPESP8266_UnvarnishSend();#if、、面的那个大白一样,竭诚为您服务,我是由队伍编号为12902的浩创、、{{{USART1_SendString((int8_t*)Printf_PM_buf);USART1_SendString((int8_t*)Printf_PM_buf);sprintf((char*)Printf_PM_buf,"PM10的浓度是%d\r\n",PM_Datastr[2]);USART1_SendString((int8_t*)Printf_PM_buf);}}{} //{

sprintf((char*)Printf_Jiaquan_buf,"mg%05.2f毫克每立方sprintf((char*)Printf_Jiaquan_buf,"ppm%05.2f\r\n",Jiaquan_data_2);USART1_SendString((int8_t*)Printf_Jiaquan_buf);}{sprintf((char*)Printf_Wenshidu_buf,"湿度=%d.%d%%RH\t温度=%d.%d℃\t校验和} //从机数据{{{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}else{}#ifDebug_congji_shuju_printf_usart1USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);USART1_SendString((int8_t*)USART2_Printf_USART1_TXBUF);{}}}{}#ifEXTI_Times_DebugAPP{USART1_SendString((int8_t*)Printf_EXTI_Times_Buf);USART1_SendString((int8_t*)Printf_EXTI_Times_Buf);USART1_SendString((int8_t*)Printf_EXTI_Times_Buf);USART1_SendString((int8_t*)Printf_EXTI_Times_Buf);USART1_SendString((int8_t*)Printf_EXTI_Times_Buf);USART1_SendString((int8_t*)Printf_EXTI_Times_Buf);Exti0_Times_Count=0;} //从机解除GSM发送煤气APP}{}{}{{}} {{{}}{{}}{{}}{{}}{{}}{{}}{{}}{{XFS_FrameInfo("好的,主人,PM2.5播报功能已经关闭了");}}{{}}{{}}{{}}{{}}if(WIFI_Bobao_Flag==1)//WIFI命令语音提示{{}}{{}}{{}}else //从机解除GSM发送煤气{}}{{}}{{}}{{}}{{}}{{}}{{}}{{ }} {{ }}{{XFS_FrameInfo("sound313我们家的煤气泄漏了");USART1_SendString((int8_t*)"我们家的煤气泄漏了\r\n");}{{{}else{}else{}{case{}case{}case{}}}}{{{}else{}else{}{case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf主人,你的血氧含量为百分之%d,偏低了}case{}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf主人,你的血氧含量为百分之%d,偏高了}}}}{{{}else{}else{}else{}else{}else{}{case{}case{}case{}case{}case{}case{}}}}{{{} {} {}else{}{case{{}}case{}case{}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的含量了,目前含量}}}}{{{}else{}else{}{}else{}else{}{}{}{}{}{}{}{}{}{}{case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度偏低,}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度偏低,相对湿度为百分之%d4060之间}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度偏低,}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度适宜,适宜的温度范围在19到24摄氏度之间,相对湿度为百分之%d,相对湿度偏低}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度适宜,1924摄氏度之间,相对湿度为百分之%d4060之间",Wendu_temp,Shidu_temp);USART1_SendString((int8_t*)Jiaquan_Yuyinhecheng_Buf);}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度适宜,适宜的温度范围在19到24摄氏度之间,相对湿度为百分之%d,相对湿度偏高}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度偏高,}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度偏高,相对湿度为百分之%d4060之间}case{sprintf((char*)Jiaquan_Yuyinhecheng_Buf,"主人,我们家的温度为%d摄氏度,温度偏高,}}}}} if(WiFi_Kongzhi_Flag==1)//Wifi数据传输功能APP,连接安卓APP正式 if(Wifi_Send_Flag==1)//WIFI发送数据到{ilP6_SentigBLc*ii_,ieii_f6))//单连接模式,透传模式{}{}macESP8266_Usart("%s",wifi_buf}{{strEsp8266_Fram_Record.InfBit.FramFinishFlag=0;USART1_SendString((int8_t*)"\r\n");}} else }}} if(ESP8266_SendString( }else{}Stm32f10x_it.c/* #include"stm32f10x_it.h"#include"uart2.h"#include#include<stdio.h>#include"SysTick.h"#include"uart3.h"#include"uart2.h"#include"uart1.h"#include"led.h"#include"dht11.h"00//0//2//1//2//4//5//30Ms//30S//15S//2//PM2.5//PM2.5测量结果数//2//PM2.5//WIFI//WIFI//5//WIFI5S//烟雾标志//烟雾标志//烟雾标////PM2.5//GSMexternu8 //关闭标externu8Wenshidu_Bobao_Flag; externu8Xinlu_Bobao_Flag; externu8XueYa_Bobao_Flag; //血压播报标志 //WIFI播报标//GMS//PM//WIFI //WIFIexternfloat externuint8_t externuint8_t externuint8_t voiddelay_ms_soft(u16time); voidTimingDelay_Decrement(void); /**@addtogroup*/**@addtogroup*/*Private /*Private /*Private /*Private /*Privatefunction /*Private / Cortex-M3ProcessorExceptions / ThisfunctionhandlesNMI void{} ThisfunctionhandlesHardFault void{/*GotoinfiniteloopwhenHardFaultexceptionoccurs*/while(1){}} ThisfunctionhandlesMemoryManage void{/*GotoinfiniteloopwhenMemoryManageexceptionoccurs*/while(1){}} ThisfunctionhandlesBusFault void{/*GotoinfiniteloopwhenBusFaultexceptionoccurs*/while(1){}} ThisfunctionhandlesUsageFault void{/*GotoinfiniteloopwhenUsageFaultexceptionoccurs*/while(1){}} ThisfunctionhandlesSVCall void{} ThisfunctionhandlesDebugMonitor void{} ThisfunctionhandlesPendSVC void{} ThisfunctionhandlesSysTick void{}/ // AddheretheInterruptHandlerfortheusedperipheral(s)(PPP),for availableperipheralinterrupthandler'snamepleaserefertothestartup file / ThisfunctionhandlesPPPinterrupt void{{#ifEXTI_Times_Debug if(_1s==1){}if(_1s=={}elseif(_1s=={}elseif(_1s=={}elseif(_1s=={}if(Ms_30=={}{Check_Yuyinhecheng_15S=0;}if(Check_Exti_30S=={}}}void{{#ifEXTI_Times_Debug {}{}}}void{uint8_ttemp;uint8_tj;uint16_tSum=0;uint8_tSum_H;uint8_tSum_L;staticuint8_ti=0;staticuint8_tstr[40];{#ifEXTI_Times_Debug temp=USART_ReceiveData(USART1);str[i]=temp;if((str[0]!=0x42)&&(i=={i=}{if(i!={if((str[1]!=0x4D)&&(i=={i=}{if(i{i=for(j=0;j<{}Sum_H=(uint8_t)(Sum>>8);Sum_L=(uint8_t)Sum;if((Sum_H==str[30])&&(Sum_L=={for(j={}PM_Datastr[0]=str[10]*256+str[11];PM_Datastr[1]=str[12]*256+str[13];PM_Datastr[2]=str[14]*256+}}}}}}}//void uint8_t staticuint8_ti= #if temp= if(i>= if(USART2_Data_RX_BUF[i-1]!= if(i>={i=}USART2_Ready=}{}i=}}}void{uint8_ttemp;uint8_tj; uint8_ti={#ifEXTI_Times_Debug temp={if(i>={i=0;for(j=1;j{{for(j={}USART2_Ready=0;}USART2_Ready= }}}}}void{uint8_tfloatstaticuint8_ti=0;staticuint8_tbuffer[10];{#ifEXTI_Times_Debug buffer[i]=temp;if(buffer[i]=={if(i>={data_1_buf=(float)(256*buffer[4]+data_2_buf=(float)(256*buffer[6]+{}{}i=}}{}}}void{uint8_t)!={#ifEXTI_Times_Debug temp=#ifShangweiji_Debug_switch//上位机调试开关if(temp=='0'){}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}elseif(temp=={}}}voidmacESP8266_USART_INT_FUN(void{uint8_t{ =USART_ReceiveData(macESP8266_USARTx); if(strEsp8266_Fram_Record.InfBit.FramLength<(RX_BUF_MAX_LEN-1)) 1个字节写结束符++ =}ifUSART_GetITStatusmacESP8266_USARTxUSART_IT_IDLESET{ucChUSART_ReceiveData(macESP8266_USARTx由软件序列清除中断标志位(先USART_SRUSART_DR)= strEsp8266_Fram_Record.InfBit.FramFinishFlag=1; }} ThisfunctionhandlesPPPinterrupt /*void{ ThisfunctionhandlesPPPinterrupt /*void{/*******************(C)COPYRIGHT2011STMicroelectronics*****ENDOFi2c.c#include"stm32f10x.h"#include"i2c.h"#include"stdio.h"#include"string.h"/**I2C总线接口*/#defineI2C_PORTGPIOB#defineSDA_Pin #defineSCL_PinGPIO_Pin_6#defineSUCCESS//SDAvoid{GPIO_InitTypeDefGPIO_InitStructure;GPIO_InitStructure.GPIO_Pin=SDA_Pin;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPD;GPIO_Init(I2C_PORT,&GPIO_InitStructure);}//SDAvoid{GPIO_InitTypeDefGPIO_InitStructure;GPIO_InitStructure.GPIO_Pin=SDA_Pin;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_Init(I2C_PORT,&GPIO_InitStructure);}voidSDA_Output(uint16_tval{if(val{}{}}voidSCL_Output(uint16_tval{if(val{}{}}uint8_t{}//voiddelay1(unsignedint{unsignedinti;for(i=0;i<n;++i);}//I2Cvoid{}//I2Cvoid{SCL_Output(0);delay1(500);SCL_Output(1);delay1(500);}//unsignedchar{unsignedshortcErrTime=5;{if(0=={return}}returnSUCCESS;}//void{SCL_Output(1);delay1(500);}void{SCL_Output(1);delay1(500);}//I2CvoidI2CSendByte(unsignedchar{unsignedchar i=8;while(i--){SDA_Output(cSendByte&0x80);delay1(500);cSendByte+=cSendByte;}}//I2Cunsignedchar{unsignedchari=unsignedcharcR_Byte=0;while(i--{cR_Byte+=cR_Byte;cR_Byte|= }return}//I2Cvoid{GPIO_InitStructure.GPIO_Pin=SDA_Pin|SCL_Pin;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_Init(I2C_PORT,&GPIO_InitStructure);} {uint8_t{}} 称:YS-XFS5051文本合成函 能:发送合成文本到XFS5051进行合成参数:*HZdata: SN_FameInovoidXFS_FrameInfo(uint8_t*HZdata){ HZ_Lengthstrlen((constchar Frame_Info[0]=0xFD; //构造帧头FDFrame_Info[1]=0x00; Frame_Info[2]=HZ_Length+2; Frame_Info[3]=0x01; Frame_Info[4 memcpy(&Frame_Info[5],HZdata,HZ_Length););//} uint8_t{uint8_tack=0;ack=I2CWaitAck();return}exti.c#include#includevoid{ RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;GPIO_Init(GPIOB,&GPIO_InitStructure);EXTI_InitStructure.EXTI_LineCmd=ENABLE;NVIC_InitStructure.NVIC_IRQChannel=EXTI0_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;}timer2.c#include"stm32f10x.h"#include"timer2.h"staticvoid{NVIC_InitTypeDefNVIC_InitStructure;NVIC_InitStructure.NVIC_IRQChannelSubPriority=3;NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;}void //1s{ TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure);}common.c#include"common.h"#include"stm32f10x.h"#include<stdarg.h>staticchar itoa(intvalue,char*string,intradixCprintfC输入:-USARTx2- 输出返回调用USART2_printfUSART2r\nthisisademor\nUSART2_printf(USART2,"\r\n%d\r\n",iUSART2_printf(USART2,"\r\n%s\r\n",jvoidUSART_printf(USART_TypeDef*USARTx,char*Data,...{constchar*s;intd;charva_listap;va_start(ap,Data);while*Data0 //{if(*Data==0x5c {switch(*++Data{case Data++;case Data++;Data++;}}elseif(*Data== switch(*++Data{case //s=va_arg(ap,constcharfor(;*s;{}case//d=for(s=buf;*s;{}}}while(USART_GetFlagStatus(USARTx,USART_FLAG_TXE)==RESET}}描述输入:-radix1010-value-buf-radix=输出返回调用:被USART2_printf()staticchar*itoa(intvalue,char*string,intradix{ i, flag= *ptr=/*Thisimplementationonlyworksfordecimalnumbers.*/if(radix!=10){*ptr=return}if{*ptr++=*ptr=return}/*ifthisisanegativevalueinserttheminussign.*/if(value<0){*ptr++='-/*Makethevaluepositive.value*=-}for(i=10000;i>0;i/={d=value/if(d||{*ptr++=(char)(d+0x30);value-=(d*i);flag=}}/*Nullterminatethestring.*ptr=return}/*NCL_Itoaled.c#includevoid{GPIO_InitTypeDefGPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_10MHz;GPIO_Init(GPIOD,&GPIO_InitStructure);}{if(LED_Status=={}{}}led.c#includestaticIOuint32_t*描述:输入输出://tick/ 1ms/ 10us/ 1usvoidSysTick_Init(void{ {}->}*函数名:voidDelay_us(IOuint32_tnTime描述:输入输出:voidDelay_us(IOuint32_tnTime{SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk开启系统滴答时钟}描述:输入输出:void{{}}{u16{}}dht11.c#includevoid{ sprintf((char*)str,"实验室湿度 温度=%d.%d℃ 校验 }staticvoid描述:IO输入输出:staticvoid{}staticvoid描述:IO输入输出:staticvoid{}函数名:staticvoid描述://输入输出:staticvoid{}描述:8输入输出:static {u8{while(Bit_RESETRead);//等待变为高电平{} //30us{temp=temp|0x01;}return}描述:输入输出:void{();//{while(Bit_RESET==Read);//低电平响应信号while(Bit_SETRead);//80us高电平准备信号RH_temp=Byte_Receive();//8位//{}}}uart1.c#include"uart1.h"#include"string.h"#include"stdio.h"staticvoid{NVIC_InitTypeDefNVIC_InitStructure;NVIC_InitStructure.NVIC_IRQChannel=USART1_IRQn;NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;}void{ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);//USART1TXGPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIOA,&GPIO_InitStructure);//USART1RXGPIO_Init(GPIOA,&GPIO_InitStructure);//1USART_InitStructure.USART_StopBits=USART_StopBits_1;USART_InitStructure.USART_Parity=USART_Parity_No;USART_InitStructure.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;USART_Init(USART1,&USART_InitStructure);USART_Cmd(USART1,ENABLE);}{uint8_tindex=0;{}}uart2.c#include"uart1.h"#include"uart2.h"#include"string.h"#include"stdio.h"u8TEMP_data[20]={0},Receive_ok=0;u8sum=0,i=0;int16_tdata[2]={0};int8_tstr2[30];void{{{data[0]=(TEMP_data[4]<<8)|TEMP_data[5];//100倍的物体温度data[1]=(TEMP_data[6]<<8)|TEMP_data[7];//100倍的环境温度}}}void{NVIC_X.NVIC_IRQChannel=USART2_IRQn;//中断向量NVIC_X.NVIC_IRQChannelPreemptionPriority0;//抢占优先级NVIC_X.NVIC_IRQChannelSubPriority=2;//响应优先级NVIC_X.NVIC_IRQChannelCmd=ENABLE;//使能中断响应}{uint8_tindex=0;{}} (u8{u8bytes[3]={0};}{GPIO_InitTypeDefGPIO_usartx;USART_InitTypeDefUsart_X; GPIO_usartx.GPIO_ModeGPIO_Mode_AF_PP;//复用推挽输出 Usart_X.USART_StopBits=USART_StopBits_1;//1位停止位Usart_X.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;}{}{uint8_ti=0;{}}{uint8_ti=0;{}}{uint8_t{}}voidUSART2_disy(int16_t*num,u8send,u8{u8i=0;{{}{}}}{}uart3.c#include"uart1.h"#include"uart3.h"#include"common.h"#include<stdio.h>#include<string.h>#include<stdbool.h>#include"SysTick.h" static(voidstatic(voidstatic(voidv

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论