本帖最后由 蓝雨夜 于 2014-12-19 20:36 编辑
【Atmel SAM R21创意大赛周计划】+OLED显示无线接收到数据
把接收到的数据显示在OLED上,同时显示rssi,及数据长度
1、添加全局变量
char disp[32];
uint8_t rssi;
uint8_t recv_ok;
uint8_t recv_lenght;
2、在无线接收回调函数中添加标志,及缓存
static bool appDataInd(NWK_DataInd_t *ind)
{
rssi=ind->rssi;
recv_lenght= ind->size;
for (uint8_t i = 0; i < ind->size; i++)
{
sio2host_putchar(ind->data
);
disp=ind->data;
}
LED_Toggle(LED0);
recv_ok=1;
return true;
/*
if (!appReadyToReceive)
return false;
// process ind->size bytes of the data pointed by ind->data
NWK_SetAckControl(APP_DO_NOT_SLEEP);
return true;
*/
}
3、应用中显示到OLED上
static void APP_TaskHandler(void) 中添加
if(recv_ok==1)
{
recv_ok=0;
ssd1306_clear();
//页
ssd1306_set_page_address(0);
//列
ssd1306_set_column_address(0);
sprintf(value_disp, "rssi=%d", rssi);
ssd1306_write_text(value_disp);
//列
ssd1306_set_column_address(45);
sprintf(value_disp, "size=%d", recv_lenght);
ssd1306_write_text(value_disp);
//页
ssd1306_set_page_address(2);
//列
ssd1306_set_column_address(0);
ssd1306_write_text(&disp);
for(i=0;i
{
disp=0;
}
}
4、效果