Static -vs- Dynamic Content

I've been doing all my screen rendering in onUpdate(), which paints the screen about every second. But it seems that static objects should only be rendered in onShow(). No need to waste the compute cycles to redraw things that don't change every second. Except the docs for DC say only render to the screen in onUpdate(). So I tried to get clever and create a paintScreen boolean in onShow and conditionally write static content in onUpdate() only after a onShow call. But, this doesn't work. The static content (the yellow rectangle) is wiped. This is CIQ 101 stuff. Sorry for the dumb question.

Trying pastebin to share test code:

https://pastebin.com/vg21ta7H
  • I didn't look at the code, but here's what happens.
    By the time onUpdate is called, the screen's been cleared, and the separator lines have been drawn in the case of a multi-field layout. So, you need to draw everything all the time.

    When I first wrote this a few years back, I figured I'd try only updating the screen every other time onUpdate was called, as I draw a bunch of lines. The result was a flashing DF. It would only show every other second.
  • If there is complex drawing you could have a bitmap. I don't know the cost of copying a bitmap to the screen vs several text and other drawing commands. In most cases it probably doesn't matter. On my 935, I have found very little impact on battery life from the amount of drawing I do. The Fenix 5+ seems to be a bit more impacted, but still fairly negligible. If you are doing an activity where you need to eek out every last minute of battery life, CIQ fields probably aren't your friends.

    I have a bread crumb map page in a CIQ application that often takes 1/3 of a second to draw, every second. Even that does't seem to hurt my 935 battery too much. Nothing like having a native map screen up on Edge devices that can cut your battery life over in half.
  • Seems it would be nice to be able to draw STATIC screen objects in onShow()..... that kind of is what onShow() should be about, since it is called whenever the screen becomes active. Then use onUpdate() for the dynamic content. Oh well. Thanks for the explanation.

    I was going to try to optimize my data fields for battery life and compute demand (which with a few running can cause the compute() loop to extend to like every 2 or 3 seconds). Sounds like static object drawing isn't my issue anyway.
  • that kind of is what onShow() should be about, since it is called whenever the screen becomes active.


    Well, that's not really what onShow() is about. The onShow() and onHide() methods are there to give your derived view a chance to load and unload resources. When working with a normal app and you have multiple views, you often want to release resources used by the current view when you push a new view onto the view stack, freeing up resources for the new view.


  • Former Member
    Former Member
    I figured I'd try only updating the screen every other time onUpdate was called, as I draw a bunch of lines. The result was a flashing DF. It would only show every other second.


    Ha! I tried the same thing a couple weeks back with the same result.

    Any reason why there isn't a method that bootloads static content to remain during the presentation? Seems like a waste of resources.

  • Any reason why there isn't a method that bootloads static content to remain during the presentation? Seems like a waste of resources.

    This is what BufferedBitmap is for. Anything that is not changing frequently would be drawn to the BufferedBitmap. You would draw that bitmap on the display as needed and then draw anything that changes frequently on top of that. This is how you would do it with other frameworks that I'm familiar with.
  • Former Member
    Former Member
    Oh cool! I'm going to look into that. Thanks for the info!