People Counter / Mbed 2 deprecated person_counter

Dependencies:   mbed mbed-rtos 4DGL-uLCD-SE HC_SR04_Ultrasonic_Library

Revision:
20:1dc516a6a941
Parent:
19:c78aafa613b8
Child:
21:4fef6bf7582c
--- a/main.cpp	Sun Apr 26 19:07:20 2020 +0000
+++ b/main.cpp	Sun Apr 26 20:28:51 2020 +0000
@@ -16,8 +16,8 @@
 //Serial BT(p9,p10);
 
 //waiting to figure out if sd card works
-//AnalogOut speaker(p18);         //Initialize speaker
-//wave_player waver(&speaker);    //Initialize Waveplayer
+AnalogOut speaker(p18);         //Initialize speaker
+wave_player waver(&speaker);    //Initialize Waveplayer
 
 Mutex serial_mutex;
 Mutex dist;
@@ -34,11 +34,12 @@
                 };
 float note3[2]= {1244.5, 0.0
                 };
-float duration[2]= {1, 0.0
+float duration[2]= {0.5, 0.0
                    };
                    
 volatile int values[5] = {0,0,0,0,0};
 volatile int index = 0;
+volatile float volume = 1.0;
 volatile bool allZero = true;
 volatile bool movingTowards = false;
 volatile bool movingAway = false;
@@ -148,13 +149,13 @@
                     //if(wave_file==NULL) {printf("file open error!\n\n\r");}
                     //waver.play(wave_file);
                     //fclose(wave_file);
-                    mySpeaker.PlaySong(note1,duration);
+                    mySpeaker.PlaySong(note1,duration,volume);
                     break;
                 case 2:
-                    mySpeaker.PlaySong(note2,duration);
+                    mySpeaker.PlaySong(note2,duration,volume);
                     break;
                 case 3:
-                    mySpeaker.PlaySong(note3,duration);
+                    mySpeaker.PlaySong(note3,duration,volume);
                     break;
                 default:
                     printf("Invalid Choice\r\n");
@@ -206,6 +207,7 @@
                                 break;
                             case '4': //number button 4
                                 if (bhit=='1') {
+                                    musicChoice = 3;
                                     //add hit code here
                                 } else {
                                     //add release code here
@@ -213,13 +215,14 @@
                                 break;
                             case '5': //button 5 up arrow
                                 if (bhit=='1') {
-                                    musicChoice = 3;
+                                    volume += .1;
                                 } else {
                                     //add release code here
                                 }
                                 break;
                             case '6': //button 6 down arrow
                                 if (bhit=='1') {
+                                    volume -= .1;
                                     //add hit code here
                                 } else {
                                     //add release code here
@@ -242,6 +245,14 @@
                             default:
                                 break;
                         }
+                        if(volume > 1)
+                        {
+                            volume = 1;
+                        }
+                        if(volume < 0)
+                        {
+                            volume = 0;
+                        }
                     }
                 }
             }
@@ -301,7 +312,6 @@
         if (state == 1 && allZero){
             state = 0;
         }
-        printf("State %d\r\n", state);
         //MyLED = !MyLED;
         Thread::wait(100);
     }