Avatar for Levon

Levon

Member since May 2021 • Last active Sep 2021
  • 1 conversations
  • 5 comments

Just messing around with electricity for the first time, no biggie

Most recent activity

  • in JavaScript
    Avatar for Levon

    @Gordon

    After some additional testing, it seems that making any setInterval() calls within that calibration period will throw it off. I have some fairly innocuous code firing within 50ms intervals, and before removing it, I noticed a significant time drift (about 1 minute per hour).

  • in JavaScript
    Avatar for Levon

    Hello,

    I'm running the original Espruino board, latest revision.
    As far as I could tell, rapid firing would continue indefinitely, though I usually wouldn't wait that long.
    Didn't know about the calibration phase, anywhere I could read up on that? Delaying the code execution by 10 seconds did indeed solve the issue, thank you.

  • in JavaScript
    Avatar for Levon

    Hello,
    I'm trying to get Espruino to store a timestamp in Storage, and the read from it on boot and set the current time accordingly. This is the salient code:

    var TimeController = {
      currentTimeFilename: "currentTime",
      writeCurrentTime: function() {
        var currentTime = Number(new Date(Date.now()).getTime() / 1000);
        Storage.writeJSON(this.currentTimeFilena­me, {
          "timestamp": currentTime,
        });
      },
      readCurrentTime: function() {
        var currentTime = Storage.readJSON(this.currentTimeFilenam­e, true);
         if (currentTime) {
           setTime(currentTime.timestamp);
        }
      },
    };
    
    E.on('init', function() {
      clearInterval();
      clearTimeout();
      clearWatch();
      TimeController.readCurrentTime();
      setInterval(() => {
        TimeController.writeCurrentTime();
      }, 30000);
    });
    
    save();
    

    However, when the code executes the first time after Espruino is plugged into power (not PC), all of the intervals fire incredibly rapidly (similarly to issue described here). Removing all instances of setTime remedies this. Not sure what kind of conflict is occurring there, any help would be appreciated!

Actions