Midterm V2 Pt2

Dependencies:   MMA8451Q8b SLCD mbed

Fork of KL46z_single_tap_2017 by Stanley Cohen

Files at this revision

API Documentation at this revision

Comitter:
annalou
Date:
Wed Mar 15 15:52:38 2017 +0000
Parent:
12:4774c4fc718e
Commit message:
ALM_MIdtermV2Pt2

Changed in this revision

KL46z_single_tap_2016..cpp Show annotated file Show diff for this revision Revisions of this file
--- a/KL46z_single_tap_2016..cpp	Tue Mar 14 16:42:14 2017 +0000
+++ b/KL46z_single_tap_2016..cpp	Wed Mar 15 15:52:38 2017 +0000
@@ -2,6 +2,7 @@
 #include "MMA8451Q8g.h"
 #include "SLCD.h"
 
+#define PROGNAME "AnnaLouise Martinez_midtermPt2\n\r"
 #define BLINKTIME   1.5
 #define RELAYON     0
 #define RELAYOFF    1
@@ -36,7 +37,7 @@
 /******
 0b0001 1000
 24 = 0x18
-time step at 800Hz ODR = 0.625ms
+time step at 400Hz ODR = 0.625ms
 24x0.625 = 15 ms
 ******/
 
@@ -55,7 +56,7 @@
 #define MMA8451_I2C_ADDRESS (0x1d<<1)
  
 Ticker ledBlink; // timinginterrupt for RED led
-InterruptIn MMA8451QInt1(PTC5);  //push botton with internal pullup
+InterruptIn MMA8451QInt2(PTD1);  //push botton with internal pullup
 DigitalOut myled(LED_RED); // red led
 DigitalOut relay(LED_GREEN); // green led
 
@@ -64,6 +65,7 @@
 float delay = WAITDELAY;
 int relayState = RELAYOFF;
 int outState = false;
+Serial pc(USBTX, USBRX);
 SLCD slcd; //define LCD display
 char LCDMessages[2][LCDLEN] = {"TRUE", "FALS"};
 
@@ -105,10 +107,10 @@
     
     myled.write(outState);
     relay.write(relayState);
-    
+    pc.printf(PROGNAME);   
 // set up interrrupts to be used later for taps
-    MMA8451QInt1.rise(&GreenLEDBlinker);
-    MMA8451QInt1.mode(PullNone); 
+    MMA8451QInt2.rise(&GreenLEDBlinker);
+    MMA8451QInt2.mode(PullNone); 
    
 // set up interrrupts to be used later for taps
     ledBlink.attach(&LEDBlinker, LEDDELAY);
@@ -116,6 +118,7 @@
 // Read Pulse Source Data and check to see if things have been set
     acc.readRegs(REG_PULSE_CFG, &regData, 1);  // check it
     sprintf (lcdData,"%x",regData);
+    pc.printf("THIS IS SOURCE REG:", "%x",REG_PULSE_CFG, "\n");
     LCDMess(lcdData,BLINKTIME); 
     
 // *********** Initialize for tap tecognition ***********      
@@ -126,7 +129,7 @@
     LCDMess(lcdData,BLINKTIME);     
     
 // Check to see if accerlometer is alive and well
-    acc.setGLimit(MAX_4G); // For now set to 2g
+    acc.setGLimit(MAX_2G); // For now set to 2g
     acc.readRegs(XYZ_DATA_CFG, &regData, 1);
     sprintf (lcdData,"%x",regData); // Note displaying in hexidecimal
     LCDMess(lcdData,BLINKTIME);