Преглед изворни кода

Merge remote-tracking branch 'origin/TwitterFeed' into Twitch

Conflicts:
	contentparser.c
	contentparser.h
	displayHandler.h
	main.c
Aareschluchtje пре 9 година
родитељ
комит
84895b8af6
6 измењених фајлова са 36 додато и 26 уклоњено
  1. 18 19
      contentparser.c
  2. 1 0
      contentparser.h
  3. 11 1
      displayHandler.c
  4. 1 1
      displayHandler.h
  5. 4 4
      main.c
  6. 1 1
      vs10xx.c

+ 18 - 19
contentparser.c

@@ -106,10 +106,8 @@ void parsetimezone(char* content)
     setTimeZone(timezone);
 }
 
-void parseTwitch(char* content)
-{
-    if(!strcmp("null", content))
-    {
+void parseTwitch(char* content) {
+    if (!strcmp("null", content)) {
         printf("Nobody is streaming");
         return;
     }
@@ -119,11 +117,11 @@ void parseTwitch(char* content)
     jsmntok_t token[20]; /* We expect no more than 20 tokens */
 
     jsmn_init(&p);
-    r = jsmn_parse(&p, content, strlen(content), token, sizeof(token)/sizeof(token[0]));
+    r = jsmn_parse(&p, content, strlen(content), token, sizeof(token) / sizeof(token[0]));
     if (r <= 0) {
         printf("Failed to parse JSON: %d \n", r);
         return;
-    }else{
+    } else {
         printf("Aantal tokens found: %d \n", r);
     }
 
@@ -134,25 +132,20 @@ void parseTwitch(char* content)
     memset(title, 0, 30);
     memset(game, 0, 20);
 
-    for(i = 1; i < r; i++)
-    {
-        if(jsoneq(content, &token[i], "Name") == 0)
-        {
-            getStringToken(content, &token[i+1], name, 20);
+    for (i = 1; i < r; i++) {
+        if (jsoneq(content, &token[i], "Name") == 0) {
+            getStringToken(content, &token[i + 1], name, 20);
             i++;
         }
-        else if(jsoneq(content, &token[i], "Title") == 0)
-        {
-            getStringToken(content, &token[i+1], title, 30);
+        else if (jsoneq(content, &token[i], "Title") == 0) {
+            getStringToken(content, &token[i + 1], title, 30);
             i++;
         }
-        else if(jsoneq(content, &token[i], "Game") == 0)
-        {
-            getStringToken(content, &token[i+1], game, 20);
+        else if (jsoneq(content, &token[i], "Game") == 0) {
+            getStringToken(content, &token[i + 1], game, 20);
             i++;
         }
-        else if(jsoneq(content, &token[i], "Date") == 0)
-        {
+        else if (jsoneq(content, &token[i], "Date") == 0) {
             //convert date to int
         }
     }
@@ -161,3 +154,9 @@ void parseTwitch(char* content)
 
     displayTwitch(name, title, game);
 }
+void TwitterParser(char* content)
+{
+    char tweet = atoi(content);
+    printf("%d", tweet);
+    displayTwitter(1,tweet);
+}

+ 1 - 0
contentparser.h

@@ -7,5 +7,6 @@
 void parseAlarmJson(char* content);
 void parsetimezone(char* content);
 void parseTwitch(char* content);
+void TwitterParser(char* content);
 
 #endif //CONTENTPARSER_H

+ 11 - 1
displayHandler.c

@@ -121,6 +121,16 @@ void displayVolume(int pos)
         LcdArrayLineTwo(characters,pos);
 }
 
+void displayTwitter(int lineNumber,char text[])
+{
+    ClearLcd();
+    int i;
+
+    if (lineNumber > -1 && lineNumber < 2){
+        (*write_display_ptr[lineNumber])(text,strlen(text));
+    }
+}
+
 
 void displayTwitch(char name[], char title[], char game[])
 {
@@ -137,4 +147,4 @@ bool isDisplayingCustomMessage(){
 
 void setDisplayingCustomMessage(bool value){
     displayingCustomMessage = value;
-}
+}

+ 1 - 1
displayHandler.h

@@ -13,5 +13,5 @@ void displayVolume(int pos);
 void displayTwitch(char name[], char title[], char game[]);
 bool isDisplayingCustomMessage();
 void setDisplayingCustomMessage(bool value);
-
+void displayTwitter(int lineNumber,char text[]);
 #endif //MUTLI_OS_BUILD_DISPLAYHANDLER_H

+ 4 - 4
main.c

@@ -262,8 +262,6 @@ int checkOffPressed(){
     }
 }
 
-
-
 int main(void)
 {
 	initialized = 0;
@@ -394,7 +392,9 @@ int main(void)
 						setSnooze(idx);
 						LcdBackLight(LCD_BACKLIGHT_OFF);
                         stopStream();
-					}
+					}else if(KbGetKey() == KEY_LEFT)
+                    {
+                    }
 				}
 			}
 		}else if(isDisplayingCustomMessage() == true){
@@ -413,4 +413,4 @@ int main(void)
         WatchDogRestart();
     }
     return(0);
-}
+}

+ 1 - 1
vs10xx.c

@@ -505,7 +505,7 @@ int VsPlayerKick(void)
          *  for the VS1003 we need an extra reset
          *  here before we start playing a stream...
          */
-        VsPlayerSetMode(VS_SM_RESET);
+         VsPlayerSetMode(VS_SM_RESET);
 //        NutDelay(10);
 //        LogMsg_P(LOG_DEBUG,PSTR("Kick: CLOCKF = [0x%02X]"),VsRegRead(VS_CLOCKF_REG));
 //        LogMsg_P(LOG_DEBUG,PSTR("Kick: CLOCKF = [0x%02X]"),VsRegRead(VS_CLOCKF_REG));