Browse Source

Twitch working again

Aareschluchtje 9 năm trước cách đây
mục cha
commit
8863cd9c4c
4 tập tin đã thay đổi với 54 bổ sung11 xóa
  1. 12 9
      contentparser.c
  2. 4 2
      displayHandler.c
  3. 18 0
      twitch.c
  4. 20 0
      twitch.h

+ 12 - 9
contentparser.c

@@ -10,7 +10,7 @@
 #include "alarm.h"
 #include "displayHandler.h"
 #include "vs10xx.h"
-int streamid;
+#include "twitch.h"
 
 void parseAlarmJson(char* content){
     int r;
@@ -199,17 +199,20 @@ void parseTwitch(char* content) {
             i++;
         }
     }
+    printf("%d", date);
     if(streamid != date)
     {
+        strcpy(data.title, title);
+        strcpy(data.game, game);
+        strcpy(data.name, name);
         printf("%s - %s - %s", name, title, game);
         streamid = date;
-        displayTwitch(name, title, game);
+        setCurrentDisplay(DISPLAY_Twitch, 100);
     }
-
-}
-void TwitterParser(char* content)
-{
-    char tweet = atoi(content);
-    printf("%d", tweet);
-    displayTwitter(1,tweet);
 }
+//void TwitterParser(char* content)
+//{
+//    char tweet = atoi(content);
+//    printf("%d", tweet);
+//    displayTwitter(1,tweet);
+//}

+ 4 - 2
displayHandler.c

@@ -13,6 +13,7 @@
 #include "rtc.h"
 #include "alarm.h"
 #include "network.h"
+#include "twitch.h"
 
 struct _tm lastDisplayTime;
 viewDisplays currentViewDisplay;
@@ -41,6 +42,8 @@ void refreshScreen(){
         displayVolume();
     }else if(currentViewDisplay == DISPLAY_Alarm){
         displayAlarm(getRunningAlarmID());
+    }else if(currentViewDisplay == DISPLAY_Twitch){
+        displayTwitch(data.name, data.title, data.game);
     }
 }
 
@@ -146,9 +149,8 @@ void displayTwitter(int lineNumber,char text[])
     }
 }
 
-
 void displayTwitch(char name[], char title[], char game[])
-{
+    {
     ClearLcd();
     LcdArrayLineOne(name, strlen(name));
     LcdArrayLineTwo("Streaming", 9);

+ 18 - 0
twitch.c

@@ -0,0 +1,18 @@
+//
+// Created by aares on 30-3-2016.
+//
+
+#include "twitch.h"
+
+int streamid = 0;
+struct streamdata data;
+
+void setID(int id)
+{
+    streamid = id;
+}
+
+int getID()
+{
+    return streamid;
+}

+ 20 - 0
twitch.h

@@ -0,0 +1,20 @@
+//
+// Created by aares on 30-3-2016.
+//
+
+#ifndef INTERNETRADIO_TWITCH_H
+#define INTERNETRADIO_TWITCH_H
+
+#endif //INTERNETRADIO_TWITCH_H
+
+void setID(int id);
+int getID(void);
+int streamid;
+struct streamdata data;
+
+struct streamdata
+{
+    char title[20];
+    char name[20];
+    char game[20];
+};