-
Notifications
You must be signed in to change notification settings - Fork 171
Description
Exposing the text width and scroll position of a scrolling layer would be nice to have.
template<typename RGB, unsigned int optionFlags>
unsigned int SMLayerScrolling<RGB, optionFlags>::getTextWidth() {
return textWidth;
}
template<typename RGB, unsigned int optionFlags>
int SMLayerScrolling<RGB, optionFlags>::getPosition() {
return scrollPosition;
}
Use-case:
...
indexed.fillScreen(BLACK);
indexed.swapBuffers(true);
scroll.start("12:04pm,1);
// of course this requires that the width of the string being scrolled is less than the matrix size
while (scroll.getPosition()<MatrixWidth-scroll.getTextWidth()/2)
{}
int pos=scroll.getPosition();
scroll.stop();
indexed.drawString(pos,10,WHITE,"12:04pm");
indexed.swapBuffers(true);
delay(1000);
// yes, a delay of exactly one second would cause clock drift. It'd need something like
// xTaskDelayUntill() or elapsedMillis() to keep it timed correctly.
indexed.fillScreen(BLACK);
indexed.swapBuffers(true);
scroll.setStartOffsetFromLeft(pos);
scroll.start("12:04pm,1);
//repeat the above with "12:05pm", etc
That would make the time scroll out to centered on the screen and then "freeze." A minute later, the time starts scrolling again to the right and disappears.
Adding scroll.pause() and scroll.resume() functions as well would make the above sample even easier as there'd be no mucking about with the indexed layer and saving the position, etc. It would be just:
scroll.start("12:04pm,1);
while (scroll.getPosition()<)MatrixWidth-scroll.getTextWidth())/2)
{}
scroll.pause(); // "12:04pm" has found its Chi and is now centered and stilled in the cosmos
delay(1000);
scroll.resume(); // "12:04pm" continues its journey into oblivion to be lost forever
while (scroll.getStatus())
{}
//repeat above with "12:05pm", etc.
Other use-cases would include a sign that scrolls across "Now serving #12. Now serving #12" and as each "#12" reaches the middle, and indexed later above it prints "#12" in a different color, pauses, clears it and then resumes the scroll. Thus making it more noticeable via the blink (written as I look at my own ticket with # 4633668346 on it, sigh and try to remember if I still have that pillow in the car since I'm going to be here for a while.)