Write string to oled, how to? Text draw function?

Discussion in 'Programmer's Corner' started by GoExtreme, May 15, 2018.

  1. GoExtreme

    Thread Starter New Member

    Mar 4, 2018
    After long time writing Smbus to work with SSD1306 oled and displaying a splash from predefined array, its time for Text and etc.
    I read all over internet and I see code like WriteLcd() function and similar.
    Im using EFM8 mcu and pretty much will need to write draw function from scratch. What's the process to draw text and numbers.
    Trying to display data from I2C current sensor into oled.
  2. danadak

    Well-Known Member

    Mar 10, 2018
    In a graphic display the display characters are "normally" stored in n x n bit mapped
    font in memory. So take for example a 5 x 7


    This is bit packed into memory different ways, but with a logical
    ordering, such that you can retrieve row by row or col by col
    the data to output to display. Usually done in C by using pointers.

    That's oversimplification, but is really a very basic operation of
    reading the characters data by row or col and, then outputing that
    to either a display buffer or display memory.

    Of course on display side you keep track of where you are writing
    in its memory. Usually a good practice is to clear the region you are
    going to use, then doing the writes.

    I have found to get flicker free displays a duplicate buffer to display
    is kept. When time to update the buffer is checked, if the region of
    interest in buffer has to change, then buffer and display updated for
    that region. If no change nothing is done. This cuts down dramatically
    the write activity to display which can cause display "artifacts" to occur
    due to the non synchronous nature of most displays. That is write a
    character already in display, over and over, but display internal controller
    not synched to write activity so human eye will pick up display being
    updated constantly rather than as needed.

    Regards, Dana.
    Last edited: May 15, 2018
    xox likes this.
  3. GoExtreme

    Thread Starter New Member

    Mar 4, 2018
    Hi Dana,

    I guess Im not sure how to point to corresponding letter. Lets say I have a string TEST.
    I count how much space I need and clear the space. But then how it knows T is T font?
  4. danadak

    Well-Known Member

    Mar 10, 2018
    It all depends on the display and display controller you have.
    Some you position the cursor and then write ascii value of
    char to the display for that position and the controller takes
    over and pulls from its internal memory the bitmap and updates
    its internal display buffer. Others you link in a font library for
    storage in UP FLASH, then you do the retrieves of the char
    array and pull out row by row and send to the display buffer.

    Regards, Dana.