mods

Dependencies:   mbed MCP4822 USBDevice

Files at this revision

API Documentation at this revision

Comitter:
kanope_benny
Date:
Thu Feb 25 12:18:54 2021 +0000
Parent:
8:c6ec6b9f6a55
Commit message:
init

Changed in this revision

MCP4822.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 c6ec6b9f6a55 -r c2a2c38ae084 MCP4822.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCP4822.lib	Thu Feb 25 12:18:54 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/kanope_benny/code/MCP4822/#f3de66b30fc3
diff -r c6ec6b9f6a55 -r c2a2c38ae084 main.cpp
--- a/main.cpp	Thu Sep 17 12:51:11 2020 +0000
+++ b/main.cpp	Thu Feb 25 12:18:54 2021 +0000
@@ -1,9 +1,7 @@
-// Hello World example for the USBMIDI library
-#if 1 
-
- 
+#if 1
 #include "mbed.h"
-#include "USBSerial.h"
+#include "USBMIDI.h"
+#include "MCP4822.h"
 
 
 void setup(void)
@@ -36,29 +34,85 @@
     //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_1);        // output SYSCLOCK to pin PC9 to monitor frequency
 }
 
- 
-
-DigitalOut myled(PC_13);
+DigitalOut myled( PC_13); 
+DigitalOut gate_A( PB_2);  
+DigitalOut gate_B( PB_10); 
+SPI spi(  PA_7, PA_6, PA_5); 
+MCP4822 dac(spi, PB_1, PB_0 );
+    
+void show_message(MIDIMessage msg) {
+    switch (msg.type()) {
+        case MIDIMessage::NoteOffType:
+            //TODO
+            break;
+        case MIDIMessage::NoteOnType:
+            // TODO  
+            //cf  = msg.key();
+            //cf  = msg.velocity();
+            
+            break;
+        case MIDIMessage::PolyphonicAftertouchType:
+            // TODO code 
+            break;
+        case MIDIMessage::ControlChangeType:
+            // TODO code 
+            break;
+        case MIDIMessage::AllNotesOffType:
+            // TODO 
+            break;
+        case MIDIMessage::ErrorType:
+            // TODO code 
+            break;
+        case MIDIMessage::ProgramChangeType:
+            // TODO code 
+            break;
+        case MIDIMessage::ChannelAftertouchType:
+            // TODO code 
+            break;
+        case MIDIMessage::PitchWheelType:
+            // TODO code 
+            break;
+        case MIDIMessage::SysExType:
+            // TODO code 
+            break; 
+        default:
+           // leds = 0;
+           break; 
+    }
+}
 
 int main() {    
 
     setup();
 
-    USBSerial pc;
-         
+    USBMIDI midi;
+    
+    
+    
+    midi.attach(show_message);
          
     while (1) {    
-       pc.printf("\ncalisse de guidoune!");
-       myled = !myled; // LED 
-        wait_ms( 100 ); 
+        for(int i=48; i<83; i++) {     // send some messages!
+            midi.write(MIDIMessage::NoteOn(i));
+            dac.a(0,1024);
+            dac.b(0,1024);
+            gate_A = 1 ; 
+            gate_B = 1 ; 
+            
+            wait(0.25);
+            midi.write(MIDIMessage::NoteOff(i));
+            gate_A = 0 ; 
+            gate_B = 0 ; 
+            dac.a(0,512);
+            dac.b(0,512);
+            
+            wait(0.5);
+            myled = !myled; // LED 
+        }
     }
-} 
-
-
+}
 #endif 
-
-#if 0 
-
+#if 0
 #include "mbed.h"
 #include "USBMIDI.h"
 
@@ -93,7 +147,7 @@
     //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_1);        // output SYSCLOCK to pin PC9 to monitor frequency
 }
 
- 
+ DigitalOut myled( PC_13); 
 
 int main() {    
 
@@ -112,4 +166,5 @@
         }
     }
 }
-#endif 
\ No newline at end of file
+#endif 
+