You are reading a single comment by @jeffmer and its replies. Click here to read the full conversation.
  • I have quite a few widgets running such as battery, bluetooth, gpsrec, ANCS etc and although they are incredibly useful, they do clutter up the screen and take away from the design simplicity of some of the clock faces I use. In an attempt to have the best of both worlds, I have added the following code to the clock apps I use. Touching the left side of the screen hides all widgets and touching the right side re-displays them.

    var widgetVis = {
      saved:null,
      hide:()=>{
          if (!Bangle.isLCDOn() || this.saved) return;
          this.saved = [];
          for (var wd of WIDGETS) {
             this.saved.push(wd.draw); 
             wd.draw=()=>{};
          }
          g.setColor(0,0,0);
          g.fillRect(0,0,239,23);
       },
      reveal:()=>{
          if (!Bangle.isLCDOn() || !this.saved) return;
          for (var wd of WIDGETS) wd.draw = this.saved.shift();
          Bangle.drawWidgets(); 
          this.saved=null;
      },
      setup:()=>{
          setWatch(this.hide, BTN4, {repeat:true,edge:"rising"});
          setWatch(this.reveal, BTN5, {repeat:true,edge:"rising"});
      }
    };
    
    widgetVis.setup();
    

    It is not enough to simply blank out the widget area and then avoid calling drawWidget() since many widgets redraw based on timer events etc. The methods above replace widget draw functions with null functions and then restore the old draw functions when widgets are not hidden.

    If others feel this is a useful facility, it might be sensible to have a standard way to hiding widgets while leaving them running. There may well be a better way of doing this than the one I have outlined.

About

Avatar for jeffmer @jeffmer started