Video Twitter Overlay

Store Forums Video Experimenter General Discussion Video Twitter Overlay

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #537
    needle
    Member

    Hi everyone,

    i’ve been playing with the VE-shield for some days now, and it’s a really fun shield! today i tried to make a twitter overlay, so i took my Ethernet shield and started programming.

    but i can’t seem to make the scroll work…
    i have tried to do the following:

    -first connect to a website
    -this website contains 1 tweet (140 characters)
    -the tweet is the last tweet with a certain #-tag
    -the website doubles the tweet so it’s layout it correctly formatted for the scroll this makes it 280 characters.

    (i’ve confirmed this to work, my arduino and ethernet shield can correctly get this information and display this on tv, with the VE shield)

    i’m almost sure the problem is where i fill my array, but i don’t know how to do this another way..

    here is my code


    #include
    #include

    TVout tv;
    int i=0;
    unsigned char x,y;


    char message[280] = "";

    char s[32];
    unsigned int n = 0;
    int index = 0;
    int messageLen = 32;
    char saveChar;

    //net
    #include
    #include
    byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x4F, 0xAF };
    byte ip[] = { 192,168,1,121 };
    byte server[] = { 195, 211, 72, 36 };
    // Initialize
    Client client(server, 80);

    void setup() {
    //tv
    tv.begin(PAL,120,96);
    initOverlay();
    tv.select_font(font6x8);

    //net
    Ethernet.begin(mac, ip);
    tv.print(0, 0, "connecting...");

    // if you get a connection, report back via serial:
    if (client.connect()) {
    tv.print(0, 10, "connected");
    // Make a HTTP request:
    client.println("GET /~deb5250/other/arduino/twit.php");
    //client.println();
    if (client.available()) {
    char c = client.read();
    message=c;

    i++;

    }
    }
    else {
    tv.print(0, 10, "connection failed");
    }

    }

    void loop()
    {
    saveChar = message[index+22];
    message[index+22] = '';

    for(int x=6;x>=0;x--) {
    if (x<6) {
    tv.delay_frame(1);
    }
    tv.print(x, 67, message+index);
    tv.print(0, 75, " ");

    }
    message[index+22] = saveChar;
    index++;
    if (index > 139) {
    index = 0;
    }

    }

    void initOverlay() {
    TCCR1A = 0;
    TCCR1B = _BV(CS10);
    TIMSK1 |= _BV(ICIE1);
    EIMSK = _BV(INT0);
    EICRA = _BV(ISC11);
    }

    ISR(INT0_vect) {
    display.scanLine = 0;
    }

    so hope you guys can help me out, it would be very much appreciated! 🙂

    #1416
    Michael
    Keymaster

    needle,
    I’m so glad you are doing this project — I’ve been meaning to do the exact same thing for months but have not gotten around to it. I hope you figure out how to get the tweets from twitter.com itself, too.

    I don’t see anything horribly wrong with the code — what behavior are you seeing? Is your tweet the full 140 chars? Does the program seem to “crash”? 280 bytes in your buffer is a lot of memory. There’s not a lot of memory to deal with in Arduino.

    #1417
    needle
    Member

    there is no problem getting the tweets from the web and into the arduino, i’ve written a small piece of PHP, that get’s the latest #-tag i specify.

    and put’s that into a single line, so i don’t have to do anything to change it inside the arduino program,

    http://195.211.72.36/~deb5250/other/arduino/twit.php

    i guess the problem is when adding characters to the message array.

    if i add it at the beginning like this:


    char message[] = "...this line is exactly a 140 character's long. like a tweet has a max. of a 140 character's. i'm almost there and only 25 chars to go.ABCDE...this line is exactly a 140 character's long. like a tweet has a max. of a 140 character's. i'm almost there and only 25 chars to go.ABCDE";

    and leave out this:



    message=c;


    so if i don’t add anything to the array but just give it a pre defined array it works very nicely…

    #1418
    Michael
    Keymaster

    Ok, I understand. I think the problem is that you are only reading in one character from the connection. Try changing:

    if (client.available())

    to

    while (client.available())

    so that it loops and fills the buffer until there are no more characters. I also think you should expand your buffer from 280 to 281 because there is probably a null character terminating the string.
    I think you are really close…

    #1420
    needle
    Member

    Ah right! that’s a good suggestion, i’ll try that asap when i get of work tomorrow 🙂 i’ll keep you posted.

    #1421
    Michael
    Keymaster

    I sure hope you blog this project, too! You’ll get a lot of attention. You could let people tweet your TV with a particular hashtag. “Tweet my TV!”

    #1422
    needle
    Member

    Alright, couldn’t sleep… so just got out of bed again, thinking about the “while”

    it didn’t work, but the following does 🙂 :

    #include 
    #include

    TVout tv;
    int i=0;
    unsigned char x,y;


    char message[280] = "";
    char s[32];
    unsigned int n = 0;
    int index = 0;
    int messageLen = 32;
    char saveChar;
    //net
    #include
    #include

    byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x4F, 0xAF };
    byte ip[] = { 192,168,1,121 };
    byte server[] = { 195, 211, 72, 36 };

    // Initialize
    Client client(server, 80);

    void setup() {
    //tv
    tv.begin(PAL,120,96);
    initOverlay();
    tv.select_font(font6x8);

    //net
    Ethernet.begin(mac, ip);
    tv.print(0, 0, "connecting...");

    // if you get a connection, report back via serial:
    if (client.connect()) {
    tv.print(0, 10, "connected");
    // Make a HTTP request:
    client.println("GET /~deb5250/other/arduino/twit.php");
    //client.println();

    }
    else {
    tv.print(0, 10, "connection failed");
    }

    }

    void loop()
    {
    if (client.available()) {
    tv.print(0, 20, "filling array");
    for(int j=0;j<=139;j++) {
    char c = client.read();
    message[j]=c;

    }
    }


    saveChar = message[index+22];
    message[index+22] = '';

    for(int x=6;x>=0;x--) {
    if (x<6) {
    tv.delay_frame(1);
    }
    tv.print(x, 67, message+index);
    tv.print(0, 75, " ");



    }
    message[index+22] = saveChar;
    index++;
    if (index > 139) {
    index = 0;

    }




    }





    void initOverlay() {
    TCCR1A = 0;
    TCCR1B = _BV(CS10);
    TIMSK1 |= _BV(ICIE1);
    EIMSK = _BV(INT0);
    EICRA = _BV(ISC11);
    }

    ISR(INT0_vect) {
    display.scanLine = 0;
    }

    http://www.youtube.com/watch?v=5xF_ASm_lo4

    now i have to change it to refresh after a X period of time….

    #1423
    Michael
    Keymaster

    Awesome! Great job.

    #1328
    Michael
    Keymaster

    Hey needle,

    This new Chumby device that allows internet content on the TV is getting a lot of attention:
    http://hackaday.com/2011/09/12/chumbys-new-netv-makes-almost-any-tv-into-an-internet-connected-device/

    I’m going to Maker Faire in NYC this weekend and I see that these Chumby guys are going to demo tweeting to a TV using their device.

    I hope you can blog about your project soon because I think it’s way more awesome to tweet to a TV using a cheap Arduino, Ethernet shield and Video Experimenter. Way more retro and cool!

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.