Avatar for allObjects


Member since Jul 2014 • Last active Apr 2020

Espruino makes IoT as easy as 123!

Most recent activity

  • in Other Boards
    Avatar for allObjects


    this is about the mainline I would go: If there is no (Espruino) JS module yet for connecting / talking to Azoteq IQS263 Capacitive Touch sensor, take the Arduino code and put it into a module.

    How would that go? ...take a peek at other modules talking I2C to sensors.

    In addition to the .connect(...) that sets 'all' up includes in its arguments the pin you connect to the sensor 'RDY' pin and callback for handler in the application level. In setup process at last you add a setWatch(callback,rdyWatchingPin,<option­s>).

    Their are variations of this: you may crate a start and stop listening - like .enable(boole) on the connection module instance to let application control when to be called rather than put all into the .connect().

    You can always let the application do all things. On the other hand, you would like to put as much 'low level' handling into the module, for example: detection of short touch, long touch, etc., and pass that in the callback or make even different callback with this information, including time, touch time, last time, etc. To get some ideas, look at the Espruino event object.

    For the programming paradigm, do not think server-side JS, like nodeJS, but more browser JS as you are very familiar with and threat the sensor like a html ui action element, for example, as a button, or a canvas where you clicked on and you get tons of info with the event that is delivered to the attached event handler(s).

    Enjoy the ride!

  • in Bangle.js
    Avatar for allObjects

    ...did I read Pizza upgrade? ...topping specs? ...sorry for the not so foreign joke in this foreign time we all go thru right now. It needs some humor to brighten things up.

    On a more - or in other ways - serious note: the piezo is so quiet / low volume because it if 'free' between 'soft' things. if there would be a way to make it work like a piezo microphone (or probably your smoke detector), the element would have to be on 'solid ground' and the center would have to have a 'Stimmstock / tuning stick' like in the Violin that passes the vibration from the 'Steg / bridge' on the top onto the bottom - the membrane / speaker cone. The other thing that could work is a transducer 'bolted solidly' to the case, top glass is better than bottom metal.

    The mic I had as a tinkering boy: looked like a small round pill box with a 7 hole in the top giving view onto a metal membrane wit a funny metal thing poking thru its center, fixated with a tiny bit of glue. Behind the membrane was a flat 1x1cm thin crystal waver of which three corners were solidly mounted in the box and the fourth corner had the other end of the funny metal thing fixated to the membrane. Incoming sound waves flex the crystal which creates electrons being pushed around its grid... and this is detected by wires connected to the sides which were silver coated...

    Could not find a pic of such a mic nor find it... but I found - ironically this: https://www.instructables.com/id/Make-a-­Guitar-Pickup-From-an-Old-Watch/

    No need to explain 'ironic'... and it also makes me think if this could be used to make Bangle.js a recording device! ...hahaha...

  • in Other Boards
    Avatar for allObjects

    So MCU can request a I2C communication window when this pin goes down. That is the reason why while loop will not be an infinite.

    'Infinite' at your terms: no - but in Espruino's architecture: infinite enough to qualify... and even more so if you even think remotely to put something like this onto an ESP8266EX chip.

    For sure Espruino supports interrupts... directly in it's firmware, and puts a marker into the event queue as you define in the setWatch()... that makes it so easy and simple to use. Your application JS code (function) will be called as soon as nothing else more pressing is going on and your last event driven application JS piece has completed.

    In Espruino, everything is event driven... either by a pin signal or a time (which is a timer signal). I'm not sure you really need inline C. But feel free to be its guest and share your experience.

    As stated - everything in Espruino is event driven / has to be event driven - even a polling is event driven: a time - setTimout() or setInterval() - sets up timer that will fire and in the end pull the 'spaghetto' out of the plate of (code) spaghetti and mumpf it. Just make sure - in order to be a good 'spaghetto citizen' - its (execution) length does not qualify for infinite or resource hogging, because as long as your one spaghetto is in process, no other spaghetto can run... Be aware that many drivers / connectors to sensors use modules written in JavaScript... so - for example - receiving data will not happen - until the 'data read' event is first in the event queue and next for execution.

    This - TSO - time sharing option - is one of the oldest architectures... around with the first main frames that gave multiple users so called 'simultaneous terminal access' (vs. console access, which in the early days was the only terminal): a 'pseudo multi-/parallel- tasking' that is done in JS in Espruino as well as in the Browser (in the Browser only until recently...): an application process or flow is divided up into many short code pieces (spaghetti) where one plants the seed of the next(s) one(s) by setting up an timer or pin interrupt (javascript) handler. This way it seems to us 'slow' humans as if things are handled in parallel / multi-tasking, where when closely looked at, each piece is happening so fast that we feel a particular application has the processor's attention at all times.

    Benefit of this setup is that there is no complicated locking/synchronization required between the apps... it's almost like transactional: a once started piece of code always finishes and what is. done is done without any other application interference... The price pay: you pay upfront by thinking thru the process and identify the pieces and their triggers (interrupts they setup for the next one).

    Speaking of interference: if you go into async yourself, you are on your own - or to bare metal... and in the end: you have changed nothing: it is still single threaded... and if your thread takes too long to relent, some one else - other application thread - will pay for it.

  • in Bangle.js
    Avatar for allObjects

    With https://banglejs.com/reference#Bangle you have a singleton with which you can control the specifics of BangleJs.

    For example, https://banglejs.com/reference#t_l_Bangl­e_setGPSPower Bangle.setGPSPower(1); will turn the GPS receiver on, and Bangle.setGPSPower(); turns it of (of course .setGPSPower(true); and .setGPSPower(false) or .setGPSPower(0); work as well.

    I n general:

    • application run mutually exclusive
    • widgets run all the time
    • games - for performance and real estate reasons - exclude / stop also widgets

    It all depends how the applications/widgets/games are built.

  • Avatar for allObjects

    Issue with touch screens of fit-bands and a-like is that they do not have many areas... usually just one, and bangle.js has two: left and right.

  • in Bangle.js
    Avatar for allObjects

    Encountered the same (about 3/3) - no app loaded. Starting from scratch was the solution w/ updating boot loader first.

  • in General
    Avatar for allObjects

    @Robin, a decent - actually great - alternative for a tablet is a chrome book: You get a real keyboard and for a good price. Some chrome books are also working as tablets w/ touch screen and back-foldable key board.

  • in JavaScript
    Avatar for allObjects


    Right after you gave me your advice I went through a long patch of not having any quality thinking time, due to having two very young kids.

    Don't be that hard on yourself... first of all: there are the real 'things', that secure the future: the kids, and there are the imaginary / imagined things: formal languages, among them: JS.

    I'm convinced if someone had provided you with the right bench to sit on and overlook the CS landscape, you would say: nothing easier than that - and a great, relaxing balance - to rearing two children... and tend to their comprehensive / challenging everything every minute needs.

    If you were asked to build and present - show and tell about - a (logical) machine / computer / mc that can memorize things by name - property name, such as mail slots for Miller, Fox, Whale,... - and location - (storage) index / place, such as first, second, third,... - you would have come up with congruent patterns for describing and coding of it. Any interpreter - human or machine - listens / reads the data and processes it according to conventions to information and executable instructions... just as you listen to your kids' expressions - visual and audible - and you do as you go.

  • in JavaScript
    Avatar for allObjects

    Great... fill though has still some issues: right-top and left-bottom... before it was both right top and bottom. Fill seems obviously a really 'neat' problem to solve.

  • Avatar for allObjects

    Neat! ...and to get rid of the the mechanical / button stuff, you can add a touch panel, such as: https://www.ebay.com/itm/Factory-Outlet-­1-4-inch-Resistive-Touch-Panel-Screen-wi­th-Soldering-FPC/292819160320 ... It is a bit larger than you need, but there may be others around... even capacitive one. The resistive though are 'passive' - no noticeable consume. - on the other hand, the touch panel could be activated the same time as the display comes on.