Avatar for NoMusicTuesdays

NoMusicTuesdays

Member since Apr 2022 • Last active Aug 2022
  • 4 conversations
  • 30 comments

Most recent activity

  • in Bangle.js
    Avatar for NoMusicTuesdays

    Oh riiight, that's what Gordon was saying about the uncompressed files... If they were compressed it would require RAM to decompress and present them via heatshrink. I'm reminded of how illustrator files are smaller on disk because they're a collection of vectors, but can get pretty heavy when open because of having to be interpreted by gpu in real time, whereas a photoshop file that's larger on disk might run more quickly. So much to learn... Banglejs is a great intro to javascript for me, there's nothing better than a practical application!

  • in Bangle.js
    Avatar for NoMusicTuesdays

    I suppose an image loaded when app starts is held in RAM, but then I suppose holding that image isn't as heavy as repeatedly loading it AND holding it

  • in Bangle.js
    Avatar for NoMusicTuesdays

    Okay.... here's what I have:

    const xc=88, yc=88;
    var twoPi  = 2*Math.PI;
    var Pi     = Math.PI;
    var halfPi = Math.PI/2;
    //daylight_images
    var faceDaylight = require("Storage").read("FaceDaylight.gi­f");
    var hourHandDay = require("Storage").read("HourHandDay.gif­");
    var minHandDay = require("Storage").read("MinHandDay.gif"­);
    var secHandDay = require("Storage").read("SecHandDay.gif"­);
    //nightglow_images
    var faceGlow = require("Storage").read("FaceGlow.gif");­
    var hourHandGlow = require("Storage").read("HourHandGlow.gi­f");
    var minHandGlow = require("Storage").read("MinHandGlow.gif­");
    var secHandGlow = require("Storage").read("SecHandGlow.gif­");
    //
    var drawTimeout;
    
    function daylight() {
      var d = new Date();
      var h = d.getHours() % 12 || 12;
      var HoursAngle   = (d.getHours()+(d.getMinutes()/60))/12 * twoPi - Pi;
      var MinutesAngle = (d.getMinutes()/60) * twoPi - Pi;
      var SecondsAngle = (d.getSeconds()/60+d.getMilliseconds()/6­0000) * twoPi - Pi;
      g.reset();
      g.clear();
      g.drawImage(faceDaylight);
      //DateWindow
      g.setFont("6x8");
      g.setFontAlign(0,0);
      g.setColor(0,0,0);
      g.drawString(d.toISOString().substr(8,2)­, 138, 88, 0);
      g.drawString(d.toISOString().substr(8,2)­, 139, 88, 0);
      g.drawImage(hourHandDay,xc,yc,{scale:1,r­otate:HoursAngle});
      g.drawImage(minHandDay,xc,yc,{scale:1,ro­tate:MinutesAngle});
      g.drawImage(secHandDay,xc,yc,{scale:1,ro­tate:SecondsAngle});
      queueDraw();
    }
    
    function nightglow() {
      var d = new Date();
      var h = d.getHours() % 12 || 12;
      var HoursAngle   = (d.getHours()+(d.getMinutes()/60))/12 * twoPi - Pi;
      var MinutesAngle = (d.getMinutes()/60) * twoPi - Pi;
      var SecondsAngle = (d.getSeconds()/60+d.getMilliseconds()/6­0000) * twoPi - Pi;
      g.reset();
      g.clear();
      g.drawImage(faceGlow);
      g.drawImage(hourHandGlow,xc,yc,{scale:1,­rotate:HoursAngle});
      g.drawImage(minHandGlow,xc,yc,{scale:1,r­otate:MinutesAngle});
      g.drawImage(secHandGlow,xc,yc,{scale:1,r­otate:SecondsAngle});
      queueDraw();
    }
    
    function draw(){
      if(Bangle.isLocked()){
        daylight();
        } else {
        nightglow();
        }
    }
    
    function queueDraw() {
      if (drawTimeout) clearTimeout(drawTimeout);
      drawTimeout = setTimeout(() => {
        drawTimeout = undefined;
        draw();
      }, 250 - (Date.now() % 250));
    }
    Bangle.on('lock', on => {
      draw();
    });
    draw();
    

    Still getting the tiniest delay, though I think it is better than it was.

  • in Bangle.js
    Avatar for NoMusicTuesdays

    Would I be better off naming '''var d = new Date();''' and such at the beginning, outside of my draw functions? I figured they needed to be inside the function so they'd update every time the function is repeated

  • in Bangle.js
    Avatar for NoMusicTuesdays

    Ah, so does naming the variables at the beginning only load them once? I wasn't sure if it was just using the variable as a shortcut to calling it out frame by frame anyway. I'll give this a try asap...

  • in Bangle.js
    Avatar for NoMusicTuesdays

    ...and the daylight images

  • in Bangle.js
    Avatar for NoMusicTuesdays

    For testing purposes, here are the nightglow images...

  • in Bangle.js
    Avatar for NoMusicTuesdays

    Sorry, I accidentally posted yesterday's code, then deleted. The above post shows the entirety of today's code

  • in Bangle.js
    Avatar for NoMusicTuesdays

    I tried adding the '''setTimeout(0);''' to the '''Bangle.on('lock', on=> {''' section to speed things up, not sure if that makes sense, but it didn't seem to make a difference...

Actions