KIK01 Proto 08
Dependencies: AverageMCP3008 VoltageMonitor mbed-rtos mbed mcp3008
Fork of KIK01_Proto07 by
Diff: main.cpp
- Revision:
- 33:eac518ea0f34
- Parent:
- 32:41cda5ad45e4
- Child:
- 34:0ef840ff8f74
--- a/main.cpp Fri Dec 01 10:38:26 2017 +0000 +++ b/main.cpp Mon Dec 11 05:53:59 2017 +0000 @@ -2,6 +2,7 @@ * KIK01 * Kick Machine * + * 2017.12.03 Proto07: SyncIn * 2017.11.29 Proto06: Add Power Monitor * 2017.10.19 Proto05: Add NOS01 Controller * 2017.09.16 Proto04: SPI1 for AD8402 Wein Bridge DCO & Internal DAC for Dual-OTA-VCA @@ -22,7 +23,7 @@ #define PIN_CHECK (1) #define TITLE_STR1 ("KIK01 Kick Machine") -#define TITLE_STR2 ("20171129") +#define TITLE_STR2 ("20171211") #define PI_F (3.1415926f) @@ -60,10 +61,12 @@ // Power Monitor AnalogIn PowerMonitorIn(PA_0); DigitalOut PowerMonitorLed(PA_15); -VoltageMonitor PWMon(&PowerMonitorIn, PM_VDD, PM_LoThreshold, PM_HiThreshold, &PowerMonitorLed); +//VoltageMonitor PWMon(&PowerMonitorIn, PM_VDD, PM_LoThreshold, PM_HiThreshold, &PowerMonitorLed); +VoltageMonitor PWMon(&PowerMonitorIn, PM_VDD, PM_LoThreshold, PM_HiThreshold, NULL); // Sync -DigitalOut SyncPin(PA_10); +DigitalOut SyncOut(PC_10); +InterruptIn SyncIn(PC_11); // Check pins DigitalOut Dout1(PB_9); @@ -124,6 +127,7 @@ Dac1.write(amp); break; case 2: + //Dac2.write(amp); Dac2.write(amp * 0.8f); // Avoid LED,s Non-Linearity break; default: @@ -139,7 +143,7 @@ // Output Sync Signal per steps if (ticks % stepLength == 0) { - SyncPin = 1; + SyncOut = 1; } // set envelope parameters @@ -161,7 +165,7 @@ } // Output SyncSignal - SyncPin = 0; + SyncOut = 0; #if (PIN_CHECK) Dout1 = 0; @@ -199,6 +203,12 @@ noiseAmplitudeParam.releaseTauRatio = AvgAdc3.read_input(3) + 0.01f; } +void syncFunction() +{ + ticks = 0; + PowerMonitorLed = !PowerMonitorLed; +} + int main() { #if UART_TRACE @@ -221,6 +231,9 @@ ticks = 0; Ticker samplingTicker; samplingTicker.attach(&update, (1.0f/ENVELOPE_UPDATE_RATE)); + + // Sync Interrupt + SyncIn.rise(&syncFunction); for (;;) { #if (PIN_CHECK)