Why doesn't BTN1 and BTN2 respond when uploading app via Bangle.js loader? #1309
Replies: 6 comments
-
Posted at 2019-12-19 by @allObjects 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... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-21 by PiOfThings @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 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-21 by Robin 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
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-21 by @allObjects @piofthings, looked at your code and asked myself about the issue... if it persists even after applying for example, 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 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-22 by PiOfThings @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:
Thanks again. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-22 by @allObjects
...smart choice! I was actually surprised that @gfwilliams (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/12041240/) - 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 @gfwilliams it will happen sooner then later. So far I had good and mixed experience with similar sources. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-12-18 by PiOfThings
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 ?
Beta Was this translation helpful? Give feedback.
All reactions