Avatar for Jferrari6803

Jferrari6803

Member since Apr 2022 • Last active Aug 2022
  • 1 conversations
  • 8 comments

New user to Espruino.
Bangle.js 2 Watch.

Most recent activity

  • in Bangle.js
    Avatar for Jferrari6803

    Good point. That would work perfectly if I could use my code snippet, or save it as a jpg, in place of the sunset.

  • in Bangle.js
    Avatar for Jferrari6803

    Thanks for the advice on displaying code.

    I like the lock screen idea, but I'm trying to go another route. I want to run the "zen", on button press or screen touch run "time" for 5 seconds, then return to "zen".

    -Run Zen
    -On Btn run Time
    -10 sec
    -Resume Zen

    Can this be done?

  • in Bangle.js
    Avatar for Jferrari6803

    sorry, I thought the code would display like yours.

    The only thing I'm missing is the button event to run the time function. I just stuck time() at the end to see what would happen.

  • in Bangle.js
    Avatar for Jferrari6803

    So... this is what I've got so far.
    It just flashes back and forth between the "Zen" splash and the clock.
    I think we're almost there.
    Any Suggestions?

    // This is my Zen Splash Screen
    function zen(){
    setInterval(function() {
    g.clear(1);
      //Draw Text
    g.setFont("Vector",45);
    g.drawString("Now",42,70);
         }, 5000);
        }
    
    // clock from your tutorial
    function time(){
    // Load fonts
    
    // position on screen
    const X = 170, Y = 110;
    
    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();
      // draw the current time
      g.setFont("Vector",55);
      g.setFontAlign(40,40); // align right bottom
      g.drawString(time, X, Y, true /*clear background*/);
      
      // draw the date, in a normal font
      g.setFont("Vector",20);
      g.setFontAlign(0,1); // align center bottom
      // pad the date - this clears the background if the date were to change length
      var dateStr = "    "+require("locale").date(d)+"    ";
      g.drawString(dateStr, g.getWidth()/2, Y+15, true /*clear background*/);
    }
    
    // Clear the screen once, at startup
    g.clear();
    // draw immediately at first
    draw();
    var secondInterval = setInterval(draw, 1000);
    // Stop updates when LCD is off, restart when on
    Bangle.on('lcdPower',on=>{
      if (secondInterval) clearInterval(secondInterval);
      secondInterval = undefined;
      if (on) {
        secondInterval = setInterval(draw, 1000);
        draw(); // draw immediately
      }
    });
    // Show launcher when middle button pressed
    Bangle.setUI("clock");
    // Load widgets
    Bangle.loadWidgets();
    Bangle.drawWidgets();
    
    //revert to zen splashscreen
    myTimeout = setTimeout (zen, 3000);
    }
    // run clock
    time();
    
  • in Bangle.js
    Avatar for Jferrari6803

    I have an idea for a watch face, but I can't figure out the code. I know almost no JavaScript. Here's what I want to do.

    1. I have a splash screen with a custom message on it.
    2. On button press I'd like to show the clock ( any watch face, I'm not picky) for 10 seconds.
    3. Then revert back to the splash screen.

    Something like:
    Run function 1
    On button press Run function 2
    After 10, seconds break and return to function 1

    Any suggestions?

  • in Bangle.js
    Avatar for Jferrari6803

    n/a

  • in Bangle.js
    Avatar for Jferrari6803

    Never mind. NOOB mistake. All is good.

Actions