I want to scroll text sideways and do it as smooth as possible. With 50ms timer delay on simulator text scrolls quite smooth, but on actual device fps are well below 60fps. If i request update at the end of onUpdate() on simulator text line scrolls way too fast, but on VivoActive 4 it seems smooth. Is it right approach, because i don't have ability to test on other devices.
function onUpdate(dc as Dc) as Void { dc.setColor(0xffffff, 0xffffff); dc.clear(); DrawUtils.drawHeaderAndFooter(stopInfo[:name], drawStopIndicator, up, down, dc); dc.setClip(DrawUtils.clipX, DrawUtils.clipY, DrawUtils.clipWidth, DrawUtils.clipHeight); dc.setColor(0x000000, 0xffffff); var printedLines = 0; for (var i = $.pageIndex * 4; printedLines < 4 && i < stopInfo[:busID].size(); i++) { scrollLines[printedLines].updateText(dc); printedLines++; } dc.clearClip(); DrawUtils.drawTimes(stopInfo, dc); // Ui.requestUpdate(); scrollTimer.start(method(:trigerUiUpdate), 50, false); }
function updateText(dc) { dc.drawText(x + currentPos, y, font, text, Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER); if (isStatic == false) { currentPos -= 2; if (currentPos < -textWidth - loopSpace) { currentPos = 0; } } }
function drawTimes() (garmin dont allow to paste it here )