Nucleo SPI Sequencer

Dependencies:   AverageAnalogIn N5110 Nucleo_rtos_UI_Test PinDetect RotaryEncoder Sequence mbed-rtos mbed FilterController

Fork of Nucleo_rtos_UI_Test by Ryo Od

Files at this revision

API Documentation at this revision

Comitter:
ryood
Date:
Tue Jun 21 09:31:01 2016 +0000
Parent:
10:28082577ed5f
Commit message:
VCVS DCF??????FilterController???

Changed in this revision

FilterController.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 28082577ed5f -r 3aab82f74a75 FilterController.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FilterController.lib	Tue Jun 21 09:31:01 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/ryood/code/FilterController/#3c930c1aaf8f
diff -r 28082577ed5f -r 3aab82f74a75 main.cpp
--- a/main.cpp	Tue Jun 21 08:41:11 2016 +0000
+++ b/main.cpp	Tue Jun 21 09:31:01 2016 +0000
@@ -14,6 +14,7 @@
 #include "N5110.h"
 #include "AverageAnalogIn.h"
 #include "SpiSequenceSender.h"
+#include "SpiFilterController.h"
 
 #define UART_TRACE  (0)
 #define SPI_RATE    (8000000)
@@ -30,6 +31,8 @@
 Sequence sequence[SEQUENCE_N];
 SpiSequenceSender sequenceSender(&spiMaster, D9, sequence, SEQUENCE_N, 5);
 
+SpiFilterController filterController(&spiMaster, D10);
+
 //------------------------------------------------------------------------
 // User Interface
 //------------------------------------------------------------------------
@@ -58,12 +61,14 @@
     PinDetect(PA_8,  PullUp),
 };
 
+#if 0
 // ToDo: Filterにモジュレーション信号を送る方法を考える。
 struct Filter {
     int cutOff;
     int resonance;
     int envMod;
 } Filter;
+#endif
 
 int currentStep = 0;
 bool isRunning = true;
@@ -88,9 +93,9 @@
         isRunning, sequenceSender.getWaveShape());
     Lcd.printString(buff, 0, 3);
     sprintf(buff, "%3d %3d %3d", 
-        sequenceSender.getPulseWidth(), Filter.envMod, sequenceSender.getBpm());
+        sequenceSender.getPulseWidth(), filterController.getEnvMod(), sequenceSender.getBpm());
     Lcd.printString(buff, 0, 4);
-    sprintf(buff, "%3d %3d", Filter.cutOff, Filter.resonance);
+    sprintf(buff, "%3d %3d", filterController.getCutoff(), filterController.getResonance());
     Lcd.printString(buff, 0, 5);
     Lcd.refresh();
 }
@@ -209,34 +214,34 @@
     
     while (true) {
         // pulse width
-        tmp = Pots[0].read_u16() >> 9;    // 7bit witdth
+        tmp = Pots[0].read_u16() >> 9;    // 7bit width
         if (tmp != (sequenceSender.getPulseWidth() >> 1)) {
             sequenceSender.setPulseWidth(tmp << 1);
             isDirty = true;
         }
         // filter envelope moduration 
-        tmp = Pots[1].read_u16() >> 9;    // 7bit witdth
-        if (tmp != Filter.envMod) {
-            Filter.envMod = tmp;
+        tmp = Pots[1].read_u16() >> 8;
+        if (tmp != filterController.getEnvMod()) {
+            filterController.setEnvMod(tmp);
             isDirty = true;
         }
         // bpm
-        tmp = Pots[2].read_u16() >> 9;    // 7bit witdth
+        tmp = Pots[2].read_u16() >> 9;    // 7bit precission
         tmp <<= 1;
         if (tmp != sequenceSender.getBpm()) {
             sequenceSender.setBpm(tmp);
             isDirty = true;
         }
         // cutoff
-        tmp = Pots[3].read_u16() >> 10;    // 6bit witdth
-        if (tmp != Filter.cutOff) {
-            Filter.cutOff = tmp;
+        tmp = Pots[3].read_u16() >> 8;
+        if (tmp != filterController.getCutoff()) {
+            filterController.setCutoff(tmp);
             isDirty = true;
         }
         // resonance
-        tmp = Pots[4].read_u16() >> 10;    // 6bit witdth
-        if (tmp != Filter.resonance) {
-            Filter.resonance = tmp;
+        tmp = Pots[4].read_u16() >> 8;
+        if (tmp != filterController.getResonance()) {
+            filterController.setResonance(tmp);
             isDirty = true;
         }
         Thread::wait(20);
@@ -284,8 +289,9 @@
     
     // Main loop
     while (true) {
-        CheckPin = !CheckPin;
         if (!isRunning && isDirty) {
+            CheckPin = !CheckPin;
+            filterController.outDCF();
             updateLCD();
             isDirty = false;
         }