Skip to content

Scrolling text for Fact  #4

@ViciousDoormat

Description

@ViciousDoormat

To fit the text on the screen, it currently has to be size 1, which is extremely small. auto-scrolling might be a nice option. Found this. Not complete but nice for inspiration:

void scrollString(String str) {
    int yoff = 1;
    display.clearDisplay();
    display.setTextWrap(false);  // we don't wrap text so it scrolls nicely
    display.setTextSize(2);
    display.setRotation(0);
    int charWidth = 12; // textsize 2 @todo auto calculate charwidth from font
    int pxwidth = (str.length()*charWidth)+32; // @todo get actual string pixel length, add support to gfx if needed
    for (int32_t x=charWidth; x>=-pxwidth; x--) {
        display.clearDisplay();
        display.setCursor(x,yoff);
        display.print(str);
        delay(150);
    }
    Serial.println("done");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions