Page 1 of 1

Continuous scroll

Posted: Sat Jan 18, 2014 7:39 am
by Brissieboy
I wanted the DMD not to wait until the message had scrolled off the display before re-starting the scroll, but to do a continuous scroll with a small gap between the end of the message and the start of the next scroll. Here's how I did it.
In DMD.cpp change this area of DMD::stepMarquee() from:

Code: Select all

  // Special case horizontal scrolling to improve speed
  if (amountY==0 && amountX==-1) {
    this->scrollHorz(amountX,false);

    // Redraw last char on screen
    int strWidth=marqueeOffsetX;
    for (byte i=0; i < marqueeLength; i++) {
      byte wide = charWidth(marqueeText[i]);
      if (strWidth+wide >= DisplayMaxX) {
        drawChar(strWidth, marqueeOffsetY,marqueeText[i],marqueeColour, marqueeBG);
        return ret;
      }
      strWidth += wide+1;
    }
  } 
to this

Code: Select all

  // Special case horizontal scrolling to improve speed
  if (amountY==0 && amountX==-1) {
    this->scrollHorz(amountX,false);

    // Redraw last char on screen
    // this is required because the scroll will move a blank line into the last position
    int strWidth=marqueeOffsetX;
    for (byte i=0; i < marqueeLength; i++) {
      byte wide = charWidth(marqueeText[i]);
      if (strWidth+wide >= DisplayMaxX) {
        drawChar(strWidth, marqueeOffsetY,marqueeText[i],marqueeColour, marqueeBG);
        return ret;
      }
      strWidth += wide+1;
    }
    // this give a continuous scroll with a gap of GAP pixels
    //  set by the (DisplayMaxX-GAP) part of the following line
    if ((marqueeWidth + marqueeOffsetX) < (DisplayMaxX-GAP)) { // GAP is the width of the gap in pixels
      drawString(DisplayMaxX,0,marqueeText,marqueeLength,marqueeColour, marqueeBG);
      marqueeOffsetX = DisplayMaxX;
    }
  }
This will now never return 'false' to indicate the end of the scroll because it never stops scrolling without some help, so you must have some way of breaking out of the loop in your sketch which contains the "ret = dmd.stepMarquee(-1,0);" task, such as checking for some other action or event or a timer etc.
This only modifies standard horizontal scrolling - no vertical or right-to-left scrolling.