16F59 LED matrix scrolling message (3)

Somehow getting there...

After the string table addressing mode was understood, it only took one hour to let a text message skip through character by character.

Some while ago I wrote a scrolling algorithm using assembler, and this took me quite a long while. As well it is stretching over many pages. Proportional fonts are used.

In C language it can be contained with only a few lines:

Code:
if(scrollstep_ctr>200)
        {
            scrollstep_ctr=0;
            curr_msg_char=*(curr_msg_ptr+chr_curr);

            if(curr_msg_char==0)
            {chr_curr=0;
             curr_msg_char=*(curr_msg_ptr+chr_curr);
            }

            chr_curr++;

            curr_msg_char1=reloc_ascii(curr_msg_char);

            curr_chr_ptr=get_font_ptr(&alpha_chr[curr_msg_char1]);
            curr_chr_size=*curr_chr_ptr;
    
            for(i=0;i<5;i++){store_ram(16+i,0);
            display_data[display_pos[i]]=0;}

            for(i=0;i<curr_chr_size;i++)
            {store_ram(16+i,*(curr_chr_ptr+i+1));}

  
            for(i=0;i<curr_chr_size;i++)
            {display_data[display_pos[i]]=load_ram((16+(curr_chr_size-1))-i);}
        }
This is not yet the final scrolling algorithm, where 10 lines will be used, and the message data will be loaded from a RAM buffer, pre-built using the font data.

Video as usual: http://www.youtube.com/watch?v=3wX11eONllA

About 1/2 of the program memory is used up so far. So it looks promizing that indeed a text scrolling algorithm can be implemented in C on the 16F59. However it was neccessary to add external buffer RAM (2 Kbytes). Right now a parallel RAM chip is used.

Eventually it can become changed to use a serial RAM chip, if enough program memory is left. 23256 = 32 Kbyte. 2364 = 8 Kbyte. Which is far more RAM than required. One 256 byte page already can contain data for a rather long text message!

And if more text messages are used, they can be pre-computed as needed.

I have made it working today:
http://www.youtube.com/watch?v=eL_1mmmPR3k

text is scrolling through!

since a 2K Byte RAM buffer is available, the algorithm is simple.

Code:
void generate_scroll_data(unsigned char str_nr)
{const char* curr_chr_ptr;
const char* curr_msg_ptr;
unsigned char curr_msg_char,curr_chr_size,curr_chr_data,curr_chr_data1;
unsigned char ram_addr;

scroll_size=0;
ram_addr=0;
curr_msg_char=0;
curr_msg_ptr=get_font_ptr(&msg_arr[str_nr]);

while(1){
    curr_chr_data=*(curr_msg_ptr+curr_msg_char);
    if(curr_chr_data==0)break;

    curr_chr_data1=reloc_ascii(curr_chr_data);
    curr_chr_ptr=get_font_ptr(&alpha_chr[curr_chr_data1]);
    curr_chr_size=*curr_chr_ptr;

    for(i=0;i<curr_chr_size;i++)
    {
        curr_chr_data1=*(curr_chr_ptr+i+1);
        store_ram(ram_addr,curr_chr_data1);
        ram_addr++;
    }
    store_ram(ram_addr,0);
    ram_addr++;curr_msg_char++;
}scroll_size=ram_addr;
}
And to scroll the data:

Code:
void main(void)
{unsigned char ram_ptr;

    InitApp();
    generate_scroll_data(0);
    
    while(1)
    {if(TMR0>0x80){TMR0=0;refresh();scrollstep_ctr++;}

        if(scrollstep_ctr>100)
        {  scrollstep_ctr=0;
            for(i=0;i<5;i++)
            {display_data[display_pos2[i]]=load_ram((4-i)+ram_ptr);}
            ram_ptr++;if(ram_ptr>(scroll_size-5))ram_ptr=0;
        }
    }
}
However I want to use all of the display to scroll 10 lines wide. For this purpose the data must be rotated on bit-level.

Blog entry information

Author
takao21203
Views
972
Last update

More entries in General

More entries from takao21203

Share this entry

Top