Sound update

Dependencies:   4DGL-uLCD-SE Physac-MBED PinDetect SDFileSystem mbed-rtos mbed

Revision:
26:163d7ca8c42d
Parent:
25:c3eb6c1a2dfb
Child:
27:a09981ebd532
--- a/main.cpp	Thu Dec 08 00:37:55 2022 +0000
+++ b/main.cpp	Thu Dec 08 02:12:14 2022 +0000
@@ -5,7 +5,7 @@
 #include "hockey.h"
 #include "tetris.h"
 
-#include "Speaker.h"
+//#include "Speaker.h"
 #include "SDFileSystem.h"
 #include "uLCD_4DGL.h"
 
@@ -18,6 +18,7 @@
 // them here:
 volatile bool game1 = false;
 volatile bool game2 = false;
+volatile int menu_flag = 0;
 
 Serial pc(USBTX, USBRX);
 Mutex pc_mutex;
@@ -34,8 +35,8 @@
 PwmOut Rgb(p23);
 PwmOut rGb(p24);
 PwmOut rgB(p25);
-AnalogOut DACout(p18);
-wave_player waver(&DACout);
+//Speaker DACout(p18);
+//wave_player waver(&DACout);
 
 
 
@@ -54,6 +55,7 @@
 //////////////////////
 // MAIN.CPP THREADS //
 //////////////////////
+/*
 void audioThread()
 {
     while (true) {
@@ -80,7 +82,7 @@
             led2 = false;
         }
     }
-}
+}*/
 
 void ledThread()
 {
@@ -113,14 +115,15 @@
     Thread thread2(hockeyGame, osPriorityHigh);
     //Thread thread3(audioThread, osPriorityLow);
     Thread thread4(ledThread, osPriorityLow);
-    int x = 0;
+    
     // The main thread goes on to blink LEDs
     while (true) {
         led1 = 1;
         Thread::wait(500);
         led1 = 0;
         Thread::wait(500);
-        if(!game1 && !game2 && x==0){
+        if(!game1 && !game2 && menu_flag==0){
+            uLCD.cls();
             uLCD.color(WHITE);
             uLCD.text_height(2);
             uLCD.text_width(2);
@@ -132,9 +135,11 @@
             uLCD.printf("DOWN:\n");
             uLCD.printf("Air\n");
             uLCD.printf("Hockey");
-            x=1;
+            menu_flag=1;
         }
         
+        //DACout.PlayNote(50, 1.0/2.5, 0.08);
+        
         PRINTF("[MAIN] Thread stacks: %lu %lu %lu %lu\r\n",
             thread1.used_stack(),
             thread2.used_stack(),
@@ -142,11 +147,11 @@
             thread4.used_stack());
         
         // Launch into the air hockey game
-        if (game1 != true && myNav.up()){
+        if (game1 != true && game2 != true && myNav.up()){
             uLCD.cls();
             game1 = true;
             }
-        if (game2 != true && myNav.down()){
+        if (game2 != true && game1 != true && myNav.down()){
             uLCD.cls();
             game2 = true;
             }