NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Maquee scrolling working

November 22, 2009
by Rick_S
Rick_S's Avatar

Well I finally got my marquee to scroll. May be simple for some but it was an achievement for me! :) I made a quick video in case anyone is interested.

YouTube Link

Rick

November 23, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Hey Rick that's pretty good, i'll trade you a "pipe" (python script| tr a-z A-Z | nc localhost 6667) for your code. This will run an entire web page. If you could post your code,that would be great, i'm still out in the left field, you see.

farmerjoe

November 23, 2009
by Rick_S
Rick_S's Avatar

Most of what I did was simply using what was already there. Namely the "font_display(char,offset)" function. That went pretty easy.

You can see their example in the "do_testpattern()" function where they spell out "HELLO" one letter at a time.

The sparkle effect was done by modifying the ledarray_testpattern() function as shown below.

void ledarray_testpattern() {
    uint8_t i, j, ct;
    ledarray_blank();
    // set initital pattern (every other LED on)
    for(i=0;i<ROWS;i++) {
        for(j=i%2;j<COLS;j += 2) {
        ledarray_set(i,j, 1 - ledarray_get(i,j));
        }
    }
    //wait 50ms
    delay_ms(50);

// toggle the pattern turning what was on off then back on again 10 times
for(ct=0;ct<10;ct++){
    for(i=0;i<ROWS;i++) {
        for(j=0;j<COLS;j++) {
            ledarray_set(i,j, 1 - ledarray_get(i,j));
        }
    }
    delay_ms(50);
    for(i=0;i<ROWS;i++) {
        for(j=0;j<COLS;j++) {
            ledarray_set(i,j, 1 - ledarray_get(i,j));
        }
    }
    delay_ms(50);
}

}

The hardest part for me (and it's still not quite there) was getting a word larger than would fit on the display to scroll off.

I did this by creating a new function called "scroll_display(*char)". This function was done by copying and modifying their serial scrolling function "do_scrolling_display". The function works except for scrolling off the screen. To get that to work, I pad my string I send it with trailing spaces. This works for now but I want to did deeper and "fix" that. Here's the code if you want it though.

  void scroll_display(const char *s) {
    ledarray_blank();
    int8_t offset = 0 , next_offset = 0;
    uint8_t is_started = 0;
    char x=' ';

    while(pgm_read_byte(s) != 0x00){

    if(is_started) {
    while(next_offset>23){
        delay_ms(90);
        ledarray_left_shift(); 
        if(next_offset > 0) {
            offset -= 1;
            next_offset -= 1;
        }
        font_display(x, offset); 
    }
} else {
  offset = COLS-1;
}

x = pgm_read_byte(s++);
if(is_started)
    offset = next_offset;
    font_display(x, offset);
    next_offset = offset + font_width(x)+1;
    is_started = 1;
   }
 return;
}

Sorry it's not commented. I have to go through it and do that. Bad habit of mine to just keep changing a little here and there without comments until I get something working.

To call the function, I would just do:

scroll_display(PSTR("NERD KIT      "));

and that will scroll that phrase across the screen.

Hope it works for you.

Rick

November 23, 2009
by n3ueaEMTP
n3ueaEMTP's Avatar

Cool!! My LEDs should be here tomorrow, hopefully I can get mine working without a hitch.

November 23, 2009
by Farmerjoecoledge
Farmerjoecoledge's Avatar

Excellent! as soon as my new programmer gets here she'll be sparkling, thx

November 23, 2009
by Rick_S
Rick_S's Avatar

No problem. We're all here to learn. Trust me, I'm far from being anything but a novice when it comes to C.

November 24, 2009
by Rick_S
Rick_S's Avatar

If anyone is still following this thread, I have posted a newer version of the scroll_display function in the Micro-controller programming section of the forum. I have commented the source as well as "fixed" the function so the trailing spaces are no longer needed in the strings passed to it.

Rick

Post a Reply

Please log in to post a reply.

Did you know that NerdKits make a great parent/child activity? Learn more...