无线传感网络课程设计Word格式.docx
《无线传感网络课程设计Word格式.docx》由会员分享,可在线阅读,更多相关《无线传感网络课程设计Word格式.docx(67页珍藏版)》请在冰豆网上搜索。
用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;
i<
FONTLISTCOUNT;
i++)
{
if(fontList[i]==ch)
returni;
}
returni;
}
//查中文
staticu16lookforChar16(u16ch)
uint16i,j;
u16temp16;
fontChar16ListCount;
j=i*2;
temp16=fontChar16List[j+1];
temp16<
<
=8;
temp16|=fontChar16List[j];
if(temp16==ch)
在指定位置输出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)(ch>
>
8);
voidLcdPutString8(u8x,u8y,u8*ptru8len,u8op)
{
u8i,*tptr=ptr,xx=x,yy=y;
u16m;
if(x>
95)
return;
if(y>
1)
i<
len;
m=lookforChar(*tptr++);
if(m!
=FONTLISTCOUNT)
{
m=m*8;
}
else
return;
xx+=8;
if(xx>
88)
voidLcdClearRam(void)
u8i;
96;
i++)
LcdBuf[0][i]=0;
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;
if(xx>
if(yy)
{
m=m*16;
for(j=0;
j<
8;
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]);
}
break;
96)
//显示16*16字符
voidLcdPutString16_16(u8x,u8y,u8*ptr,u8len,u8op)
m=m*32;
for(j=0;
16;
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]);
xx+=16;
80)
staticvoidLcdPrint8(u8x,u8y,u8vl,u8op)
u8j;
m=lookforChar(vl);
if(m!
LcdPutChar8((x+j),y,font[m+j]);
LcdPutChar8((x+j),y+1,font[m+j+8]);
LcdPutChar8((x+j),y,~font[m+j]);
LcdPutChar8((x+j),y+1,~font[m+j+8]);
staticvoidLcdPrint16(u8x,u8y,u16val,u8op)
m=lookforChar16(val);
=fontChar16ListCount)
m=m*32;
LcdPutChar8((x+j),y,fontChar16[m+j]);
LcdPutChar8((x+j),y+1,fontChar16[m+j+16]);
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;
1)
return;
while((*tptr!
='
\0'
)&
&
(tcount<
=88))
if(*tptr<
127)//显示ASIC码
LcdPrint8(tcount,y,*tptr,op);
tptr++;
tcount+=8;
else//显示汉字
temp16=tptr[1];
temp16<
temp16|=tptr[0];
LcdPrint16(tcount,y,temp16,op);
tptr+=2;
tcount+=16;
/