• I decided to have a go at writing something for the Bangle2 (at least, for the emulator until they go on sale properly). I started with the tutorial and ended up creating a very basic analogue clockface.

    The docs for the graphics API say for the AA versions of methods:

    Note: This is only available in devices with Antialiasing support included (Bangle.js or Linux)

    but it isn't clear whether this should include Bangle.js 2, or just the original. The methods don't work in the Bangle 2 emulator. My guess is that they aren't intended to (it is a different screen, lower res, fewer colours, etc), but in that case maybe the docs should be more explicit about Bangles now there are two of them?

    Working non-antialiased clock just in case anyone is interested:

    function draw() {
      // work out how to display the current time
     var d = new Date();
    //  var h = d.getHours(), m = d.getMinutes();
    //  var time = (" "+h).substr(-2) + ":" + ("0"+m).substr(-2);
    //  // Reset the state of the graphics library
      g.reset();
    
      var base = 85;
      var rad = 50;
      g.clearRect(base - rad, base - rad, base + rad, base + rad);
      g.drawCircle(base, base, rad);
      g.drawString("12", base - 2, base - 40, false);
      g.drawString("6", base - 2, base + 40, false);
      g.drawString("3", base + 40, base -2, false);
      g.drawString("9", base - 40, base -2, false);
      var handLength, hour, minutes, seconds, ang;
    
      handLength = 20;
      hour = d.getHours();
      ang = ((hour % 12 * 30) - 90) * 0.01745329;
      g.drawLine(base, base, base + (handLength * Math.cos(ang)), base + (handLength * Math.sin(ang)));
    
      g.reset();
      handLength = 35;
      minutes = d.getMinutes();
      ang = ((minutes * 6) - 90) * 0.01745329;
      g.drawLine(base, base, base + (handLength * Math.cos(ang)), base + (handLength * Math.sin(ang)));
    
      g.reset();
      g.setColor(255, 0, 0);
      handLength = 40;
      seconds = d.getSeconds() + d.getMilliseconds() / 1000;
      ang = ((seconds * 6) - 90) * 0.01745329;
      g.drawLine(base, base, base + (handLength * Math.cos(ang)), base + (handLength * Math.sin(ang)));
    }
    
    // Clear the screen once, at startup
    g.clear();
    // draw immediately at first
    draw();
    var secondInterval = setInterval(draw, 10);
    // Stop updates when LCD is off, restart when on
    Bangle.on('lcdPower',on=>{
      if (secondInterval) clearInterval(secondInterval);
      secondInterval = undefined;
      if (on) {
        secondInterval = setInterval(draw, 10);
        draw(); // draw immediately
      }
    });
    // Show launcher when middle button pressed
    Bangle.setUI("clock");
    // Load widgets
    Bangle.loadWidgets();
    Bangle.drawWidgets();
    
About

Avatar for myownself @myownself started