Program of McLighTT

Dependencies:   TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG DISCO_F746NG_USBDevice

Files at this revision

API Documentation at this revision

Comitter:
Natthaphan
Date:
Fri May 10 13:45:29 2019 +0000
Commit message:
McLighTT

Changed in this revision

BSP_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
DISCO_F746NG_USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
TS_DISCO_F746NG.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r cb5e943e3cf8 BSP_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Fri May 10 13:45:29 2019 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#c9112f0c67e3
diff -r 000000000000 -r cb5e943e3cf8 DISCO_F746NG_USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DISCO_F746NG_USBDevice.lib	Fri May 10 13:45:29 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/DieterGraef/code/DISCO_F746NG_USBDevice/#0a2eaa300982
diff -r 000000000000 -r cb5e943e3cf8 LCD_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Fri May 10 13:45:29 2019 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
diff -r 000000000000 -r cb5e943e3cf8 TS_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F746NG.lib	Fri May 10 13:45:29 2019 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
diff -r 000000000000 -r cb5e943e3cf8 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 10 13:45:29 2019 +0000
@@ -0,0 +1,406 @@
+#include "mbed.h"
+#include "USBMIDI.h"
+#include "LCD_DISCO_F746NG.h"
+#include "TS_DISCO_F746NG.h"
+
+void set1(void);
+void set2(void);
+void set3(void);
+
+#define FastSpeedInterface 0
+#define HighSpeedInterface 1
+ 
+Ticker s1;
+Ticker s2;
+Ticker s3;
+
+  USBMIDI midi(FastSpeedInterface);
+  LCD_DISCO_F746NG lcd;
+TS_DISCO_F746NG ts;
+DigitalOut l1(D1),l2(D0),l3(D2);
+  AnalogIn Ain0(A0),Ain1(A1),Ain2(A2),Ain3(A3),Ain4(A4);
+  
+    int a0=0;
+    int a1=0;
+    int a2=0;
+    int a3=0;
+    int a4=0;
+   
+       
+    int last_a0=0;
+    int last_a1=0;
+    int last_a2=0;
+     int last_a3=0;
+    int last_a4=0;
+  
+       
+        int main(){  
+        TS_StateTypeDef TS_State;
+    
+    lcd.Clear(LCD_COLOR_WHITE);
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    
+ 
+    lcd.SetTextColor(LCD_COLOR_DARKGREEN);
+    lcd.FillEllipse(95,57,80,35);
+    
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+     lcd.FillRect(13,20,45,80);
+    
+     lcd.SetTextColor(LCD_COLOR_BLACK);
+     lcd.FillRect(200,20,90,80);
+     
+     
+  lcd.SetTextColor(LCD_COLOR_DARKRED);
+     lcd.FillCircle(390,60,45);
+     
+     
+     
+     //set lcd to select sound
+      lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(40,130,50,50);
+   
+      lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(40,210,50,50);
+    
+       lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(120,130,50,50);
+   
+      lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(120,210,50,50);
+    
+       lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(200,130,50,50);
+   
+      lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(200,210,50,50);
+    
+       lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(280,130,50,50);
+   
+      lcd.SetTextColor(LCD_COLOR_YELLOW);
+    lcd.FillRect(280,210,50,50);
+    
+    //mute midi
+    
+    lcd.SetTextColor(LCD_COLOR_ORANGE);
+    lcd.FillRect(360,155,80,80);
+    
+     
+    //write message
+     
+     lcd.SetBackColor(LCD_COLOR_DARKGREEN);
+     lcd.SetTextColor(LCD_COLOR_WHITE);
+     lcd.DisplayStringAt(75,50,(uint8_t*)"PLAY",LEFT_MODE);
+     
+      lcd.SetBackColor(LCD_COLOR_BLACK);
+     lcd.SetTextColor(LCD_COLOR_WHITE);
+     lcd.DisplayStringAt(205,50,(uint8_t*)"PAUSE",LEFT_MODE);
+     
+     lcd.SetBackColor(LCD_COLOR_DARKRED);
+     lcd.SetTextColor(LCD_COLOR_WHITE);
+     lcd.DisplayStringAt(366,55,(uint8_t*)"REC",LEFT_MODE);
+     
+     
+     lcd.SetBackColor(LCD_COLOR_ORANGE);
+     lcd.SetTextColor(LCD_COLOR_WHITE);
+     lcd.DisplayStringAt(375,187,(uint8_t*)"OFF",LEFT_MODE);
+     
+     
+     
+     lcd.SetBackColor(LCD_COLOR_YELLOW);
+     lcd.SetTextColor(LCD_COLOR_BLACK);
+     lcd.DisplayStringAt(58,145,(uint8_t*)"1",LEFT_MODE);
+     lcd.DisplayStringAt(58,225,(uint8_t*)"5",LEFT_MODE);
+     lcd.DisplayStringAt(138,145,(uint8_t*)"2",LEFT_MODE);
+     lcd.DisplayStringAt(138,225,(uint8_t*)"6",LEFT_MODE);
+     lcd.DisplayStringAt(218,145,(uint8_t*)"3",LEFT_MODE);
+     lcd.DisplayStringAt(218,225,(uint8_t*)"7",LEFT_MODE);
+     lcd.DisplayStringAt(298,145,(uint8_t*)"4",LEFT_MODE);
+     lcd.DisplayStringAt(298,225,(uint8_t*)"8",LEFT_MODE);
+           
+s2.attach(&set2,0.1);
+ while(1){
+     
+            a0=((Ain0.read()*(127))-10);
+         a1=((Ain1.read()*(-127))+5);
+         a2=((Ain2.read()*(-127))+5);
+         a3=((Ain3.read()*(-127))+10);
+         a4=((Ain4.read()*(-127))+10);
+            ts.GetState(&TS_State);
+         if((TS_State.touchDetected))
+         {
+              //Play
+              if(TS_State.touchY[0]>20&TS_State.touchY[0]<100&TS_State.touchX[0]>58&TS_State.touchX[0]<170)
+                {
+                s2.detach();
+              s3.detach();
+              s1.attach(&set3,0.3);
+              midi.write(MIDIMessage::ControlChange(7,1));
+             }
+             
+             //Pause
+             if(TS_State.touchY[0]>20&TS_State.touchY[0]<100&TS_State.touchX[0]>200&TS_State.touchX[0]<280)
+                {
+              s1.detach();
+               s3.detach();
+              s2.attach(&set2,0.1);  
+          midi.write(MIDIMessage::ControlChange(8,1));
+             } 
+             
+             //REC
+          if(TS_State.touchY[0]>20&TS_State.touchY[0]<100&TS_State.touchX[0]>345&TS_State.touchX[0]<435)
+                {
+          midi.write(MIDIMessage::ControlChange(9,1));
+            s1.detach();
+            s2.detach();
+           s3.attach(&set1,0.2);      
+             }
+             
+             // select sound
+            //1
+             if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>40&TS_State.touchX[0]<90)
+                {
+          midi.write(MIDIMessage::NoteOn(127));
+             wait(1);
+             l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             } 
+             
+             //2
+              if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>40&TS_State.touchX[0]<90)
+                {
+          midi.write(MIDIMessage::NoteOn(126));
+           wait(1);
+        l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             }
+             
+             //3 
+            if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>120&TS_State.touchX[0]<170)
+                {
+          midi.write(MIDIMessage::NoteOn(125));
+           wait(1);
+          l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             } 
+               
+               //4
+               if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>120&TS_State.touchX[0]<170)
+                {
+          midi.write(MIDIMessage::NoteOn(124));
+           wait(1);
+         l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             } 
+             
+             //5
+             if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>200&TS_State.touchX[0]<250)
+                {
+          midi.write(MIDIMessage::NoteOn(123));
+           wait(1);
+         l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             } 
+             
+             //6
+              if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>200&TS_State.touchX[0]<250)
+                {
+          midi.write(MIDIMessage::NoteOn(122));
+           wait(1);
+           l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             } 
+            
+             //7
+              if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>280&TS_State.touchX[0]<330)
+                {
+          midi.write(MIDIMessage::NoteOn(121));
+             wait(1);
+             l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             } 
+             
+             //8
+              if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>280&TS_State.touchX[0]<330)
+                {
+          midi.write(MIDIMessage::NoteOn(120));
+             wait(1);
+      l1=0;
+             wait(0.3);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.3);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+             } 
+             
+                //off
+                if(TS_State.touchY[0]>155&TS_State.touchY[0]<235&TS_State.touchX[0]>360&TS_State.touchX[0]<440)
+                {
+          midi.write(MIDIMessage::NoteOn(119));
+             wait(1);
+                   
+      l1=0;
+             wait(0.5);
+             l1=1;
+             wait(0.1);
+             l2=0;
+             wait(0.4);
+             l2=1;
+             wait(0.1);
+            l3=0;
+             wait(0.3);
+             l3=1;
+             wait(0.1);
+           
+             } 
+         }
+         
+         
+         else{
+     
+        
+         //Write MIDI
+         
+         
+         //a0
+         if(a0!=last_a0){
+             last_a0=a0;
+     
+         midi.write(MIDIMessage::ControlChange(1,a0));
+         wait(0.008);
+         }
+        //a1
+     if(a1!=last_a1){
+             last_a1=a1;
+     
+         midi.write(MIDIMessage::ControlChange(2,a1));
+         wait(0.008);
+         }
+        //a2
+         
+        if(a2!=last_a2){
+             last_a2=a2;
+     
+         midi.write(MIDIMessage::ControlChange(3,a2));
+         wait(0.008);
+       }
+       //a3
+        if(a3!=last_a3){
+             last_a3=a3;
+     
+         midi.write(MIDIMessage::ControlChange(4,a3));
+        wait(0.008);
+         }
+        //a4
+        if(a4!=last_a4){
+             last_a4=a4;
+     
+        midi.write(MIDIMessage::ControlChange(5,a4));
+        wait(0.008);
+         }
+   }}
+        } 
+         //red
+            void set1(){
+                l1=!l1;
+                l2=1;
+                l3=1;   
+             }
+             
+             //blue
+            void set2(){
+                l1=1;
+                l2=0;
+                l3=1; 
+             }
+              
+              
+              //green
+            void set3(){
+                l1=1;
+                l2=1;
+                l3=0; 
+             }
+             
+
+ 
+
+
+    
\ No newline at end of file
diff -r 000000000000 -r cb5e943e3cf8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 10 13:45:29 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file