Przeglądaj źródła

changing chanel(mp3)

sandriek 9 lat temu
rodzic
commit
ff14e8c737
3 zmienionych plików z 34 dodań i 3 usunięć
  1. 27 1
      gotosleep.c
  2. 1 0
      gotosleep.h
  3. 6 2
      main.c

+ 27 - 1
gotosleep.c

@@ -16,12 +16,13 @@ struct _fallSleep
 	struct _tm sleepTime;
 	struct _tm sleepTime;
 };
 };
 struct _tm count;
 struct _tm count;
+int i = 0;
 void setSleep()
 void setSleep()
 {
 {
 	X12RtcGetClock(&count);
 	X12RtcGetClock(&count);
 	fallSleep.sleepTime = count;
 	fallSleep.sleepTime = count;
 	fallSleep.sleepTime.tm_hour += 1;
 	fallSleep.sleepTime.tm_hour += 1;
-	playStream("62.195.226.247",80,"/test.mp3");
+	changeChanel();
 	return 1;
 	return 1;
 }
 }
 void checkSleep(int vol1)
 void checkSleep(int vol1)
@@ -29,6 +30,31 @@ void checkSleep(int vol1)
 	X12RtcGetClock(&count);
 	X12RtcGetClock(&count);
 	if(compareTime(count, fallSleep.sleepTime) == 0){
 	if(compareTime(count, fallSleep.sleepTime) == 0){
 		stopStream();
 		stopStream();
+		i = 0;
 	}
 	}
 	return 1;
 	return 1;
 }
 }
+void changeChanel(){
+	
+	if (i > 2){
+		i =1;
+	}
+	switch(i) {
+	case 0  :
+      playStream("62.195.226.247",80,"/test.mp3");
+	  i = 2;
+      break;
+   case 1  :
+	  stopStream(); 
+      playStream("62.195.226.247",80,"/test.mp3");
+	  i++;
+      break;
+	
+   case 2  :
+      stopStream(); 
+      playStream("62.195.226.247",80,"/test2.mp3");
+	  i++;
+      break;
+}
+return 1;
+}

+ 1 - 0
gotosleep.h

@@ -2,4 +2,5 @@
 #define _GoToSleep_H
 #define _GoToSleep_H
 extern void setSleep();
 extern void setSleep();
 extern void checkSleep();
 extern void checkSleep();
+extern void changeChanel();
 #endif
 #endif

+ 6 - 2
main.c

@@ -374,13 +374,17 @@ int main(void)
                 displayVolume(VOL/8);
                 displayVolume(VOL/8);
             }
             }
         }
         }
-		else if(KbGetKey() == KEY_LEFT /*the key I can use or you guys want to use, for now KEY_LEFT*/)
+		else if(KbGetKey() == KEY_LEFT)
         {
         {
             NutSleep(150);
             NutSleep(150);
-			VOL = 40;
+			VOL = 20;
 			VsSetVolume(128-VOL, 128-VOL);
 			VsSetVolume(128-VOL, 128-VOL);
             X12RtcGetClock(&timeCheck);
             X12RtcGetClock(&timeCheck);
             setSleep();
             setSleep();
+        }
+		else if(KbGetKey() == KEY_RIGHT)
+        {
+           changeChanel();
         }
         }
         else if(timerStruct(timeCheck) >= 5 && checkAlarms() == 1)
         else if(timerStruct(timeCheck) >= 5 && checkAlarms() == 1)
         {
         {