Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- mbed_Cookbook_SE
- Date:
- 2015-12-23
- Revision:
- 0:276a6b2e2aab
File content as of revision 0:276a6b2e2aab:
#include <mbed.h>
#include "ReceiverIR.h"
ReceiverIR ir_rx(p14);
int receive(RemoteIR::Format *format, uint8_t *buf, int bufsiz, int timeout = 100) {
int cnt = 0;
while (ir_rx.getState() != ReceiverIR::Received) {
cnt++;
if (timeout <cnt) {
return -1;
}
}
return ir_rx.getData(format, buf, bufsiz * 8);
}
int main(void) {
while (1) {
uint8_t buf[32];
int bitlength1;
RemoteIR::Format format;
memset(buf, 0x00, sizeof(buf));
bitlength1 = receive(&format, buf, sizeof(buf));
if (bitlength1 < 0) {
continue;
}
for(int i=0;i<bitlength1/8+((bitlength1 % 8) != 0) ? 1 : 0;i++)
{
printf("%02X",buf[i]);
}
printf("\r\n");
}
}