B13 final project part 2

Dependencies:   mbed

Fork of Project_B13_RGBmaster by suchat tangjarukig

Files at this revision

API Documentation at this revision

Comitter:
mbedobsza
Date:
Wed Dec 09 18:07:00 2015 +0000
Parent:
0:65bf30fbbdeb
Commit message:
rgbmaster B13 final project

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 08 21:42:07 2015 +0000
+++ b/main.cpp	Wed Dec 09 18:07:00 2015 +0000
@@ -12,7 +12,7 @@
 void controlChange(uint8_t channel, uint8_t control, uint8_t value);
 void noteOn(uint8_t channel, uint8_t pitch, uint8_t velocity);
 void noteOff(uint8_t channel, uint8_t pitch);
-char mode = '2';
+char mode = '1';
 uint8_t keymap1[4][4]= {{0x2D,0x2E,0x2F,0x30},{0x31,0x32,0x33,0x34},{0x35,0x36,0x37,0x38},{0x39,0x3A,0x3B,0x3C}};
 uint8_t keymap2[4][4]= {{0x2D,0x2E,0x2F,0x30},{0x31,0x32,0x33,0x34},{0x35,0x36,0x37,0x38},{0x39,0x3A,0x3B,0x3C}};
 uint8_t channalmap[4][4]= {{1,1,1,1},{1,1,1,1},{2,2,2,2},{2,2,2,2}};
@@ -22,12 +22,12 @@
 /*uint8_t sequence[2][22]= {{0x32,0x2F,0x2F,0x32,0x2F,0x2F,0x32,0x2F,0x2F,0x39,0x00,0x38,0x37,0x35,0x35,0x33,0x31,0x31,0x30,0x2E,0x2E,0x00},
     {127,127,127,127,127,127,127,127,127,127,0,127,127,127,127,127,127,127,127,127,127,0}
 };*/
-uint8_t sequence[3][35]= {{
-        0x00,0x00,0x00,0x00,0x00, 0x32,0x2F,0x2F,0x00,0x32 ,0x2F,0x2F,0x00,0x32,0x2F, 0x2F,
+uint8_t sequence[3][38]= {{
+        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x32,0x2F,0x2F,0x00,0x32 ,0x2F,0x2F,0x00,0x32,0x2F, 0x2F,
         0x00,0x39,0x00,0x00 ,0x38,0x37,0x35,0x00,0x35, 0x33,0x31,0x00,0x31,0x30, 0x2E,0x00,0x2E,0x00,0x00
     },
-    {0,0,0,0,0, 127,127,127,0,127, 127,127,0,127,127 ,127,0,127,0,0 ,127,127,127,0,127 ,127,127,0,127,127 ,127,0,127,0,0},
-    {1,1,2,3,4, 4,3,2,3,3, 1,2,4,4,2, 2,1,1,3,4, 3,3,4,1,1, 1,2,1,3,3, 1,1,0,0,0}
+    {0,0,0,0,0,0,0,0, 127,127,127,0,127, 127,127,0,127,127 ,127,0,127,0,0 ,127,127,127,0,127 ,127,127,0,127,127 ,127,0,127,0,0},
+    {1,1,2,0,4, 4,3,0,3,3, 1,2,0,4,2, 2,0,1,0,0, 3,3,4,0,1, 1,2,0,3,3,    0,0,0,0,0,0,0,0}
 };
 
 int i = 1;
@@ -48,24 +48,30 @@
     while(1) {
 
         if(mode == '2') {
+            i = 1;
             while(mode == '2') {
                 if(mode1 == 0){
                     mode = '1';
-                    noteOff(1,sequence[0][i-1+3]+15);
+                    noteOff(1,sequence[0][i-1+6]+20);
                     slave.printf("#1");
                     }
                 current = t.read_ms();
                 if(current-previous >= beat_ms) {
-                    if(i>32) {
+                    if(i>38) {
 
                         i = 1;
-                        noteOff(1,sequence[i+3][0]);
+                        noteOff(1,sequence[i+4][0]);
                     }
+                    for(int j = 0;j<4;j++){
+                        if(addsw[j][sequence[2][sequence[2][i]]-1]==1){
+                            noteOn(1,sequence[0][i+6]+20,sequence[1][i+4]);
+                            break;
+                            }
+                        }
                     
-                    noteOn(1,sequence[0][i+3]+15,sequence[1][i]);
-                    noteOff(1,sequence[0][i-1+3]+15);
+                    noteOff(1,sequence[0][i-1+4]+20);
                     //wait_us(20);
-                    slave.printf("*%c",sequence[2][i]+'0');
+                    slave.printf("*%c",sequence[2][i-1]+'0');
                     i++;
                     previous = t.read_ms();
                 }