void lcd_display() //LCD初始化显示
{
TFT_ClearScreen(BLACK);
GUI_Show12ASCII(10,10,"PRECHIN",GREEN,BLACK);
GUI_Show12ASCII(10,30,"www.prechin.com",GREEN,BLACK);
GUI_Show12ASCII(10,50,"NRF24L01 Test!",GREEN,BLACK);
GUI_Show12ASCII(10,70,"2015-11-13",GREEN,BLACK);
GUI_Show12ASCII(10,90,"K_UP:RX_Mode K_DOWN:TX_Mode",GREEN,BLACK);
}
void data_pros() //数据处理函数
{
u8 key;
static u8 mode=2; //模式选择
u8 rx_buf[33]="www.prechin.com ";
static u16 t=0;
while(1) //等待按键按下进行选择发送还是接收
{
key=keyscan(0);
if(key==K_UP_PRESS) //接收模式
{
mode=0;
GUI_Show12ASCII(10,140,"RX_Mode",RED,BLACK);
GUI_Show12ASCII(10,160,"Received Data:",RED,BLACK);
GUI_Show12ASCII(120,160," ",RED,BLACK);
break;
}
if(key==K_DOWN_PRESS) //发送模式
{
mode=1;
GUI_Show12ASCII(10,140,"TX_Mode",RED,BLACK);
GUI_Show12ASCII(10,160,"Send Data: ",RED,BLACK);
GUI_Show12ASCII(120,160," ",RED,BLACK);
break;
}
}
if(mode==0) //接收模式
{
NRF24L01_RX_Mode();
while(1)
{
if(NRF24L01_RxPacket(rx_buf)==0) //接收到数据显示
{
rx_buf[32]='\0';
GUI_Show12ASCII(120,160,rx_buf,RED,BLACK);
break;
}
else
{
delay_ms(1);
}
t++;
if(t==1000)
{
t=0;
led1=~led1; //一秒钟改变一次状态
}
}
}
if(mode==1) //发送模式
{
NRF24L01_TX_Mode();
while(1)
{
if(NRF24L01_TxPacket(rx_buf)==TX_OK)
{
GUI_Show12ASCII(120,160,rx_buf,RED,BLACK);
break;
}
else
{
GUI_Show12ASCII(120,160,"Send Data Failed ",RED,BLACK);
}
}
}
}
|