I made various LED matrix scrolling message circuits.
Now I am trying to simplify the algorithm, and shorten the source code.
Here's the old version:
The problems:
-The font data is stored in a space saving format. Since the height is 5 lines only, the 5 lower bits of a byte are used for font data, and the 3 high bits for the character width.
-The characters have different width.
-The LED matrix can have different sizes, not a multiple of 8
-The data from the font table must be copied in a way bit 1 from vertical line 1 -> display horizontal line 0, pos 0, bit 7; bit 2 -> display horizontal line 1, pos 0, bit 7
then the next vertical line is bit 6 and so on.
After each 8 bits on the matrix, +1 to pos. as offset
And here's the new code
I havent tested it yet, one of my questions is shifting in for loops. possible in this way?
Now I am trying to simplify the algorithm, and shorten the source code.
Here's the old version:
Code:
if(scrollstep_ctr>50)
{ scrollstep_ctr=0;
for(i=0;i<scroll_mem_size;i++)display_data[i]=0;
bitno=0;
ram_addr=(scroll_dsp_size-1)+ram_ptr;
bp_bit=0x1;
for(i=0;i<scroll_dsp_size;i++)
{
led_matrix_off();
ram_set_addr(ram_addr--,3);buffer=load_ram(0);
led_matrix_on();
binmsk=1;
bp_byte=0;
if(i>4)bp_byte=1;
if(i>9)bp_byte=2;
for(i3=0;i3<5;i3++)
{
if(buffer&binmsk)display_data[bp_byte]|=bp_bit;
bitno++;
binmsk<<=1;
bp_byte+=3;
}
if(bp_bit<0x10)bp_bit<<=1;else bp_bit=0x1;
}
ram_ptr++;if(ram_ptr>(scroll_size-(scroll_dsp_size+2)))ram_ptr=0;
}
-The font data is stored in a space saving format. Since the height is 5 lines only, the 5 lower bits of a byte are used for font data, and the 3 high bits for the character width.
-The characters have different width.
-The LED matrix can have different sizes, not a multiple of 8
-The data from the font table must be copied in a way bit 1 from vertical line 1 -> display horizontal line 0, pos 0, bit 7; bit 2 -> display horizontal line 1, pos 0, bit 7
then the next vertical line is bit 6 and so on.
After each 8 bits on the matrix, +1 to pos. as offset
And here's the new code
Code:
void copy_scroll(uint offs,uint bmp_offs, uchar mask_min)
{uchar* ram_ptr;uchar* dsp_ptr;uchar i,i2;
ram_ptr=bitmap+bmp_offs;dsp_ptr=display_ptr+offs;
for(i=0x80;(i>0)&&(i>mask_min);i>>=1);
{for(i2=1;i2<0x20;i2<<=1)
{if((*ram_ptr++)&i2)*dsp_ptr|=i;else *dsp_ptr&=0xff-i;
dsp_ptr+=display_bytes_width;
}}}
void copy_scroll_10(){copy_scroll(0,0,0);copy_scroll(1,8,0x20);}