Moon phase widget slow?

Posted on
  • I'm using the northern hemisphere moon phase widget (in the SE UK in case that makes a difference!) It seems a bit 'slow' to me - i.e. I'm looking out the window right now at what looks like a full moon, the phase on my Bangle JS2 widget looks like it's at least 1 phase behind. Has anyone else noticed this? Is it to do with how often it updates?

  • Full moon is tomorrow night.

  • i noticed that offset too, i guess the threshold between two phase should be enhanced a litlle bit

  • Thanks @myownself - good to know!
    @nicoboss feels like it could 'tip' a bit earlier - I wonder if I notice this more when it's waxing as it is now than when it's waning.

  • It's 7.30am in London, the moon phase widget is showing a full moon and yet the moon I can see out of my window right now looks like it's ever so slightly slightly waning, it looks a bit less full than it did when I posted this thread. I guess it's a moot (moon?!) point when you change from one discrete phase image to another, but it certainly looks like it needs shifting forwards a bit.

  • Good morning!

    I just compared the moon phase calculation of the moon phase widget with that of my moon phase complication for analog clocks using the following code:

      function compareMoonphasesAt (today) {
      /**** Code from Moonphase Widget ****/
      
        const MC = 29.5305882, NM = 694039.09;
        var r = 11, mx = this.x + 12; my = this.y + 12;
      
        function moonPhase(d) {
          var tmp, month = d.getMonth(), year = d.getFullYear(), day = d.getDate();
          if (month < 3) {year--; month += 12;}
          tmp = ((365.25 * year + 30.6 * ++month + day - NM) / MC);
          return Math.round(((tmp - (tmp | 0)) * 7)+1);
        }
      
      /**** Code from Moonphase Complication ****/
      
        const MillisPerDay   = 86400000;
        const synodicalMonth = 29.530588;
      
        let Phase = (
          (today/MillisPerDay - new Date(2009,11,31, 20,12,36)/MillisPerDay) % synodicalMonth
        ) / synodicalMonth;
      
        if (Phase < 0) { Phase += 1; } // just in case that date is completely wrong
      
      /**** make the latter comparable to the former ****/
      
        Phase -= 0.5; if (Phase < 0) { Phase += 1; }
        Phase = Math.round(Phase * 7)+1;
      
      /**** print comparison ****/
      
        let day = today.getDate();
        print(
          '2022-01-' + (day < 10 ? '0' : '') + day + ': ' + 
          moonPhase(today) + ' vs. ' + Phase
        );
      }
    
      for (let Day = 17-14; Day < 17+14; Day++) {
        compareMoonphasesAt(new Date(2022,0,Day));
      }
    

    The output of that little script is:

    2022-01-03: 8 vs. 8
    2022-01-04: 1 vs. 1
    2022-01-05: 1 vs. 1
    2022-01-06: 2 vs. 2
    2022-01-07: 2 vs. 2
    2022-01-08: 2 vs. 2
    2022-01-09: 2 vs. 2
    2022-01-10: 3 vs. 3
    2022-01-11: 3 vs. 3
    2022-01-12: 3 vs. 3
    2022-01-13: 3 vs. 3
    2022-01-14: 4 vs. 4
    2022-01-15: 4 vs. 4
    2022-01-16: 4 vs. 4
    2022-01-17: 4 vs. 4
    2022-01-18: 5 vs. 5
    2022-01-19: 5 vs. 5
    2022-01-20: 5 vs. 5
    2022-01-21: 5 vs. 5
    2022-01-22: 5 vs. 5
    2022-01-23: 6 vs. 6
    2022-01-24: 6 vs. 6
    2022-01-25: 6 vs. 6
    2022-01-26: 6 vs. 6
    2022-01-27: 7 vs. 7
    2022-01-28: 7 vs. 7
    2022-01-29: 7 vs. 7
    2022-01-30: 7 vs. 7
    

    This looks as if the calculation itself is correct.

    What might lead to less optimal graphics is the low number of different indices - compared to user requirements (e.g., according to the numbers, "full moon" is shown from Jan 14 to Jan 17 incl. - this collides with "it's ever so slightly slightly waning")

    Thus, what may (might?) finish this discussion could be a more detailed drawing of the current moon phase in the widget?

  • Thus, what may (might?) finish this discussion could be a more detailed drawing of the current moon phase in the widget?

    It's on my to-do list, you've already done some great work in http://forum.espruino.com/comments/16328­587/

  • Well, since our formulae seem to be comparable, you may just copy all the code from my moon phase complication and adapt it for your radius and color settings - that's it. Everything else would require more work.

  • @blogmywiki: I can confirm the difference of the rendered phases with the visual moon.

    Nevertheless I can confirm the the calculation itself seems correct as also @Andreas_Rozek tested.

    From my point of view:

    1. It's hard to render a -always correct- circle view projection within 23 px
    2. Typically a moon projection shows als the full circle; but see 1. with a doted 1px line ... I don't expect to be more precise for our eyes
    3. I guess using the same code (moonphase calculation) in more than one app/widget or the cool overlays that @Andreas_Rozek provides (e.g. a module) would be very helpfull
  • The moon widget has no internal update, it depends on widgets draw to be updated 😉.

  • I've replaced the 8 phases with the drawing function from @Andreas_Rozek, see https://github.com/espruino/BangleApps/p­ull/1430

  • Maybe you find some time and go for a setting option, because there are two hemispheres and because of this there are two widgets - that would be great.


    1 Attachment

    • Bildschirmfoto 2022-02-12 um 07.39.41.jpg
  • oops - I guess, it would also be a good idea to add such an option to my moon phase "complication"...

  • I'm planning to use mylocation.json for this.

  • so I'll wait for you to solve that problem and see if I can copy your solution

  • I'm now using the data from the "My Location" app in https://github.com/espruino/BangleApps/p­­ull/1430

    You can try out the new widget on https://hilmarst.github.io/BangleApps/#m­oon

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Moon phase widget slow?

Posted by Avatar for blogmywiki @blogmywiki

Actions