I used the approach of putting out column by column because I know about some of your applications that implement one line of a running text... To finally implement that, it becomes extremely simple:
Think about you want to run the text Hello! over and over *** smoothly *** - pixel by
pixel column - through a display that can show two (2) characters only... in other words, the display has 10 columns of dots - or two 6x4 (fixed) font characters with one pixel space between characters.
Define buffer for whole text plus 2 blanks at begin and end: (2+6+2)*5=50 cols
Write the text once w/ leading and trailing blanks into buffer.
Think about the 50 cols as a ring-buffer: after the last col, the first follows.
Have a 'rotating' view port of 10 cols running over the ring of 40 cols.
Regarding point 3: it is actually only 40 cols you shift thru, but with every position
you show 10 cols. To make algorithm life simple - as shown at the end - that's what the
leading and trailing spaces (blank characters) are for. So bear with me.
I try to show what is going on in 'character graphics' below.
After writing to the buffer with a 6x4 font and 1
col character spacing, it looks like this (@=1,
all others=0 bits):
I guess this is enough to show - and see - what is going on...
With this setup, the algorithm becomes very very simple
(b is the buffer):
// " HELLO! " - 2+6+2=10 chars is 50 cols pixels with
// 6x4 font + 1 pixel char space displayed in 2x 7x5 matrix
var n = 10; // times to 'scan' every frame that is pushed
var m = 40; // m buffer col begins to shift thru (0..39)
var w = 10; // w cols displayed at once (8x10 display)
var p = -1, i, j, k, s = n - 1;
function scan() {
if (++s>=n) {
s = 0;
if (++p>=m) {
p = 0; // start over
}
}
i = p - 1; k = -1; // i byte to put out
while (++k<w) { i++; // k col in view port
// push b[i] out
}
}
setInterval(scan,20);
The lower n, the faster the text shifts thru...
Conclusion: Single line text plus as many blanks before and
after that can be displayed at once in the display defines
the buffer size. So any text length can be displayed shifting
thru the display.
m
PS: Sorry, the show and tell on my almost 40 years old DIY LED matrix has to wait another post...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Eric, it all depends...
I used the approach of putting out column by column because I know about some of your applications that implement one line of a running text... To finally implement that, it becomes extremely simple:
Think about you want to run the text
Hello!
over and over *** smoothly *** - pixel bypixel column - through a display that can show two (2) characters only... in other words, the display has 10 columns of dots - or two 6x4 (fixed) font characters with one pixel space between characters.
Regarding point 3: it is actually only 40 cols you shift thru, but with every position
you show 10 cols. To make algorithm life simple - as shown at the end - that's what the
leading and trailing spaces (blank characters) are for. So bear with me.
I try to show what is going on in 'character graphics' below.
After writing to the buffer with a 6x4 font and 1
col character spacing, it looks like this (@=1,
all others=0 bits):
First you push out the first ten columns for n times -
10 columns starting with column 0.
This will display nothing... obviously:
Then you push out n times 10 columns starting with col 1.
This displays the left vertical of the
H
at the mostright display column:
And so fort...
I guess this is enough to show - and see - what is going on...
With this setup, the algorithm becomes very very simple
(b is the buffer):
The lower n, the faster the text shifts thru...
Conclusion: Single line text plus as many blanks before and
after that can be displayed at once in the display defines
the buffer size. So any text length can be displayed shifting
thru the display.
PS: Sorry, the show and tell on my almost 40 years old DIY LED matrix has to wait another post...