t

Dependencies:   mbed wave_player mbed-rtos C12832_lcd 4DGL-uLCD-SE LCD_fonts SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
ShelbyC22
Date:
Wed Dec 04 21:06:43 2019 +0000
Parent:
4:59b73f321c0e
Child:
6:cd24147b5e50
Commit message:
code with updated homescreen with title, bubble selection, song titles, with cheer and led light up in the beginning and plays songs after a song has been selected in main menu;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Dec 04 19:44:53 2019 +0000
+++ b/main.cpp	Wed Dec 04 21:06:43 2019 +0000
@@ -90,6 +90,7 @@
 
 volatile bool songselect = false;
 volatile bool homescreen = true;
+volatile bool songchange = false;
 uLCD_4DGL uLCD(p28,p27,p30); 
 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
 DigitalOut myled(LED1);
@@ -104,53 +105,60 @@
 AnalogIn joy_pot(p16);
 // Thread 1
 // print homescreen to LCD
+//new homescreen that doesn't have the flashing 
 void thread1(void const *args)
 {
-    
     while(true) {       // thread loop
-        
+        lcd_mutex.lock();
         if (homescreen){
-            lcd_mutex.lock();
             uLCD.cls();
-            uLCD.text_height(1.9);
+            uLCD.text_height(1.3);
             uLCD.text_width(1.9);
             uLCD.color(WHITE);
-            uLCD.locate(0,0);
+            uLCD.locate(5,0);
+            uLCD.printf("Tap Tap");
+            uLCD.locate(4,1);
+            uLCD.printf("Revolution");
+            uLCD.locate(0,3);
             uLCD.printf("Pick a song");
-            uLCD.text_height(1.9);
+            uLCD.text_height(1.3);
             uLCD.text_width(1.9);
-            //shifted over from 1 to 3 in x to make room for bubble
-            uLCD.locate(3,2);
+            uLCD.locate(3,5);
             uLCD.printf("Fireflies");
-            uLCD.locate(3,4);
+            uLCD.locate(3,7);
             uLCD.printf("The Middle");
-            uLCD.locate(3,6);
+            uLCD.locate(3,9);
             uLCD.printf("Stacy's Mom");
-            uLCD.locate(3,8);
-            uLCD.printf("I Write Sins Not Tragedies");
-            uLCD.rectangle(5, songnum*16-2, 100, songnum*16+8 ,GREEN);
+            uLCD.locate(3,11);
+            uLCD.printf("I Write Sins \n \t Not Tragedies");
+            uLCD.filled_circle(6, 43, 4, GREEN); //new selection with circle instead of rectangle
+            homescreen = false;}
+        if (songchange){
+            for (int i = 0; i < 4; i++){
+            uLCD.filled_circle(6, i*15+43, 4,BLACK);
+            }
+            uLCD.filled_circle(6, (songnum-1)*15+43, 4,GREEN);
+            songchange = false;
+            }
             lcd_mutex.unlock();
-            
-                }
-            Thread::wait(200);    
+            Thread::wait(200);
     }
 }
 
 //for song selection during homescreen
+
 void thread2(void const *args)
 {
-
    while(1){
-        if (homescreen){
             if ((joy_pot <= (1.4/3.3)) && songnum>1) {
                 songnum--;
-                } 
+                songchange = true;
+                }
             else if ((joy_pot >= (1.8/3.3)) && songnum<4){
                 songnum++;
+                songchange = true;
                 }
-            }
         Thread::wait(250);
-        
     }
 }
 
@@ -442,11 +450,12 @@
     Thread t1(thread1);
     Thread t2(thread2);
     Thread t3(thread3);
-    //startup sound. Commented out for testing without SD card
-    //FILE *wave_file;
-    //wave_file=fopen("/sd/cheer.wav","r");
-    //waver.play(wave_file);
-    //fclose(wave_file);
+    //startup sound
+    myRGBled = blue; //tested to make sure led works, we can use whatever color(s) here
+    FILE *wave_file;
+    wave_file=fopen("/sd/cheer.wav","r");
+    waver.play(wave_file);
+    fclose(wave_file);
     while(1) 
     {