Displaying Bitmaps
Use the ‘display_bitmap’ function. For example:-
display_bitmap(0, ec_logo_128x64, //Bitmap (flash / program memory)
DISPLAY_BITMAP_INVERT_PIXELS_OFF, //Options
0, 0); //X, Y
Available options:
DISPLAY_BITMAP_INVERT_PIXELS_OFF
DISPLAY_BITMAP_INVERT_PIXELS_ON
Displaying Text
Use the ‘display_const_string’ and ‘display_variable_string’ functions to display null terminated strings. Individual strings may be displayed as monospace or proportional width text with left, centre or right alignment. For example:
display_const_string(0, font_05x07, //Bitmap (flash / program memory)
(DISPLAY_STRING_ON_X_AXIS |
DISPLAY_STRING_INVERT_PIXELS_OFF |
DISPLAY_STRING_PROPORTIONAL |
DISPLAY_STRING_CENTER_ALIGN), //Options
20, 20, //X, Y
(CONSTANT BYTE*)"Hello World"); //String
CONSTANT BYTE sample_const_string [] = {"Hello World"};
display_const_string(0, font_05x07, //Bitmap (flash/program memory)
(DISPLAY_STRING_ON_X_AXIS |
DISPLAY_STRING_INVERT_PIXELS_OFF |
DISPLAY_STRING_MONOSPACE |
DISPLAY_STRING_LEFT_ALIGN), //Options
20, 20, //X, Y
sample_const_string); //String
BYTE sample_variable_string[12] = {"Hello World"};
display_variable_string(0, font_05x07, //Bitmap (flash/program memory)
(DISPLAY_STRING_ON_X_AXIS |
DISPLAY_STRING_INVERT_PIXELS_OFF |
DISPLAY_STRING_MONOSPACE |
DISPLAY_STRING_LEFT_ALIGN), //Options
20, 20, //X, Y
sample_variable_string); //String
Available options:
DISPLAY_STRING_INVERT_PIXELS_OFF
DISPLAY_STRING_INVERT_PIXELS_ON
DISPLAY_STRING_ON_X_AXIS
DISPLAY_STRING_ON_Y_AXIS
DISPLAY_STRING_MONOSPACE
DISPLAY_STRING_PROPORTIONAL
DISPLAY_STRING_LEFT_ALIGN
DISPLAY_STRING_CENTER_ALIGN
DISPLAY_STRING_CENTRE_ALIGN
DISPLAY_STRING_RIGHT_ALIGN
Displaying Scrolling Text
The following examples demonstrate how to use the scrolling text function.
Displaying a scrolling constant string (string stored in program memory) example
//Define the string (always include a trailing space)
CONSTANT BYTE my_string[] = {" Hello World "};
//Call this function initially with display_scroll_text_start_pixel = 0xff, and then every time you want to move the text on 1 place
void display_scrolling_text (void)
{
static CONSTANT BYTE *p_start_character = &my_string[0];
display_scroll_text_start_pixel += 1; //1 for faster scrolling)
display_scroll_text_display_pixels_count = 40; //Width of the display area
//to display within, in pixels
display_const_string(0, font_05x07, //Bitmap (flash / program memory)
(DISPLAY_STRING_ON_X_AXIS |
DISPLAY_STRING_INVERT_PIXELS_OFF |
DISPLAY_STRING_SCROLL), //Options
10, 10, //X, Y start coordinate
p_start_character); //String
if (display_scroll_1st_char_done_skip_pixels)
{
//FIRST CHARACTER HAS FALLEN OFF THE START OF THE DISPLAY
//MOVE TO NEXT ONE
p_start_character++;
if (p_start_character >= (&my_string[0] + sizeof(my_string) - 1))
p_start_character = &my_string[0];
//Reset the number of pixels to skip
if (display_scroll_1st_char_done_skip_pixels < 0xff) //(0xff = reset to zero)
display_scroll_text_start_pixel = display_scroll_1st_char_done_skip_pixels;
else
display_scroll_text_start_pixel = 0;
}
}
Displaying a scrolling variable string (string stored in ram) example
//Call this function initially with display_scroll_text_start_pixel = 0xff, and then every time you want to move the text on 1 place
void display_scrolling_text (void)
{
static BYTE my_string[] = "Hello World ";
BYTE *p_source;
BYTE *p_dest;
BYTE first_character;
display_scroll_text_start_pixel += 1; //1 for faster scrolling)
display_scroll_text_display_pixels_count = 60; //Width of the display area
//to display within, in pixels
display_variable_string(0, font_07x13, //Bitmap (flash / program memory)
(DISPLAY_STRING_ON_X_AXIS |
DISPLAY_STRING_INVERT_PIXELS_OFF |
DISPLAY_STRING_SCROLL), //Options
2, 15, //X, Y start coordinate
my_string); //String
if (display_scroll_1st_char_done_skip_pixels)
{
//FIRST CHARACTER HAS FALLEN OFF THE START OF THE DISPLAY
//MOVE IT TO THE END
p_source = &my_string[1];
p_dest = &my_string[0];
first_character = *p_dest;
while (*p_source != 0x00)
*p_dest++ = *p_source++;
*p_dest++ = first_character;
*p_dest++ = 0x00;
//Reset the number of pixels to skip
if (display_scroll_1st_char_done_skip_pixels < 0xff) //(0xff = reset to zero)
display_scroll_text_start_pixel = display_scroll_1st_char_done_skip_pixels;
else
display_scroll_text_start_pixel = 0;
}
}
This will display the string which will continuously scroll, automatically moving each character to the end of the string each time they fall off the start, so that the scrolling never resets.
Scrolling Details
The implementation of scrolling is deliberately provided in this quite raw fashion so that you can fine tune it exactly as you wish and also use the functionality to do special things if desired. These are the variables that provide the scrolling functionality when any string is displayed with the DISPLAY_STRING_SCROLL option selected:
display_scroll_text_start_pixel
This variable defines how many pixels at the start of the displayed string to ignore. You would typically incremented it each time the string is displayed.
display_scroll_text_display_pixels_count
Set to the required width you want the text to be displayed within (any extra trailing characters or part characters will not be displayed). Must be set each time the string is displayed.
display_scroll_1st_char_done_skip_pixels
This variable will contain 0 after a scrolling string has been displayed if the first character of the string is still partly displayed. If not zero then the first character of the string can be removed and the value indicates the value to reset display_scroll_text_start_pixel to (0xff = set it to zero). Although it is best for fastest processing to remove characters from the start of strings and reset display_scroll_text_start_pixel, doing this is optional and you could simply keep on incrementing display_scroll_text_start_pixel all the way to the end of the string if you wished.
Manipulation of display_scroll_text_start_pixel and display_scroll_text_display_pixels_count variables gives you the flexibility to create your own special scrolling or bespoke string display capabilities should you wish.
Scrolling Notes
Displaying fast scrolling text and large scrolling text, requires enough processing speed and a fast enough communications interface to your display to avoid scrolling being slowed. Most other display functions don’t require your hardware to be very fast, as a slight delay while a bitmap or string is displayed is barely noticed by the eye. However when moving text along pixel by pixel slowness of updating can become an issue if your hardware is not fast enough. If scrolling is too slow the following may help:
Slow the scrolling speed
Reduce the size of the text
Use fonts that are stored in a C header file (instead of an external binary file)
Enable the DISPLAY_USE_LOCAL_RAM_BUFFER define so that internal microcontroller / processor memory is used to buffer the display data, avoiding the driver having to read from the display.
Clear The Screen
display_clear_screen(0); //Clear the screen
display_clear_screen(1); //Clear the screen with all pixels on


