W R / Mbed 2 deprecated 4180_Final_Project

Dependencies:   mbed wave_player mbed-rtos 4180Final SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
trmontgomery
Date:
Wed Apr 29 01:39:39 2020 +0000
Parent:
9:c40418c26c04
Child:
11:962634a738fb
Commit message:
play no longer working

Changed in this revision

init.h 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
play.h Show annotated file Show diff for this revision Revisions of this file
--- a/init.h	Wed Apr 29 01:31:35 2020 +0000
+++ b/init.h	Wed Apr 29 01:39:39 2020 +0000
@@ -4,7 +4,7 @@
 #include "Nav_Switch.h"
 #include "SDFileSystem.h"
 #include "microphone.h"
-//#include "fireflies.h"
+#include "fireflies.h"
 #include "wave_player.h"
 #include  "rtos.h"
 
@@ -22,12 +22,8 @@
 BusOut led_strip1(p21,p22,p23); 
 BusOut led_strip2(p24,p25,p26);
 
-// Stuff for sound
-unsigned char *music = NULL;
-wave_player waver(&DACout);
-Ticker nextsample;
-volatile int sIndx = 0;
-int playMusic = 0;
+Thread thread1;
+Thread thread2; 
 
 // Globals
 int rounds = 3;
--- a/main.cpp	Wed Apr 29 01:31:35 2020 +0000
+++ b/main.cpp	Wed Apr 29 01:39:39 2020 +0000
@@ -3,19 +3,18 @@
 //      - Add more inputs/outputs
 //      - add pot to increase selector size
 //      - add sound
-#include "mbed.h"
-#include "uLCD_4DGL.h"
-#include "Nav_Switch.h"
-#include "SDFileSystem.h"
-#include "microphone.h"
-#include "fireflies.h"
-#include "wave_player.h"
-#include  "rtos.h"
 #include "play.h"
 #include "init.h"
 
 int main();
 
+// Stuff for sound
+unsigned char *music = NULL;
+wave_player waver(&DACout);
+Ticker nextsample;
+volatile int sIndx = 0;
+int playMusic = 0;
+
 // Method for ticker for sound
 void playMenuMusic() {
     if (playMusic) {
@@ -312,88 +311,7 @@
     }
 }
 
-int getScore1() {
-    myled3 = (int)(((float) micScore) / 1000.0);
-    return micScore; //int(mymic1*1000.0);
-    
-    
-    // gameType==0 for mic
-    //if (gameType == 0) {
-//        
-//    } else {
-//        
-//    }
-}
-int getScore2() {
-    return 10; //int(mymic1*1000.0);
-}
 
-void play_old() {
-     uLCD.background_color(GREEN);
-     uLCD.cls();
-     uLCD.filled_rectangle(0, 0, 200, 15, RED);
-     // header
-     uLCD.color(BLACK);
-     uLCD.locate(5,0);
-     uLCD.text_height(2);
-     uLCD.text_width(2);
-     uLCD.textbackground_color(RED);
-     uLCD.printf("PLAY");
-     uLCD.text_height(1);
-     uLCD.text_width(1);
-     uLCD.locate(14,1);
-     uLCD.printf("Rnd%1d", curRound);
-     // Scores headers
-     uLCD.textbackground_color(GREEN);
-     uLCD.color(BLUE);
-     uLCD.locate(5,3);
-     uLCD.printf("Player 1:");
-     uLCD.color(PURPLE);
-     uLCD.locate(5,11);
-     uLCD.printf("Player 2:");
-     // Scores
-     uLCD.text_height(4);
-     uLCD.text_width(4);
-     while (1) {
-        timer = 0;
-        // Blinking pause button
-        while (timer<25) {
-            if (myNav.fire()) {
-                uLCD.filled_rectangle(60, 68, 65, 82, GREEN);
-                uLCD.filled_rectangle(70, 68, 75, 82, GREEN);
-                wait(.1);
-                pause();
-            }
-            if (timer % 25 == 0) {
-                score1 = getScore1(); //(int) (pot*100.0); //curTime+1000; // int(mymic1*1000.0);
-                score2 = getScore2(); //curTime+2000;
-                uLCD.color(BLUE);
-                uLCD.locate(0,1);
-                uLCD.printf("%4d", score1);
-                uLCD.color(PURPLE);
-                uLCD.locate(0,3);
-                uLCD.printf("%4d", score2);
-                // Time bar
-                double roundTime = 15.0;  // in secs
-                int length = (int) ( (double)curTime / roundTime * 127.0);
-                uLCD.filled_rectangle(0, 65, length, 85, DGREEN);
-                if (length >= 127) {
-                    nextRound();
-                }
-                curTime++;
-            }
-            if (timer < 20){
-                uLCD.filled_rectangle(60, 68, 65, 82, LGREY);
-                uLCD.filled_rectangle(70, 68, 75, 82, LGREY);
-            } else if (timer >= 20) {
-                uLCD.filled_rectangle(60, 68, 65, 82, BLACK);
-                uLCD.filled_rectangle(70, 68, 75, 82, BLACK);
-            }
-            wait(.01);
-            timer++;
-         }
-     }
-}
 
 void highScores() {
      uLCD.background_color(ORANGE);
@@ -528,7 +446,7 @@
 
 int main() {
      // read in highScoresArr from SD card
-     /*
+     
      FILE *fp = fopen("/sd/finalProj/highscores.txt", "r");
      if(fp == NULL) {
      uLCD.printf("Error Open \n");
@@ -537,7 +455,7 @@
         fscanf(fp, "%4d", &highScoresArr[i]);
      }
      fclose(fp);
-     */
+     
      // create menu interface
      uLCD.background_color(LBLUE);
      uLCD.cls();
--- a/play.h	Wed Apr 29 01:31:35 2020 +0000
+++ b/play.h	Wed Apr 29 01:39:39 2020 +0000
@@ -1,7 +1,6 @@
 #pragma once
 #include "init.h"
 
- 
 int mic_reading1 = 0; 
 int mic_reading2 = 0; 
 float mic_read_raw = 0; 
@@ -95,7 +94,6 @@
  
 void play() {
      draw_play();
-     //Thread t1(update_leds);
      while (1) {
         round.reset();
         round.start();