Browse Source

Twitter feed is done

MalekSediqi 9 years ago
parent
commit
38ac0e4eca
5 changed files with 37 additions and 23 deletions
  1. 1 3
      .idea/InternetRadio.iml
  2. 16 0
      Twitter.h
  3. 5 3
      contentparser.c
  4. 12 17
      displayHandler.c
  5. 3 0
      main.c

+ 1 - 3
.idea/InternetRadio.iml

@@ -1,9 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module type="CPP_MODULE" version="4">
   <component name="NewModuleRootManager">
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/CMakeLists.txt" isTestSource="false" />
-    </content>
+    <content url="file://$MODULE_DIR$" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module-library">
       <library name="Header Search Paths">

+ 16 - 0
Twitter.h

@@ -0,0 +1,16 @@
+//
+// Created by malek on 30-3-2016.
+//
+
+#ifndef INTERNETRADIO_TWITTER_H
+#define INTERNETRADIO_TWITTER_H
+
+#endif //INTERNETRADIO_TWITTER_H
+
+struct TwitterFeed TweetFeed;
+int Scroller;
+
+struct TwitterFeed{
+
+    char tweet[140];
+};

+ 5 - 3
contentparser.c

@@ -10,6 +10,7 @@
 #include "alarm.h"
 #include "displayHandler.h"
 #include "vs10xx.h"
+#include "Twitter.h"
 int streamid;
 
 void parseAlarmJson(char* content){
@@ -209,7 +210,8 @@ void parseTwitch(char* content) {
 }
 void TwitterParser(char* content)
 {
-    char* tweet = content;
-    printf("%s", tweet);
-    displayTwitter(tweet);
+    char tweet[140];
+    memset(tweet, 0, 140);
+    strcpy(TweetFeed.tweet,content);
+    printf("%s", TweetFeed.tweet);
 }

+ 12 - 17
displayHandler.c

@@ -13,7 +13,7 @@
 #include "rtc.h"
 #include "alarm.h"
 #include "network.h"
-
+#include "Twitter.h"
 struct _tm lastDisplayTime;
 viewDisplays currentViewDisplay;
 u_long displayTime;
@@ -41,6 +41,9 @@ void refreshScreen(){
         displayVolume();
     }else if(currentViewDisplay == DISPLAY_Alarm){
         displayAlarm(getRunningAlarmID());
+    }else if(currentViewDisplay == DISPLAY_Twitter)
+    {
+        displayTwitter(TweetFeed.tweet);
     }
 }
 
@@ -140,41 +143,33 @@ void displayTwitter(char* text)
 {
     //int lineNumber,char text[]
     ClearLcd();
+    LcdBackLight(LCD_BACKLIGHT_ON);
     LcdArrayLineOne("     Twitter    ", 16);
     int j = 0;
     int i;
     char text1[16];
     //char text2[140] = text;
-    int shift = 0;
+   // int shift = 0;
     //char *text = "Twitter";
-    for(i = 0; i<200;i++){
+    for(i = 0; i<140;i++){
         if (text[i] != 0){
             j++;
         }
     }
 
-    while(1) {
-
-
-        /*for (i = 0; i < 16; ++i) {
-            LcdArrayLineOne(getLoop(text, shift + i), 7);
-            shift++;
-        }*/
         for(i = 0; i < 16; i++){
-            if (text[shift+i]!= 0) {
-                text1[i] = text[shift + i];
+            if (text[Scroller+i]!= 0) {
+                text1[i] = text[Scroller + i];
             } else {
                 text1[i] = ' ';
             }
         }
-        printf("%s\n", text1);
         LcdArrayLineTwo(text1,16);
-        shift++;
-        if (shift > j){
-            shift = 0;
+        Scroller++;
+        if (Scroller > j){
+            Scroller = 0;
         }
         NutDelay(500);
-    }
 }
 
 

+ 3 - 0
main.c

@@ -331,6 +331,9 @@ int main(void)
                 }else if(KbGetKey() == KEY_UP){
                     setCurrentDisplay(DISPLAY_Volume, 5);
                     volumeUp();
+                }else if(KbGetKey() == KEY_LEFT)
+                {
+                    setCurrentDisplay(DISPLAY_Twitter,20);
                 }
             }
         }