Karpova Lab fork of stateScript

Dependencies:   SMARTWAV SOMO_II mbed

Fork of stateScript_v2_karpova by Andy Lustig

Revision:
9:f15ad8d18881
Parent:
8:436cf2ab961c
diff -r 436cf2ab961c -r f15ad8d18881 mbedInterface/mbedInterface.cpp
--- a/mbedInterface/mbedInterface.cpp	Wed Jan 27 21:31:45 2016 +0000
+++ b/mbedInterface/mbedInterface.cpp	Thu Jan 28 16:47:32 2016 +0000
@@ -1,7 +1,7 @@
 #include "mbedInterface.h"
 #include "mbed.h"
-#define EPHYSRIG
-//#define TRAINRIG
+#define EPHYSRIG //!!!!!!make sure to change NUMPORTS, NUMINPORTS, and NUMOUTPORTS in the mbedInterface.h file!!!!!!!!!
+//#define TRAINRIG //!!!!!!make sure to change NUMPORTS, NUMINPORTS, and NUMOUTPORTS in the mbedInterface.h file!!!!!!!!!
 
 
 //--------------------------------------------------------------
@@ -51,8 +51,8 @@
 bool RFSyncWritable = true;
 
 //Recieve clock signal from RF system
-InterruptIn RFClock(p28);
-DigitalIn RFData(p27);
+InterruptIn RFClock(p25);
+DigitalIn RFData(p26);
 
 
 void callback_RFClock(void) {
@@ -139,19 +139,20 @@
 ////PinName outPins[NUMPORTS] = {p18,p15,p13,p11,p29,p25,p23,p21,p20}; //New board output pins
 //PinName inPins[NUMINPORTS] = {p12,p14,p16,p17,p22,p24,p26,p30,p7};
 
-#ifdef TRAINRIG
+#ifdef TRAINRIG //!!!!!!make sure to change NUMPORTS, NUMINPORTS, and NUMOUTPORTS in the mbedInterface.h file!!!!!!!!!
 //translate pin numbers to hardware pins
-PinName outPins[NUMPORTS] = {p7,p10,p13,p16,p17,p18,p21,p22}; //p21 and p21 are place holders 
-PinName inPins[NUMPORTS]  = {p5,p6,p8,p9,p11,p12,p14,p15};
+PinName outPins[NUMPORTS] = {p7,p10,p13,p16,p17,p18};       //6 outports
+PinName inPins[NUMPORTS]  = {p5,p6,p8,p9,p11,p12,p14,p15};  //8 inports
 #endif
-#ifdef EPHYSRIG
+#ifdef EPHYSRIG//!!!!!!make sure to change NUMPORTS, NUMINPORTS, and NUMOUTPORTS in the mbedInterface.h file!!!!!!!!!
 //translate pin numbers to hardware pins
-PinName outPins[NUMPORTS] = {p7,p10,p12,p14,p16,p17,p18,p21,p22};
-PinName inPins[NUMPORTS]  = {p5,p6,p8,p9,p11,p13,p15,p23,p24};
+PinName outPins[NUMPORTS] = {p7,p10,p12,p14,p16,p17,p18,p21,p22}; //9 outports
+PinName inPins[NUMPORTS]  = {p5,p6,p8,p9,p11,p13,p15,p23,p24};    //9 inports
 #endif
 
 //The sound output uses a SmartWav device and their simple serial library
-SMARTWAV sWav(p9,p10,p19);   //(TX,RX,Reset);
+//SMARTWAV audio(p28,p27,p19);   //(TX,RX,Reset);
+SOMO audio(p28,p27);        //(TX,RX,Reset)
 
 //This is the callback for the MBED timer
 extern "C" void TIMER0_IRQHandler (void) {
@@ -188,8 +189,8 @@
 
 
 MBEDSystem::MBEDSystem():
-    clockResetInt(p5),
-    clockExternalIncrement(p8) {
+    clockResetInt(p29),
+    clockExternalIncrement(p30) {
 
     clockResetInt.rise(this, &MBEDSystem::externalClockReset);
     clockResetInt.fall(&externalResetDown);
@@ -212,7 +213,7 @@
     }
 
 
-    sWav.reset();
+    audio.reset();
 
 }
 
@@ -365,20 +366,21 @@
 
 void MBEDSound::execute() {
     if (reset) {
-        sWav.reset();
+        audio.reset();
     } else if (!play) {
-        sWav.stopTrack();
+        audio.stopTrack();
+    } else if (fileNum){
+        audio.playTrackNum(fileNum);
     } else {
         if (volume > -1) {
-            sWav.volume(volume);
+            audio.volume(volume);
         } else if (volumePtr != NULL) {
-            sWav.volume(*volumePtr);
+            audio.volume(*volumePtr);
         }
-
         if (fileNameExists) {
-            //sWav.playTracks();
-            sWav.stopTrack();
-            sWav.playTrackName(fileName);
+            audio.stopTrack();
+            wait_ms(30); //without this delay, smartWAV shield tends to freeze up
+            audio.playTrackName(fileName);
         }
     }
 }