![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Xbee-Smart-Home-Inside RX Test
Dependencies: Si7021 mbed-rtos JPEGCamera mbed
Fork of Xbee-Smart-Home-Inside by
Diff: main.cpp
- Revision:
- 4:df159b3382e3
- Parent:
- 3:415ccd1f7ae1
- Child:
- 5:81a1920e5f3d
diff -r 415ccd1f7ae1 -r df159b3382e3 main.cpp --- a/main.cpp Tue Apr 25 22:36:59 2017 +0000 +++ b/main.cpp Wed Apr 26 04:10:32 2017 +0000 @@ -8,8 +8,8 @@ Serial pc(USBTX, USBRX); JPEGCamera camera(p13, p14); DigitalOut rst1(p8); -AnalogIn ambient(p15); -DigitalOut light(p16); +AnalogIn ambient(p16); +DigitalOut light(p17); Si7021 tempHum(p28, p27); DigitalOut led1(LED1); @@ -18,10 +18,10 @@ char outBuffer[50]; // char imageBuff[4800]; // For camera buffer char inBuffer; -bool lightOnOff = true; +bool lightOnOff = false; volatile bool requestIn = false; -Mutex serialMutex; +// Mutex serialMutex; Thread t1; void getcommand() @@ -29,10 +29,8 @@ while(1) { if(xbee.readable()) { led1 = 1; - serialMutex.lock(); inBuffer = xbee.getc(); requestIn = true; - serialMutex.unlock(); led1 = 0; } Thread::wait(1000); @@ -44,17 +42,14 @@ if(xbee.writeable()){ led2 = 1; int i = 0; - serialMutex.lock(); while(outBuff[i] != ','){ xbee.putc(outBuff[i]); - pc.putc(outBuff[i]); i++; } - serialMutex.unlock(); led2 = 0; } } - +/* // IRS p26, SDA p9, SCL p10 (SDA & SCL Need 4.7Kohm with 3.3, Vcc --> 3.3 InterruptIn interrupt(p26); I2C i2c(p9, p10); @@ -69,7 +64,7 @@ // Implemented latter // If wrong passcode then take pic & send it } - +*/ /* // Implemented latter void cameraImage() { @@ -94,6 +89,7 @@ int main() { + light = 0; rst1 = 0; wait_ms(1); rst1 = 1; @@ -102,11 +98,12 @@ t1.start(getcommand); // If someone enter key in touchpad this interrupt will be evoked - interrupt.fall(&fallInterrupt); - interrupt.mode(PullUp); + // interrupt.fall(&fallInterrupt); + // interrupt.mode(PullUp); while(1){ if(requestIn == true){ // Check for input request msg + led1 = 0; if(inBuffer == 's') { // Send the status tempHum.measure(); float temp = (tempHum.get_temperature()/1000.00); @@ -114,14 +111,17 @@ float lightStatus = light; char delimit = '|'; char terminate = ','; - char status = 's'; - sprintf(outBuffer, "%c%c%2.2f%c%2.1f%c%0.2f%c",status, delimit, temp, delimit, hum, delimit, lightStatus, terminate); + sprintf(outBuffer, "%2.2f%c%2.1f%c%0.2f%c",temp, delimit, hum, delimit, lightStatus, terminate); sendcommand(outBuffer); + led1 = 1; + inBuffer = ' '; } else if(inBuffer == 'l') { lightOnOff = !lightOnOff; // Toggle light on/off - (lightOnOff == true) ? ambient : 0; - + // (lightOnOff == true) ? ambient : 0; + light = (lightOnOff == true) ? 1 : 0; + led1 = 1; + inBuffer = ' '; } else if(inBuffer == 'c') { // Capture pic & Send it // cameraImage();