无线传感网络课程设计报告姓名:胡韶辉胡衎学号:139074377139074376班级:物131班指导教师:卫琳娜2017年1月1日无线传感网络课程设计实验一、无线传感网络点对点通信实验1.实验内容此实验为验证实验,根据实验步骤进行实验,观察结果是否与预期相符2.实验步骤用IAR8.1打开路径:C:\Users\xs\Desktop\无线传感器网络课程设计\无线传感网实验资料201604\感知RF2-2530WSNV1.2\代码和例子程序\Light_Switch\IDE\Light_Switch\srf05_cc2530\Iar\Light_Switch.eww分别编译并下载至两个节点上,打开节点,左右键选择device1/device2,选择完成后按中间键确认,观察LED灯显示情况。3.实验代码及分析/*功能:查找字符在索引中的哪一个位置*//**************************************************************************************************/staticu16lookforChar(u8ch){uint16i;for(i=0;iFONTLISTCOUNT;i++){if(fontList[i]==ch)returni;}returni;}//查中文staticu16lookforChar16(u16ch){uint16i,j;u16temp16;for(i=0;ifontChar16ListCount;i++){j=i*2;temp16=fontChar16List[j+1];temp16=8;temp16|=fontChar16List[j];if(temp16==ch)returni;}returni;}/**************************************************************************************************//*功能:在指定位置输出8*8*//**************************************************************************************************/staticvoidLcdPutChar8(u8x,u8y,u8ch){LcdBuf[y][x]=ch;}/**************************************************************************************************//*功能:在指定位置输出16*16*//**************************************************************************************************//*staticvoidLcdPutChar16(u8x,u8y,u16ch){LcdBuf[y][x]=(u8)ch;//低前高后LcdBuf[y+1][x]=(u8)(ch8);}voidLcdPutString8(u8x,u8y,u8*ptru8len,u8op){u8i,*tptr=ptr,xx=x,yy=y;u16m;if(x95)return;if(y1)return;for(i=0;ilen;i++){m=lookforChar(*tptr++);if(m!=FONTLISTCOUNT){m=m*8;}elsereturn;xx+=8;if(xx88)return;}}*/voidLcdClearRam(void){u8i;for(i=0;i96;i++){LcdBuf[0][i]=0;}for(i=0;i96;i++){LcdBuf[1][i]=0;}}voidLcdClearScrean(void){LcdClearRam();PutPic((void*)LcdBuf);}voidLcdPutString16_8(u8x,u8y,u8*ptr,u8len,u8op){u8i,j,*tptr=ptr,xx=x,yy=y;u16m;if(xx95)return;if(yy)return;for(i=0;ilen;i++){m=lookforChar(*tptr++);if(m!=FONTLISTCOUNT){m=m*16;for(j=0;j8;j++){if(op){LcdPutChar8((xx+j),yy,font[m+j]);LcdPutChar8((xx+j),yy+1,font[m+j+8]);}else{LcdPutChar8((xx+j),yy,~font[m+j]);LcdPutChar8((xx+j),yy+1,~font[m+j+8]);}}}elsebreak;xx+=8;if(xx96)return;}PutPic((void*)LcdBuf);}//显示16*16字符voidLcdPutString16_16(u8x,u8y,u8*ptr,u8len,u8op){u8i,j,*tptr=ptr,xx=x,yy=y;u16m;if(xx95)return;if(yy)return;for(i=0;ilen;i++){m=lookforChar(*tptr++);if(m!=FONTLISTCOUNT){m=m*32;for(j=0;j16;j++){if(op){LcdPutChar8((xx+j),yy,font[m+j]);LcdPutChar8((xx+j),yy+1,font[m+j+16]);}else{LcdPutChar8((xx+j),yy,~font[m+j]);LcdPutChar8((xx+j),yy+1,~font[m+j+16]);}}}elsebreak;xx+=16;if(xx80)return;}PutPic((void*)LcdBuf);}staticvoidLcdPrint8(u8x,u8y,u8vl,u8op){u8j;u16m;m=lookforChar(vl);if(m!=FONTLISTCOUNT){m=m*16;for(j=0;j8;j++){if(op){LcdPutChar8((x+j),y,font[m+j]);LcdPutChar8((x+j),y+1,font[m+j+8]);}else{LcdPutChar8((x+j),y,~font[m+j]);LcdPutChar8((x+j),y+1,~font[m+j+8]);}}}}staticvoidLcdPrint16(u8x,u8y,u16val,u8op){u8j;u16m;m=lookforChar16(val);if(m!=fontChar16ListCount){m=m*32;for(j=0;j16;j++){if(op){LcdPutChar8((x+j),y,fontChar16[m+j]);LcdPutChar8((x+j),y+1,fontChar16[m+j+16]);}else{LcdPutChar8((x+j),y,~fontChar16[m+j]);LcdPutChar8((x+j),y+1,~fontChar16[m+j+16]);}}}}voidLcdPutDispBuf(u8x,u8y,OledCodeDataType*ptr,u8op){u8tcount=x;OledCodeDataType*tptr=ptr;u16temp16;if(x88)return;if(y1)return;while((*tptr!='\0')&&(tcount=88)){if(*tptr127)//显示ASIC码{LcdPrint8(tcount,y,*tptr,op);tptr++;tcount+=8;}else//显示汉字{temp16=tptr[1];temp16=8;temp16|=tptr[0];LcdPrint16(tcount,y,temp16,op);tptr+=2;tcount+=16;}}PutPic((void*)LcdBuf);}//实现中英文混合显示voidLcdPutDisp(u8x,u8y,OledCodeDataType*ptr,u8op){u8tcount=x;OledCodeDataType*tptr=ptr;u16temp16;if(x88)return;if(y1)return;while((*tptr!='\0')&&(tcount=88)){if(*tptr127)//显示ASIC码{LcdPrint8(tcount,y,*tptr,op);tptr++;tcount+=8;}else//显示汉字{temp16=tptr[1];temp16=8;temp16|=tptr[0];LcdPrint16(tcount,y,temp16,op);tptr+=2;tcount+=16;}}PutPic((void*)LcdBuf);}//从右往左输出一组字符并移运显示voidLcdPutScDispRtoL(OledCodeDataType*ptr,u8op,u16dl){OledCodeDataType*tptr=ptr;u16temp16;//LcdClearRam();while(*tptr!='\0'){if(*tptr127)//显示ASIC码{memcpy(LcdBuf[0],&LcdBuf[0][8],88);memcpy(LcdBuf[1],&LcdBuf[1][8],88);LcdPrint8(88,0,*tptr,op);tptr++;}else//显示汉字{memcpy(LcdBuf[0],&LcdBuf[0][16],80);memcpy(LcdBuf[1],&LcdBuf[1][16],80);temp16=tptr[1];temp16=8;temp16|=tptr[0];LcdPrint16(80,0,temp16,op);tptr+=2;}PutPic((void*)LcdBuf);LcdDelay(dl);}}voidLcdPutScDispRtoL12(OledCodeDataType*ptr,u8op,u16dl){OledCodeDataType*tptr=ptr;u16i,temp16;for(i=0;i12;){if(*tptr127)//显示ASIC码{memcpy(LcdBuf[0],&LcdBuf[0][8],88);memcpy(LcdBuf[1],&LcdBuf[1][8],88);LcdPrint8(88,0,*tptr,op);tptr++;i++;}else//显示汉字{memcpy(LcdBuf[0],&LcdBuf[0][16],80);memcpy(LcdBuf[1],&LcdBuf[1][16],80);temp16=tptr[1];temp16=8;temp16|=tptr[0];LcdPrint16(80,0,temp16,op);tptr+=2;i+=2;}PutPic((void*)LcdBuf);LcdDelay(dl);}}//从左往右voidLcdPutScDispLtoR12(OledCodeDataType*ptr,u8op,u16dl){OledCodeDataType*ttptr,*tptr=ptr;u16temp16;u8i,len,tempbuf[2][96];len=12;tptr=ptr+11;for(i=0;ilen;){if(*(tptr)127)//显示ASIC码{memcpy(&tempbuf[0][0],&LcdBuf[0][0],96);memcpy(&tem