You are reading a single comment by @HughB and its replies. Click here to read the full conversation.
  • I'm trying a clock_info to simplest clock.
    I have done a new version of simplest clock that uses the new clock loading style. IE all the code between an opening and closing brace.

    I'm getting the following error on the console when I try BTN1 and BTN3.

    >
    Uncaught Error: Function "d" not found!
     at line 1 col 15
    120>e.x||(k(),d(88<e.y?1:-1))
                  ^
    in function called from system
    >
    

    Here's my code for simplest clock

    
    {
      // must be inside our own scope here so that when we are unloaded everything disappears
      // we also define functions using 'let fn = function() {..}' for the same reason. function decls are global
    
      const h = g.getHeight();
      const w = g.getWidth();
      
      let draw = function() {
        var date = new Date();
        var timeStr = require("locale").time(date,1);
        
        g.reset();
        g.setColor(g.theme.bg);
        g.fillRect(Bangle.appRect);
    
        g.setFont('Vector', w/3);
        g.setFontAlign(0, 0);
        g.setColor(g.theme.fg);
        g.drawString(timeStr, w/2, h/2);
    
        // schedule a draw for the next minute
        if (drawTimeout) clearTimeout(drawTimeout);
        drawTimeout = setTimeout(function() {
          drawTimeout = undefined;
          draw();
        }, 60000 - (Date.now() % 60000));
      };
    
      // future use
      let prevInfo = function() {
        console.log("prevInfo");
      };
    
      // future use
      let nextInfo = function() {
        console.log("nextInfo");
      };
    
      // timeout used to update every minute
      var drawTimeout;
      g.clear();
    
      // Show launcher when middle button pressed, add updown button handlers
      Bangle.setUI({
        mode : "clockupdown",
        btn : function (n) {
           if (n<0) prevInfo();
           if (n>0) nextInfo();
           draw();
         }
      });
    
      // Load widgets
      Bangle.loadWidgets();
      draw();
      setTimeout(Bangle.drawWidgets,0);
    }  // end of clock
    
    
    
About

Avatar for HughB @HughB started