• When I upload my code from the WebIDE it has access to BTN1, 2 and 3 and the code responds correctly. However when I check in my code to Github and deploy it via my Bangle.js loader, it only responds to BTN3. BTN2 brings up Settings App and BTN1 doesn't respond at all.

    Is there a way to override the Settings app when my clock app is on ?

  • I guess your setWatch() come too early. They have to fire after loading w/ loader completed. But without seeing code - the setwatch(...) in layered contexts, it's hard to tell/help...

  • @allObjects thanks for the tip. Any sample code I can look at?

    My code is here

    https://github.com/piofthings/BangleApps­/blob/master/apps/fitclck/fit-clock.js

    It is just a copy of the morph-clock.js app with some minor mods.

  • Sat 2019.12.21

    Hi @PiOfThings,

    While I haven't seen much use of IIFE (Immediately Invoked Function Expression) for microcontrollers, if it's working for you, Bravo! (see the structure in the example of the code file you referenced)

    As that entire IIFE code block will execute as it is uploaded to your Espruino device, as @allObjects points out, the setWatch()'s may occur before everything settles.

    Place something like this as the very last section with a call to your constructor function within the timeout.

    example

    // Note: save() must be entered at least once before this will take effect
    
    E.on('init',function() {
    //  setWatch(kill, BTN, { repeat: true, edge:'falling' });
      setTimeout( function() {
        console.log("Hello World!");
    //    st();
    //    console.log("Receiving\n");
    //    rx();
        
      }, 1500);
    });
    
  • @PiOfThings, looked at your code and asked myself about the issue... if it persists even after applying for example, setTimeout(ctor,999); at line 278 - https://github.com/piofthings/BangleApps­/blob/master/apps/fitclck/fit-clock.js#L­278 (if it is still that line), old setWatches() may may still exist... I doubt though that @Gordon - I mean: the app loader @Gordon created - leaves them behind, active... (Don't ask me about removing them since I don't know how they would have been created, or having access to them or their handle...).

    A) Do you have actual device to test? ... or - B) Are you (still) confined - like me - to the Espruino (or my own, homegrown) emulator?

    NB: Instead of the direct timeout, I would try the standard onInit(){ ctor(); }. Looking forward to hear equally interested on success or not yet success ... failure is defined as giving up, not yet success is learning... I just was 'told' by some giants on whom's shoulders I'm given the privilege to stand.

  • @Robin and @allObjects thank you for all the tips, but guess what 'fixed' it? Merging the latest upstream from espruino/BangleApps repo into my fork and redeploying (almost) the same code. I will dig into the changeset and see if I can spot what changed.

    Couple of points though:

    1. E.on('init'...) : I am not sure Bangle Apps fall in this category, because I am guessing Bangle HW on init, start the firmware first and not the App (not my App anyway).

    2. IIFE - I deserve no credit for getting that to work, I was simply copying a pattern from the most basic clock App in the Repo.

    3. H/w - @allObjects I was just too impatient to wait 3 months, I want to dump my Fitbit as soon as possible, I backed the Beta Unit, so I am developing on device.

    Thanks again.

  • @PiOfThings

    I was just too impatient to wait 3 months, I want to dump my Fitbit as soon as possible, I backed the Beta Unit

    ...smart choice!

    I was actually surprised that @Gordon (finally) put out an emulator... It is about 5 years ago when I started to develop in dedicated emulator in browser (http://forum.espruino.com/comments/12041­240/) - and 3+ years ago built my own (for developing ui framework and ui elements). My emulator not as sophisticated but much more accessible and customizable. I see not much difference in the outcome since none of the emulators does really 'usable' HW emulation. The advantage of my emulator is that I can include testing and monitoring... I like emulation for the purpose of figuring out logic - algorithms and data structures - on a higher (application oriented) level immediately. For the ui I'm at the point where I pull into the emulator the very same unchanged code from projects and modules from the Espruiono Web IDE Sandbox folder that then run on the target Espruno board. The emulation uses a board specific 'plug-in' to give me what I need... and I add as I go. Most recent I implemented the setWatch() and it works just as I expected. The pin / Btn is a html element - Button or Checkbox - that creates the 'edge' event on press or unpress / mouse down / mouse up.

    You allocated your resources for beta version... I folded then into multiple 'final' versions. I'm looking forward to get them as soon as possible... and if 'Far East' is playing by its promise towards @Gordon it will happen sooner then later. So far I had good and mixed experience with similar sources.

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

Why doesn't BTN1 and BTN2 respond when uploading app via Bangle.js loader?

Posted by Avatar for PiOfThings @PiOfThings

Actions