Преглед на файлове

Gotosleep

not tested yet, temporarily on left key but can be changed, and stream
is just hardcoded for now.
sandriek преди 10 години
родител
ревизия
1e3769a73f
променени са 3 файла, в които са добавени 46 реда и са изтрити 0 реда
  1. 34 0
      gotosleep.c
  2. 5 0
      gotosleep.h
  3. 7 0
      main.c

+ 34 - 0
gotosleep.c

@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/thread.h>
+#include <sys/timer.h>
+#include <sys/version.h>
+#include <dev/irqreg.h>
+#include "log.h"
+#include "rtc.h"
+#include "alarm.h"
+#include "display.h"
+#include "httpstream.h"
+
+struct _fallSleep
+{
+	struct _tm sleepTime;
+};
+struct _tm count;
+void setSleep()
+{
+	X12RtcGetClock(&count);
+	fallSleep.sleepTime = count;
+	fallSleep.sleepTime.tm_hour += 1;
+	playStream("62.195.226.247",80,"/test.mp3");
+	return 1;
+}
+void checkSleep()
+{
+	X12RtcGetClock(&count);
+	if(compareTime(count, fallSleep.sleepTime) >= 4){
+		stopStream();
+	}
+	return 1;
+}

+ 5 - 0
gotosleep.h

@@ -0,0 +1,5 @@
+#ifndef _GoToSleep_H
+#define _GoToSleep_H
+extern void setSleep();
+extern void checkSleep();
+#endif

+ 7 - 0
main.c

@@ -373,9 +373,16 @@ int main(void)
                 VsSetVolume(128-VOL, 128-VOL);
                 displayVolume(VOL/8);
             }
+        }
+		else if(KbGetKey() == KEY_LEFT /*the key I can use or you guys want to use, for now KEY_LEFT*/)
+        {
+            NutSleep(150);
+            X12RtcGetClock(&timeCheck);
+            setSleep();
         }
         else if(timerStruct(timeCheck) >= 5 && checkAlarms() == 1)
         {
+			checkSleep();
 			for (idx = 0; idx < 5; idx++){
 				if (getState(idx) == 1){
 					displayAlarm(0,1,idx);