** Function name: displayScrollingText ** Description: Scroll large texts into screen ***************************************************************************************/
| 31 | ** Description: Scroll large texts into screen |
| 32 | ***************************************************************************************/ |
| 33 | void 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 |
no test coverage detected