scrolling performance

in a watch widget I am trying to make some scrolling.

it works but the refresh is slow and the scroll speed also !

what are the best way to do it.

  • Ok, so first of all, scowling WHAT?  Scrolling through glances, scrolling through pages when you are in full screen mode, having text scroll right to left?

  • If you mean scrolling text horizontally, I've had ok results using a 50 ms update timer (which is the fastest timer possible), and scrolling by 2 pixels for every update. (This is on the lower-resolution MIP devices - on AMOLED devices, you may have to scroll by more 2 than pixels per update to get an acceptable scroll speed.)

    Here's some example code and a video captured from the simulator:

    https://forums.garmin.com/developer/connect-iq/f/discussion/258627/anybody-have-example-of-sliding-text/1235847#1235847

    Here's a video of a real device:

    forums.garmin.com/.../1497375

  • I've got a view in my widget which need to display lot's of lines of info.

    I scroll through it with next/prev (scrolling vertically, but can be changed to be right/left if needed)

    but for now it's painlessly slow

  • You want to post the code for how you are doing this now for help with speeding it up.

  • here are the main parts :

    function onUpdate(dc) {
            //System.println("view hour onUpdate");
            // Call the parent onUpdate function to redraw the layout
            View.onUpdate(dc);
              
             // clear the screen
            dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_BLACK);
            dc.clear();
    
            // drawing !
    		dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
            //TODO: check scroll bug ?
    
            var tides = _tideData[5]["data"];
            if (tides != null) {
                var y = _scrollpos;
                //System.println("elem : "+ tides.size());
                
                for(var h = 0; h < tides.size(); h++) {              
                    // color for current hur
                    y = drawHourly(dc,mWidth * 0.1 , y /* h *30 + _scrollpos  /*64*/ , tides[h]);                    
                }       
            }
                
            //System.println("view hour onUpdate - out");
        }

    and more elements : 

        function scrollup() {
            _scrollpos += 60;
            if (_scrollpos> 0) {  // 24*80 ?
                _scrollpos = 0;
            }
            System.println("scroll : " + _scrollpos);
            WatchUi.requestUpdate();
        }
    
           function scrolldown() {
            _scrollpos -= 60;
            if (_scrollpos< -1900) {
                _scrollpos = -1900;
            } 
            System.println("scroll : " +_scrollpos);
            WatchUi.requestUpdate();
        }
        
        
          // scroll down
    	function onNextPage() {
            //System.println("openTideWidgetHourViewDelegate scroll down");
            _view.scrolldown();
            
            return true;       
        }
        
        

    hope this can help

  • This looks pretty optimized to me. A suggestion would be to define your `tides` variable somewhere other than onUpdate(), so that you don't have to keep retrieving the same value every time the user scrolls.

    If the scroll is taking a long time, your drawHourly function must be doing some pretty time consuming things. Have you tried optimizing that?

  • How can I profile to optimisze it ?

  • in the sim, File>View Profiler

  • have  try this, but didn't understand how to interprete/use the result !