Tau ReSpeaker Setup V01

Dependencies:   MbedJSONValue mbed

Fork of TAU_ReSpeaker_DSP_Test by Yossi_Students

Revision:
4:59319802012b
Parent:
3:48258b86e182
Child:
5:ec6f2323a263
--- a/main.cpp	Mon Feb 19 11:50:39 2018 +0000
+++ b/main.cpp	Mon Feb 19 15:14:44 2018 +0000
@@ -131,9 +131,11 @@
 functionPtr FilterFunction;
 
 // alternative functuin selection (faster mcu process)
-uint8_t operationMode = 0;
-// 0 -  no filter
-// 1 -  High Pass filter
+volatile uint8_t operationMode = 0;
+// 0 -  off
+// 1 -  passthrough - no filter
+// 2 -  highpass    - High Pass filter
+// 3 -  hpf_trig    - High Pass filter + Trigger mode
 
 ///////////////
 // Functions //
@@ -196,12 +198,15 @@
     while(1) {
         // run selected filter
         if (operationMode == 0) {
-            no_filter();
+            offMode();
         } else if (operationMode == 1) {
-            highpass_filter();
-            //pc.printf("Mode: %d \r\n", operationMode);
-            //wait(0.1);
+            passthrough();
+        } else if (operationMode == 2) {
+            highpass();
+        } else if (operationMode == 3) {
+            highpassTrig();
         }
+        //highpass_filter();
         // more elegant but much slower option:
         //FilterFunction();
 #ifdef DEBUG_MOD11
@@ -231,7 +236,7 @@
     Dac_Reg += __HAL_DHR12R1_ALIGNEMENT(DAC_ALIGN_12B_R);
 
     // intialize filter function pointer
-    FilterFunction = no_filter;//highpass_filter;//no_filter;
+    FilterFunction = offMode;//highpass_filter;
     operationMode = 0 ;
 }
 
@@ -386,35 +391,32 @@
 // DSP Packet Handler
 void dspPacket(void)
 {
-    string filterType;
     string modeType;
-    // get mic channle
-    filterType = guiCmd["filter"].get<string>();
+    // get operation mode
     modeType = guiCmd["mode"].get<string>();
 
 #ifdef DEBUG_MOD10
     // send parsed values
-    pc.printf("filter: %s , mode: %s\r\n", filterType.c_str(),modeType.c_str());
-    switch_dsp.printf("filter: %s , mode: %s\r\n", filterType.c_str(),modeType.c_str());
+    pc.printf("mode: %s\r\n", modeType.c_str());
+    switch_dsp.printf("mode: %s\r\n", modeType.c_str());
 #endif
     // selected operation mode
-    if ( filterType == "none" ) {
-        FilterFunction = no_filter;
+    if ( modeType == "off" ) {
+        FilterFunction = offMode;
         operationMode = 0 ;
-    } else if( filterType == "hpf" ) {
-        FilterFunction = highpass_filter;
+    } else if( modeType == "passthrough" ) {
+        FilterFunction = passthrough;
         operationMode = 1 ;
+    }else if( modeType == "highpass" ) {
+        FilterFunction = highpass;
+        operationMode = 2 ;
+    }else if( modeType == "hpf_trig" ) {
+        FilterFunction = highpassTrig;
+        operationMode = 3 ;
     } else {
-        switch_dsp.printf("undefined filter %s \r\n", filterType.c_str());
-        FilterFunction = no_filter;
+        switch_dsp.printf("undefined mode %s \r\n", modeType.c_str());
+        FilterFunction = offMode;
         operationMode = 0 ;
     }
 
-    // selected operation mode
-    if ( modeType == "off" ) {
-    } else if( modeType == "on" ) {
-    } else {
-        switch_dsp.printf("undefined filter %s \r\n", modeType.c_str());
-    }
-
 }// end dspPacket
\ No newline at end of file