m3pi for proj2
Dependencies: RemoteIR m3pi mbed-rtos mbed
Diff: LightCommunication.cpp
- Revision:
- 3:ecb3fa0406e8
- Parent:
- 2:70240992e869
- Child:
- 4:9580760cdd1f
--- a/LightCommunication.cpp Tue May 09 23:06:05 2017 +0200 +++ b/LightCommunication.cpp Tue May 09 23:16:07 2017 +0200 @@ -4,10 +4,15 @@ #include "LightCommunication.h" +int LightCommunication::left = 0; +int LightCommunication::right = 0; +Serial LightCommunication::device(p14,p15); +ReceiverIR LightCommunication::ir_rx(p21); +Mutex LightCommunication::mut; + + LightCommunication::LightCommunication() { left,right = 0; - device = new Serial(p14,p15); - ir_rx = new ReceiverIR(p21); } LightCommunication::~LightCommunication() { @@ -16,8 +21,8 @@ char * LightCommunication::getSerial() { char test[3]; - if(device->readable()) { - device->scanf("%s",test); + if(device.readable()) { + device.scanf("%s",test); } return test; } @@ -26,8 +31,8 @@ RemoteIR::Format format; uint8_t buf[32]; int bitcount; - if (ir_rx->getState() == ReceiverIR::Received) { - bitcount = ir_rx->getData(&format, buf, sizeof(buf) * 8); + if (ir_rx.getState() == ReceiverIR::Received) { + bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8); } return buf; }