gotosleep.c 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <assert.h>
  4. #include <sys/thread.h>
  5. #include <sys/timer.h>
  6. #include <sys/version.h>
  7. #include <dev/irqreg.h>
  8. #include "log.h"
  9. #include "rtc.h"
  10. #include "alarm.h"
  11. #include "display.h"
  12. #include "httpstream.h"
  13. #include "gotosleep.h"
  14. struct _fallSleep
  15. {
  16. struct _tm sleepTime;
  17. };
  18. struct _tm count;
  19. int i = 0;
  20. void setSleep()
  21. {
  22. X12RtcGetClock(&count);
  23. fallSleep.sleepTime = count;
  24. fallSleep.sleepTime.tm_hour += 1;
  25. changeChanel();
  26. return 1;
  27. }
  28. void checkSleep(int vol1)
  29. {
  30. X12RtcGetClock(&count);
  31. if(compareTime(count, fallSleep.sleepTime) == 0){
  32. stopStream();
  33. i = 0;
  34. }
  35. return 1;
  36. }
  37. void changeChanel(){
  38. if (i > 2){
  39. i =1;
  40. }
  41. switch(i) {
  42. case 0 :
  43. playStream("62.195.226.247",80,"/test.mp3");
  44. i = 2;
  45. break;
  46. case 1 :
  47. stopStream();
  48. playStream("62.195.226.247",80,"/test.mp3");
  49. i++;
  50. break;
  51. case 2 :
  52. stopStream();
  53. playStream("62.195.226.247",80,"/test2.mp3");
  54. i++;
  55. break;
  56. }
  57. return 1;
  58. }