Ce code contient un jeu relié à un micro. Il faut alors souffler sur le micro pour augmenter une jauge et tuer le personnage situé en haut de l'écran, et ensuite passé au niveau suivant. Le micro contient 4 broches, dont 1 broche de sortie analogique (valeurs entre 0 et 1). Cette broche est relié à la pin A0 de la carte MBED.

Dependencies:   TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG

Files at this revision

API Documentation at this revision

Comitter:
FionaLebel
Date:
Tue Jun 04 14:13:48 2019 +0000
Commit message:
version finale

Changed in this revision

BSP_DISCO_F746NG.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 e77d6ddce807 BSP_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Tue Jun 04 14:13:48 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/BSP_DISCO_F746NG/#df2ea349c37a
diff -r 000000000000 -r e77d6ddce807 LCD_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Tue Jun 04 14:13:48 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
diff -r 000000000000 -r e77d6ddce807 TS_DISCO_F746NG.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TS_DISCO_F746NG.lib	Tue Jun 04 14:13:48 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
diff -r 000000000000 -r e77d6ddce807 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 04 14:13:48 2019 +0000
@@ -0,0 +1,236 @@
+#include "mbed.h"
+#include "LCD_DISCO_F746NG.h"
+#include "TS_DISCO_F746NG.h"
+#include <string>
+
+LCD_DISCO_F746NG lcd;
+TS_DISCO_F746NG ts;
+DigitalOut led1(LED1);
+AnalogIn in(A0);
+Serial pc(USBTX, USBRX, 9600);
+
+int main()
+{
+    TS_StateTypeDef TS_State;
+    ts.Init(200,200);
+    int niveau =1;
+    float volume = 0.00;
+    int compteurJauge=0;
+    char volumeChar[12]={0};
+    int etat = 1;
+
+    lcd.Clear(LCD_COLOR_WHITE);
+    lcd.SetBackColor(LCD_COLOR_WHITE);
+    lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"CAPTEUR SONORE", CENTER_MODE);
+    lcd.SetTextColor(LCD_COLOR_WHITE);
+    lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+    lcd.DisplayStringAt(0, LINE(7), (uint8_t *)"Play", CENTER_MODE);
+
+    while(1) {
+         
+        ts.GetState(&TS_State);
+        if ((TS_State.touchDetected) && (TS_State.touchX[0] > 190 && TS_State.touchX[0] < 290 && TS_State.touchY[0]<210 && TS_State.touchY[0]>160 ))
+        {
+            led1 = 1;
+            lcd.Clear(LCD_COLOR_WHITE);
+            
+            while(1){
+                
+                 switch(etat){
+                    case 1: 
+                volume = in.read();
+                pc.printf("Volume ana = %f \r\n", volume);
+                wait(0.3);
+                sprintf(volumeChar, "%0.4f", volume);
+                lcd.Clear(LCD_COLOR_WHITE);
+                lcd.SetBackColor(LCD_COLOR_WHITE);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10), (uint8_t *)volumeChar, RIGHT_MODE);
+                    
+                        
+              
+                lcd.SetBackColor(LCD_COLOR_WHITE);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Tuer Arthur", CENTER_MODE);
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_WHITE);
+                lcd.DisplayStringAt(0, LINE(3), (uint8_t *)"Arthur", CENTER_MODE);                          
+            
+            if (volume>0.00 && volume<0.05)
+            {
+                for (int i=0; i<1;i++){
+        
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+            }
+            else if (volume>0.05 && volume<0.08){
+                 for (int i=0; i<2;i++){
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+            else if (volume>0.08 && volume<0.1){
+                for (int i=0; i<3;i++){
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+                else if (volume>0.2 && volume<0.4){
+               for (int i=0; i<4;i++){
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+                
+                else if (volume>0.4 && volume<0.6){
+        for (int i=0; i<5;i++){
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+                
+                 else if (volume>0.6 && volume<0.8){
+             for (int i=0; i<6;i++){
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+            
+                 }
+             else if (volume>0.8 && volume<0.9){
+               for (int i=0; i<7;i++){
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+        
+        }
+        else if (volume>0.9 && volume<1){
+            for (int i=0; i<9;i++){
+                lcd.SetBackColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+        
+
+        }
+        else if(volume==1.0){
+                lcd.Clear(LCD_COLOR_WHITE);
+                lcd.SetBackColor(LCD_COLOR_WHITE);
+                lcd.SetTextColor(LCD_COLOR_LIGHTMAGENTA);
+                lcd.DisplayStringAt(0, LINE(5),(uint8_t *) "VOUS AVEZ TUE ARTHUR BRAVO", CENTER_MODE);
+                wait(5);
+                etat =2;
+            }
+            
+            break;
+            
+            case 2:
+            volume = in.read();
+                pc.printf("Volume ana = %f \r\n", volume);
+                wait(0.3);
+                sprintf(volumeChar, "%0.4f", volume);
+                lcd.Clear(LCD_COLOR_WHITE);
+                lcd.SetBackColor(LCD_COLOR_WHITE);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10), (uint8_t *)volumeChar, RIGHT_MODE);
+                    
+                        
+              
+                lcd.SetBackColor(LCD_COLOR_WHITE);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(1), (uint8_t *)"Tuer Bastien", CENTER_MODE);
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_WHITE);
+                lcd.DisplayStringAt(0, LINE(3), (uint8_t *)"Bastien", CENTER_MODE);                          
+            
+            if (volume>0.00 && volume<0.05)
+            {
+                for (int i=0; i<1;i++){
+        
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+            }
+            else if (volume>0.05 && volume<0.08){
+                 for (int i=0; i<2;i++){
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+            else if (volume>0.08 && volume<0.1){
+                for (int i=0; i<3;i++){
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+                else if (volume>0.2 && volume<0.4){
+               for (int i=0; i<4;i++){
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+                
+                else if (volume>0.4 && volume<0.6){
+        for (int i=0; i<5;i++){
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+                }
+                
+                 else if (volume>0.6 && volume<0.8){
+             for (int i=0; i<6;i++){
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+            
+                 }
+             else if (volume>0.8 && volume<0.9){
+               for (int i=0; i<7;i++){
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+        
+        }
+        else if (volume>0.9 && volume<1){
+            for (int i=0; i<9;i++){
+                lcd.SetBackColor(LCD_COLOR_RED);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(10-i), (uint8_t *)"     ", CENTER_MODE);
+            }
+        
+
+        }
+        else if(volume==1.0){
+                lcd.Clear(LCD_COLOR_WHITE);
+                lcd.SetBackColor(LCD_COLOR_WHITE);
+                lcd.SetTextColor(LCD_COLOR_RED);
+                lcd.DisplayStringAt(0, LINE(5),(uint8_t *) "VOUS AVEZ TUE BASTIEN BRAVO", CENTER_MODE);
+                wait(5);
+            }
+            break;
+        
+            
+            }
+          
+    
+        }
+        
+    }
+}
+
+ } 
diff -r 000000000000 -r e77d6ddce807 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 04 14:13:48 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file