1、无线传感网络课程设计无线传感网络课程设计报告 姓名:胡韶辉 胡衎学号:139074377 139074376班级:物131班指导教师:卫琳娜 2017年1月1日无线传感网络课程设计实验一、无线传感网络点对点通信实验1.实验内容此实验为验证实验,根据实验步骤进行实验,观察结果是否与预期相符2实验步骤 用IAR8.1打开路径:C:UsersxsDesktop无线传感器网络课程设计无线传感网实验资料201604感知RF2-2530WSNV1.2代码和例子程序Light_SwitchIDELight_Switchsrf05_cc2530IarLight_Switch.eww分别编译并下载至两个节点上,
2、打开节点,左右键选择/,选择完成后按中间键确认,观察LED灯显示情况。3.实验代码及分析/*功 能:查找字符在索引中的哪一个位置*/*/static u16 lookforChar( u8 ch ) uint16 i; for( i = 0; i FONTLISTCOUNT; i + ) if( fontListi = ch ) return i; return i;/查中文static u16 lookforChar16( u16 ch ) uint16 i,j; u16 temp16; for( i = 0; i fontChar16ListCount; i + ) j = i*2; te
3、mp16 = fontChar16Listj + 1; temp16 8);void LcdPutString8( u8 x,u8 y,u8 *ptr u8 len,u8 op ) u8 i,*tptr = ptr,xx = x,yy = y; u16 m; if( x 95) return ; if( y 1) return ; for( i = 0;i 88 ) return; */void LcdClearRam( void ) u8 i; for( i = 0;i 96;i + ) LcdBuf0i = 0; for( i = 0;i 95) return ; if( yy ) ret
4、urn ; for( i = 0;i len; i + ) m = lookforChar(*tptr +); if( m != FONTLISTCOUNT ) m = m * 16; for( j = 0;j 96 ) return; PutPic( (void *)LcdBuf );/显示16*16字符void LcdPutString16_16( u8 x,u8 y,u8 *ptr,u8 len,u8 op ) u8 i,j,*tptr = ptr,xx = x,yy = y; u16 m; if( xx 95) return ; if( yy ) return ; for( i = 0
5、;i len; i + ) m = lookforChar(*tptr +); if( m != FONTLISTCOUNT ) m = m * 32; for( j = 0;j 80 ) return; PutPic( (void *)LcdBuf );static void LcdPrint8( u8 x,u8 y,u8 vl,u8 op ) u8 j; u16 m; m = lookforChar( vl ); if( m != FONTLISTCOUNT ) m = m * 16; for( j = 0;j 8;j + ) if(op) LcdPutChar8( (x + j),y,f
6、ontm+j ); LcdPutChar8( (x + j),y+1,fontm+j+8 ); else LcdPutChar8( (x + j),y,fontm+j ); LcdPutChar8( (x + j),y+1,fontm+j+8 ); static void LcdPrint16( u8 x, u8 y, u16 val, u8 op ) u8 j; u16 m; m = lookforChar16( val ); if( m != fontChar16ListCount ) m = m * 32; for( j = 0;j 88 ) return ; if( y 1 ) ret
7、urn; while( (*tptr != 0) & ( tcount = 88) ) if(*tptr 127) /显示ASIC码 LcdPrint8( tcount,y,*tptr,op ); tptr +; tcount += 8; else /显示汉字 temp16 = tptr1; temp16 88 ) return ; if( y 1 ) return; while( (*tptr != 0) & ( tcount = 88) ) if(*tptr 127) /显示ASIC码 LcdPrint8( tcount,y,*tptr,op ); tptr +; tcount += 8;
8、 else /显示汉字 temp16 = tptr1; temp16 = 8; temp16 |= tptr0; LcdPrint16( tcount,y,temp16,op ); tptr += 2; tcount += 16; PutPic( (void *)LcdBuf );/从右往左输出一组字符并移运显示void LcdPutScDispRtoL( OledCodeDataType *ptr,u8 op,u16 dl ) OledCodeDataType *tptr = ptr; u16 temp16;/ LcdClearRam(); while( *tptr != 0 ) if(*t
9、ptr 127) /显示ASIC码 memcpy(LcdBuf0,&LcdBuf08,88); memcpy(LcdBuf1,&LcdBuf18,88); LcdPrint8( 88,0,*tptr,op ); tptr +; else /显示汉字 memcpy(LcdBuf0,&LcdBuf016,80); memcpy(LcdBuf1,&LcdBuf116,80); temp16 = tptr1; temp16 = 8; temp16 |= tptr0; LcdPrint16( 80,0,temp16,op ); tptr += 2; PutPic( (void *)LcdBuf ); L
10、cdDelay( dl ); void LcdPutScDispRtoL12( OledCodeDataType *ptr,u8 op,u16 dl ) OledCodeDataType *tptr = ptr; u16 i,temp16; for( i = 0;i 12;) if(*tptr 127) /显示ASIC码 memcpy(LcdBuf0,&LcdBuf08,88); memcpy(LcdBuf1,&LcdBuf18,88); LcdPrint8( 88,0,*tptr,op ); tptr +; i + ; else /显示汉字 memcpy(LcdBuf0,&LcdBuf016
11、,80); memcpy(LcdBuf1,&LcdBuf116,80); temp16 = tptr1; temp16 = 8; temp16 |= tptr0; LcdPrint16( 80,0,temp16,op ); tptr += 2; i +=2; PutPic( (void *)LcdBuf ); LcdDelay( dl ); /从左往右void LcdPutScDispLtoR12( OledCodeDataType *ptr,u8 op,u16 dl ) OledCodeDataType *ttptr,*tptr = ptr; u16 temp16; u8 i,len,tem
12、pbuf296; len = 12; tptr = ptr+11; for( i = 0; i len; ) if( *(tptr) 127 ) /显示ASIC码 memcpy(&tempbuf00,&LcdBuf00,96 ); memcpy(&tempbuf10,&LcdBuf10,96 ); memcpy(&LcdBuf08,&tempbuf00,88); memcpy(&LcdBuf18,&tempbuf10,88); LcdPrint8( 0,0,*tptr,op ); tptr -; i +; else /显示汉字 memcpy(&tempbuf00,&LcdBuf00,96 );
13、 memcpy(&tempbuf10,&LcdBuf10,96 ); memcpy(&LcdBuf016,&tempbuf00,80); memcpy(&LcdBuf116,&tempbuf10,80); ttptr = tptr; temp16 = *ttptr; temp16 95) | (x + w) 96) ) return; if( (y 1) | (y + h) 2) return; for( i = 0;i w; i + ) if(op) LcdBufyx + i = *tptr ; if( h = 2 ) LcdBufy+1x + i = *(tptr+w); tptr +;
14、else LcdBufyx + i = *tptr ; if( h = 2 ) LcdBufy+1x + i = *(tptr+w); tptr +; PutPic( (void *)LcdBuf );/整屏滑动显示void LcdPutScPic( OledCodeDataType *ptr, u8 op,u8 qp,u16 dl ) u8 i,j; u8 tempbuf296; if(qp) for( i = 0 ;i 96; i + ) tempbuf0i = *ptr+; for( i = 0 ;i 96; i + ) tempbuf1i = *ptr+; else for( i =
15、0 ;i 96; i + ) tempbuf0i = *ptr+; for( i = 0 ;i 96; i + ) tempbuf1i = *ptr+; switch( op ) case RIGHT_SC: /右边 for( i = 0; i 8; i + ) for(j = 0;j 84; j + ) LcdBuf095-j = LcdBuf083 - j; LcdBuf195-j = LcdBuf183 - j; for( j = 0;j 12; j + ) LcdBuf011-j = tempbuf095 - j; LcdBuf111-j = tempbuf195 - j; for(j
16、 = 0;j 84; j + ) tempbuf095-j = tempbuf083 - j; tempbuf195-j = tempbuf183 - j; PutPic( (void *)LcdBuf ); LcdDelay( dl ); break; case LIFT_SC: /左边 for( i = 0; i 8; i + ) for(j = 0;j 84; j + ) LcdBuf0j = LcdBuf0j + 12; LcdBuf1j = LcdBuf1j + 12; for( j = 0;j 12; j + ) LcdBuf095-j = tempbuf011-j; LcdBuf195-j = tempbuf111-j; for(j = 0;j 84; j + ) tempbuf0j = tempbuf0j+12; tempbuf
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1