Smart-Home-TX Test
Dependencies: 4DGL-uLCD-SE PinDetect
Fork of Xbee-Smart-Home-Outside by
Diff: main.cpp
- Revision:
- 3:80ca319bd924
- Parent:
- 2:b549ccada3c3
- Child:
- 4:f87a36946c09
diff -r b549ccada3c3 -r 80ca319bd924 main.cpp --- a/main.cpp Wed Apr 26 04:10:40 2017 +0000 +++ b/main.cpp Wed Apr 26 14:52:11 2017 +0000 @@ -3,6 +3,7 @@ #include <stdio.h> #include "uLCD_4DGL.h" #include "rtos.h" +#include "PinDetect.h" // #include "jpegutil.h" Serial pc(USBTX, USBRX); @@ -11,8 +12,8 @@ DigitalOut reset(p8); DigitalOut led1(LED1); DigitalOut led2(LED2); -InterruptIn getStatus(p16); -InterruptIn toggleLight(p17); +PinDetect getStatus(p16); +PinDetect toggleLight(p17); // LocalFileSystem local("local"); / @@ -38,7 +39,7 @@ void sendcommand(char out) { - while(xbee.writeable()) { + if(xbee.writeable()) { led2 = 1; char outbuf = out; xbee.putc(outbuf); @@ -79,10 +80,15 @@ wait_ms(1); reset = 1; wait_ms(1); + getStatus.mode(PullDown); + getStatus.attach_asserted( &statusRequest ); + getStatus.setSampleFrequency(); // Defaults to 20ms. + toggleLight.mode(PullDown); - getStatus.rise(&statusRequest); //attach address of function on rising edge - toggleLight.rise(&flipLight); + toggleLight.attach_asserted( &flipLight ); + toggleLight.setSampleFrequency(); // Defaults to 20ms. + // lcd.baudrate(300000); lcd.cls(); lcd.locate(0,0); @@ -95,6 +101,8 @@ lcd.line(0, 45, 128, 45, 0xFF0000); // xbee.baud(115200); // May need to latter t1.start(getcommand); + wait(0.5); + sendcommand('s'); while(1) { if (statusReq == true) {