MCPcopy Create free account
hub / github.com/BruceDevices/firmware / displayScrollingText

Function displayScrollingText

src/core/display.cpp:33–61  ·  view source on GitHub ↗

** Function name: displayScrollingText ** Description: Scroll large texts into screen ***************************************************************************************/

Source from the content-addressed store, hash-verified

31** Description: Scroll large texts into screen
32***************************************************************************************/
33void displayScrollingText(const String &text, Opt_Coord &coord) {
34 int len = text.length();
35 String displayText = text + " "; // Add spaces for smooth looping
36 int scrollLen = len + 8; // Full text plus space buffer
37 static int i = 0;
38 static long _lastmillis = 0;
39 tft.setTextColor(coord.fgcolor, coord.bgcolor);
40 if (len < coord.size) {
41 // Text fits within limit, no scrolling needed
42 return;
43 } else if (millis() > _lastmillis + 200) {
44 String scrollingPart =
45 displayText.substring(i, i + (coord.size - 1)); // Display charLimit characters at a time
46 tft.fillRect(
47 coord.x,
48 coord.y,
49 (coord.size - 1) * LW * tft.getTextSize(),
50 LH * tft.getTextSize(),
51 bruceConfig.bgColor
52 ); // Clear display area
53 tft.setCursor(coord.x, coord.y);
54 tft.setCursor(coord.x, coord.y);
55 tft.print(scrollingPart);
56 if (i >= scrollLen - coord.size) i = -1; // Loop back
57 _lastmillis = millis();
58 i++;
59 if (i == 1) _lastmillis = millis() + 1000;
60 }
61}
62
63/***************************************************************************************
64** Function name: TouchFooter

Callers 2

loopOptionsFunction · 0.85
loopSDFunction · 0.85

Calls 6

millisFunction · 0.85
setTextColorMethod · 0.45
fillRectMethod · 0.45
getTextSizeMethod · 0.45
setCursorMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected