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.
Dependencies: mbed BME280 SI1145
Diff: main.cpp
- Revision:
- 10:1296cc169c60
- Parent:
- 9:e619711e05be
- Child:
- 11:0c66b84f8553
--- a/main.cpp Thu Jul 06 15:04:11 2017 +0000
+++ b/main.cpp Thu Jul 06 16:32:54 2017 +0000
@@ -16,6 +16,7 @@
#include "mbed.h"
#include "BME280.h"
#include "SI1145.h"
+//#include "MODSERIAL.h"
// Define Constants / Macros
#define node_id (0x01)
@@ -32,9 +33,11 @@
// Declare the PIR interface
InterruptIn MotionDetect(PA_0);
bool pir_enable = true;
-bool pir_trigger = false;
// Declare Serial Interfaces
+//Serial xb(tx, rx);
+//Serial pc(D1, D0);
+
Serial xb(tx, rx);
Serial pc(D1, D0);
@@ -47,17 +50,15 @@
}
void SendPirFlag(){
- if(1){
- xb.printf("ni:%c,mo:1\r\n",nodeID);;
- }
+ xb.printf("ni:%c,mo:1\r\n",nodeID);
}
// PIR interrupt. Set the pir_trigger to true when interrupted.
void PIR(void){
- if(xb.writeable()){
+ if(xb.writeable() && pir_enable){
SendPirFlag();
+ pc.printf("PIR FLAG ISR\r\n");
}
- pir_trigger = true;
}
void initialize_serial_connections(){
@@ -94,31 +95,15 @@
if(xb.writeable()){xb.printf("%c", pc_data);}
}
- if(pir_trigger){
- // DEBUG
- if(xb.writeable()){
- SendPirFlag();
- pir_trigger = false;
- pc.printf("PIR FLAG \r\n");
- }
- }
-
// testing out using getc() instead of gets()
if(xb.readable()){
wait(0.01);
- char temp = xb.getc();
- if(temp == 'i' || temp == '\0'){
- //if(xb.readable()){
- if(1){
- for(int i = 1; i < sizeof(buffer); i++){
- buffer[i] = xb.getc();
- }
- }
+ for(int i = 0; i < sizeof(buffer); i++){
+ buffer[i] = xb.getc();
+ pc.printf("%c", buffer[i]);
}
-
-
-
+
pc.printf("\r\n");
if(buffer[4] == nodeID){
send_enable = true;