tomasslavicek

Partial update / draw, Garmin Connect IQ watch face Monkey C

Oct 16th, 2018
121
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onShow() {
  2.     redraw = true;
  3. }
  4.  
  5. function onUpdate(dc) {    
  6.     dc.clearClip();
  7.     redraw = true;
  8.     fullUpdate();
  9.     partialUpdate();
  10.     draw(dc);
  11. }
  12.    
  13. function onPartialUpdate(dc) {
  14.     partialUpdate();
  15.     dc.setClip(clipMin[0], clipMin[1], clipMax[0] - clipMin[0], clipMax[1] - clipMin[1]);
  16.     draw(dc);
  17. }
  18.  
  19. function draw(dc) {                    
  20.     if (redraw) {    
  21.         // Full redraw, 1x per minute (or when he is looking on his watch)
  22.         var dc2 = backgroundBitmap.getDc();
  23.         dc2.draw(...)
  24.         redraw = false;      
  25.     }
  26.    
  27.     dc.drawBitmap(0, 0, backgroundBitmap);
  28.    
  29.     // Second hand, drawn every second          
  30.     dc.draw(...)
  31. }
RAW Paste Data