• 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 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.

    1. Define buffer for whole text plus 2 blanks at begin and end: (2+6+2)*5=50 cols
    2. Write the text once w/ leading and trailing blanks into buffer.
    3. Think about the 50 cols as a ring-buffer: after the last col, the first follows.
    4. 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):

      _0_  _1_  _2_  _3_  _4_  _5_  _6_  _7_  _8_  _9_  10 chars
     /   \/   \/   \/   \/   \/   \/   \/   \/   \/   \
     0123456789012345678901234567890123456789­0123456789 50 cols
     ----------@--@-@@@@-@----@-----@@---@---­----------  8 rows
     ----------@--@-@----@----@----@--@--@---­----------
     ----------@@@@-@@@@-@----@----@--@--@---­----------
     ----------@--@-@----@----@----@--@------­----------
     ----------@--@-@@@@-@@@@-@@@@--@@---@---­----------
     ----------------------------------------­----------
     ----------------------------------------­----------
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~
    

    First you push out the first ten columns for n times -
    10 columns starting with column 0.
    This will display nothing... obviously:

      _0_  _1_  _2_  _3_  _4_  _5_  _6_  _7_  _8_  _9_ 
     /   \/   \/   \/   \/   \/   \/   \/   \/   \/   \
     0123456789012345678901234567890123456789­0123456789
    .----------. 
    |----------|--@-@@@@-@----@-----@@---@--­-----------
    |----------|--@-@----@----@----@--@--@--­-----------
    |----------|@@@-@@@@-@----@----@--@--@--­-----------
    |----------|--@-@----@----@----@--@-----­-----------
    |----------|--@-@@@@-@@@@-@@@@--@@---@--­-----------
    |----------|----------------------------­-----------
    |----------|----------------------------­-----------
    |~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~~
    '----------'
                \
                 'Rotating' view port - begin @ col 0
    

    Then you push out n times 10 columns starting with col 1.
    This displays the left vertical of the H at the most
    right display column:

      _0_  _1_  _2_  _3_  _4_  _5_  _6_  _7_  _8_  _9_ 
     /   \/   \/   \/   \/   \/   \/   \/   \/   \/   \
     0123456789012345678901234567890123456789­0123456789
     .----------.
     |---------@|-@-@@@@-@----@-----@@---@---­----------
     |---------@|-@-@----@----@----@--@--@---­----------
     |---------@|@@-@@@@-@----@----@--@--@---­----------
     |---------@|-@-@----@----@----@--@------­----------
     |---------@|-@-@@@@-@@@@-@@@@--@@---@---­----------
     |----------|----------------------------­----------
     |----------|----------------------------­----------
     |~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~
     '----------'
                \
                 'Rotating' view port - begin @ col 1
    

    And so fort...

      _0_  _1_  _2_  _3_  _4_  _5_  _6_  _7_  _8_  _9_ 
     /   \/   \/   \/   \/   \/   \/   \/   \/   \/   \
     0123456789012345678901234567890123456789­0123456789
      .----------.
     -|--------@-|@-@@@@-@----@-----@@---@---­----------
     -|--------@-|@-@----@----@----@--@--@---­----------
     -|--------@@|@-@@@@-@----@----@--@--@---­----------
     -|--------@-|@-@----@----@----@--@------­----------
     -|--------@-|@-@@@@-@@@@-@@@@--@@---@---­----------
     -|----------|---------------------------­----------
     -|----------|---------------------------­----------
     ~|~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~
      '----------'
                \
                 'Rotating' view port - begin @ col 2
    
      _0_  _1_  _2_  _3_  _4_  _5_  _6_  _7_  _8_  _9_ 
     /   \/   \/   \/   \/   \/   \/   \/   \/   \/   \
     0123456789012345678901234567890123456789­0123456789
       .----------.
     --|-------@--|-@@@@-@----@-----@@---@---­----------
     --|-------@--|-@----@----@----@--@--@---­----------
     --|-------@@@|-@@@@-@----@----@--@--@---­----------
     --|-------@--|-@----@----@----@--@------­----------
     --|-------@--|-@@@@-@@@@-@@@@--@@---@---­----------
     --|----------|--------------------------­----------
     --|----------|--------------------------­----------
     ~~|~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~
       '----------'
                \
                 'Rotating' view port - begin @ col 3
    
      _0_  _1_  _2_  _3_  _4_  _5_  _6_  _7_  _8_  _9_ 
     /   \/   \/   \/   \/   \/   \/   \/   \/   \/   \
     0123456789012345678901234567890123456789­0123456789
        .----------.
     ---|------@--@|@@@@-@----@-----@@---@---­----------
     ---|------@--@|@----@----@----@--@--@---­----------
     ---|------@@@@|@@@@-@----@----@--@--@---­----------
     ---|------@--@|@----@----@----@--@------­----------
     ---|------@--@|@@@@-@@@@-@@@@--@@---@---­----------
     ---|----------|-------------------------­----------
     ---|----------|-------------------------­----------
     ~~~|~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~
        '----------'
                \
                 'Rotating' view port - begin @ col 4
    
      _0_  _1_  _2_  _3_  _4_  _5_  _6_  _7_  _8_  _9_ 
     /   \/   \/   \/   \/   \/   \/   \/   \/   \/   \          
     012345678 1 2345678 2 2345678 3 2345678 4 23456789
         .----------.                       .
     ----|----@--@-@|@@@-@----@-----@@---@--.­----------
     ----|----@--@-@|----@----@----@--@--@---­----------
     ----|----@@@@-@|@@@-@----@----@--@--@--.­----------
     ----|----@--@-@|----@----@----@--@------­----------
     ----|----@--@-@|@@@-@@@@-@@@@--@@---@--.­----------
     ----|----------|------------------------­----------
     ----|----------|-----------------------.­----------
     ~~~~|~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~­~~~~~~~~~~
         |0123456789|<--col 0..9 displayed  ^
         '----------'                       |
          ^      \                          |
          |       \                         m = 40 - 1
          |       'Rotating' view port - begin @ col 5
     0 .. p=5 .. m (=39) - display position p shifting thru
    

    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...

About

Avatar for allObjects @allObjects started