The most important element of my sketch is the finite state machine that computes the new value (new_byte) to update the buffer.
The allowed states are 5:
#define S_OFF 0 #define S_LETTER 1 #define S_SPACING 2 #define S_SPACE 3 #define S_BLANK 4
The first one (that is also the initial state) means that Arduino has nothing to show: the display is off.
The second state means the sketch is rendering a character; the third that it’s rendering the space between two characters; the forth that it’s rendering a “space” character and the fifth that it’s rendering the space between two repetitions of the string.
The transition from a step to the next one is controlled by a couple of constants, that define the length (= number of empty columns) of each type of space:
#define SPACING_SIZE 1 #define SPACE_SIZE 3 #define BLANK_SIZE 7
The code that renders a single character is similar to my previous example; while the rendering of a space is just a sequence of zero bytes:
new_byte = pgm_read_byte_near(aipointe_font + letter_offset + column_position); [...] new_byte = 0x00;
Here’s a diagram about state transitions:
I hope this tutorial helped you to create your own sketches and applications: as usual feel free to write me for any questions!