Ver código fonte

Added more info to display (display bug needs to be tested yet)

Aareschluchtje 9 anos atrás
pai
commit
41fd547ffc
5 arquivos alterados com 38 adições e 18 exclusões
  1. 6 5
      contentparser.c
  2. 23 5
      displayHandler.c
  3. 1 1
      jsmn.c
  4. 5 4
      twitch.c
  5. 3 3
      twitch.h

+ 6 - 5
contentparser.c

@@ -176,10 +176,11 @@ void parseTwitch(char* content) {
     char name[20];
     char title[20];
     char game[20];
-    int date;
+    char date[15];
     memset(name, 0, 20);
     memset(title, 0, 20);
     memset(game, 0, 20);
+    memset(date, 0, 15);
 
     for (i = 1; i < r; i++) {
         if (jsoneq(content, &token[i], "Name") == 0) {
@@ -195,18 +196,18 @@ void parseTwitch(char* content) {
             i++;
         }
         else if (jsoneq(content, &token[i], "Date") == 0) {
-            date = getIntegerToken(content, &token[i + 1]);
+            getStringToken(content, &token[i + 1], date, 15);
             i++;
         }
     }
-    printf("%d", date);
-    if(streamid != date)
+    printf("%s", date);
+    if(strncmp(date, streamid, 15) != 0)
     {
         strcpy(data.title, title);
         strcpy(data.game, game);
         strcpy(data.name, name);
         printf("%s - %s - %s", name, title, game);
-        streamid = date;
+        strcpy(streamid, date);
         setCurrentDisplay(DISPLAY_Twitch, 100);
     }
 }

+ 23 - 5
displayHandler.c

@@ -149,10 +149,28 @@ void displayTwitter(int lineNumber,char text[])
     }
 }
 
-void displayTwitch(char name[], char title[], char game[])
-    {
-    ClearLcd();
-    LcdArrayLineOne(name, strlen(name));
-    LcdArrayLineTwo("Streaming", 9);
+void displayTwitch(char name[], char title[], char game[]) {
+
+    if (timerStruct(lastDisplayTime) % 10 < 5) {
+        ClearLcd();
+        if(strlen(name) > 16) {
+            LcdArrayLineOne(name, strlen(name));
+        }else {
+            LcdArrayLineTwo(name, 16);
+        }
+        LcdArrayLineTwo("is streaming", 12);
+    }
+    else {
+        ClearLcd();
+        if(strlen(title) > 16) {
+            LcdArrayLineOne(title, 16);
+        }else {
+            LcdArrayLineOne(title, strlen(title));
+        }if(strlen(game) > 16) {
+            LcdArrayLineTwo(game, 16);
+        }else{
+            LcdArrayLineTwo(game, strlen(game));
+        }
+    }
     LcdBackLight(LCD_BACKLIGHT_ON);
 }

+ 1 - 1
jsmn.c

@@ -340,7 +340,7 @@ void getStringToken(const char *json, jsmntok_t *tok, char *res, char maxlength)
 	if((tok->end - tok->start) < maxlength - 1){
 		sprintf(res, "%.*s", tok->end - tok->start, json + tok->start);
 	}else{
-		printf("ERROR: String to large! output string length: %d - Input string length: %d - String: %.*s \n", maxlength - 1, (tok->end - tok->start), tok->end - tok->start, json + tok->start);
+		printf("ERROR: String too large! output string length: %d - Input string length: %d - String: %.*s \n", maxlength - 1, (tok->end - tok->start), tok->end - tok->start, json + tok->start);
 		res[0] = '\0';
 	};
 }

+ 5 - 4
twitch.c

@@ -3,16 +3,17 @@
 //
 
 #include "twitch.h"
+#include <string.h>
 
-int streamid = 0;
+char streamid[15];
 struct streamdata data;
 
-void setID(int id)
+void setID(char* id)
 {
-    streamid = id;
+    strcpy(streamid, id);
 }
 
-int getID()
+char* getID()
 {
     return streamid;
 }

+ 3 - 3
twitch.h

@@ -7,9 +7,9 @@
 
 #endif //INTERNETRADIO_TWITCH_H
 
-void setID(int id);
-int getID(void);
-int streamid;
+void setID(char* id);
+char* getID(void);
+char streamid[15];
 struct streamdata data;
 
 struct streamdata