KIK01 Proto 08

Dependencies:   AverageMCP3008 VoltageMonitor mbed-rtos mbed mcp3008

Fork of KIK01_Proto07 by Ryo Od

Revision:
38:90dde01f8255
Parent:
37:85eb8e38cac8
Child:
39:3c73531d13a2
--- a/main.cpp	Mon Dec 25 11:14:51 2017 +0000
+++ b/main.cpp	Sat Dec 30 09:11:42 2017 +0000
@@ -19,14 +19,14 @@
 #include "AverageMCP3008.h"
 #include "EnvelopeAR.h"
 
-#define UART_TRACE      (1)
+#define UART_TRACE      (0)
 #include "VoltageMonitor.h"
 
-#define PIN_CHECK       (1)
+#define PIN_CHECK       (0)
 #define LED_SYNCOUT_BLINK   (1)
 
 #define TITLE_STR1      ("KIK01 Kick Machine Proto08")
-#define TITLE_STR2      ("20171223")
+#define TITLE_STR2      ("20171230")
 
 #define PI_F            (3.1415926f)
 
@@ -105,12 +105,13 @@
 volatile float amplitude;
 volatile float noiseAmplitude;
 
-volatile float bpm;
 volatile int envelopeLength;
 volatile int stepLength;
 
+float bpm;
+
 //-----------------------------------------------------------------------------
-// Callback Functions
+// Interrupt Service Routine
 //-----------------------------------------------------------------------------
 
 void ledBeatAtTimeout()
@@ -130,9 +131,12 @@
 }
 #endif
 
-//-----------------------------------------------------------------------------
-// Functions
-//-----------------------------------------------------------------------------
+void syncInFunction()
+{
+    ticks = 0;
+    LedSyncIn = 1;
+    timeoutLedSyncIn.attach(&ledSyncInAtTimeout, LED_SYNCIN_BLINK_CYCLE);
+}
 
 void AD8402Write(uint8_t address, uint8_t value)
 {
@@ -222,6 +226,10 @@
 #endif
 }
 
+//-----------------------------------------------------------------------------
+// Functions
+//-----------------------------------------------------------------------------
+
 void readParams()
 {
     bpm = AvgAdc1.read_input(7) * 180.0f + 60.0f;
@@ -253,24 +261,18 @@
     noiseAmplitudeParam.releaseTauRatio = AvgAdc3.read_input(3) + 0.01f;
 }
 
-void syncInFunction()
-{
-    ticks = 0;
-    LedSyncIn = 1;
-    timeoutLedSyncIn.attach(&ledSyncInAtTimeout, LED_SYNCIN_BLINK_CYCLE);
-}
-
 void LedsCheck(int n, int wait)
 {
     for (int i = 0; i < n; i++) {
-        //LedPower = 1;
         LedBeat = 1;
+        Thread::wait(wait);
+        LedBeat = 0;
+
         LedSyncIn = 1;
+        Thread::wait(wait);
+        LedSyncIn = 0;
+
         LedSyncOut = 1;
-        Thread::wait(wait);
-        //LedPower = 0;
-        LedBeat = 0;
-        LedSyncIn = 0;
         LedSyncOut = 0;
         Thread::wait(wait);
     }