The example described in the previous page is ok if the text to display is shorter then the buffer’s length; normally however you want to display longer strings.
Rather than rendering (i.e. trasform the characters to “dots”, each one corresponds to a led turned on) the whole display, you can realize that, at every step, only a column is new: the rest of the buffer is the same, just translated one column left.
So you can re-use the previous code, just update the column left to the pointer before displaying the buffer’s content:
My code performs this update in the updateDisplay() method, which gets the updated value of the column (new_byte) as a parameter:
#define S_OFF 0 #define S_LETTER 1 #define S_SPACING 2 #define S_SPACE 3 #define S_BLANK 4
The new_byte value is computed by the scroll() method.
That method is invoked at each scrolling step: the scrolling speed is defined using a constant:
#define SPACING_SIZE 1 #define SPACE_SIZE 3 #define BLANK_SIZE 7
In the main loop(), first my sketch gets the actual millis() value: this method returns the number of milliseconds elapsed since Arduino was powered on.
If the difference between this value and the value saved in the last step is more than SCROLLING_SPEED, a new scrolling step is performed:
new_byte = pgm_read_byte_near(aipointe_font + letter_offset + column_position); [...] new_byte = 0x00;