InfraredLibに対応したMSC
Dependencies: BLE_API RemoteIR mbed nRF51822
Fork of nRF51822_SimpleChat_IRRX_nRF51DK by
Diff: main.cpp
- Revision:
- 6:976503121a46
- Parent:
- 5:1bf7a84598a1
- Child:
- 7:66243b10532c
diff -r 1bf7a84598a1 -r 976503121a46 main.cpp --- a/main.cpp Sat Dec 03 03:21:22 2016 +0000 +++ b/main.cpp Sat Dec 03 10:37:12 2016 +0000 @@ -43,7 +43,7 @@ Serial pc(USBTX, USBRX); Ticker steper; - +DigitalOut led1(P0_17); ReceiverIR ir_rx(P0_25); TransmitterIR ir_tx(P0_18); @@ -196,7 +196,7 @@ char bufbuf_c[20]; uint8_t bufbuf[40]; sprintf(bufbuf_c, "%d", receivedFlag); - + led1 = receivedFlag; int a; for(a=0; bufbuf_c[a] != '\0'; a++) { bufbuf[a] = bufbuf_c[a]; @@ -221,12 +221,10 @@ */ int receive(RemoteIR::Format *format, uint8_t *buf, int bufsiz, int timeout = 100) { int cnt = 0; - while (ir_rx.getState() != ReceiverIR::Received) { +// while (ir_rx.getState() != ReceiverIR::Received) { + if (ir_rx.getState() != ReceiverIR::Received) { //pc.printf("no receive \r\n"); - cnt++; - if (timeout < cnt) { return -1; - } } return ir_rx.getData(format, buf, bufsiz * 8); } @@ -308,6 +306,7 @@ int main(void) { + led1 = 0; ble.init(); ble.onDisconnection(disconnectionCallback); ble.onDataWritten(WrittenHandler); @@ -369,7 +368,7 @@ display_data(buf1, bitlength1); display_format(format); receivedFlag = 1; - flagMargine = 100; + flagMargine = 50; } } }