Avatar for SimonGAndrews

SimonGAndrews

Member since Aug 2021 • Last active Nov 2021
  • 2 conversations
  • 16 comments

Retired Solution Architect (Xerox - Imaging Services)
Working on implementing Xstate
https://xstate.js.org/docs/packages/xsta­te-fsm/
on Microcontrollers for improving Service Delivery

Most recent activity

  • Avatar for SimonGAndrews

    Thanks @Gordon,. I get the issue now with implementing.
    I appreciate your idea on the workaround and will try it out.

    Really enjoying working with Espruino , Pico is great, 5v tolerance really useful.
    Will be putting up on github, XState with Espruino including hierarchical states , asap.
    Comming along well.

  • in Pico / Wifi / Original Espruino
    Avatar for SimonGAndrews

    Hello,
    Im looking to use Function.name in javascript. https://developer.mozilla.org/en-US/docs­/Web/JavaScript/Reference/Global_Objects­/Function/name
    while porting the Xstate library to Expruino.

    I believe Function.name or similiar is not available in Espruino.
    Also a common polyfill uses function.toString() and Although Espruino does have Object.toString() which operates on a function , the returned string does not provide the name. (see attached).

    Any thoughts on the possibility of implementing function.name or a workaround to get the name of a function ?
    Thanks in Advance

  • in Projects
    Avatar for SimonGAndrews

    So been continuing with xstate-fsm-Espruino (as above ... XState/fsm for Espruino microcontrollers) but in test scenarios was very quickly missing the hierarchical functionality I had gotten use to with full XState on the Raspberry pi. So I've started to work on putting limited state chart functionality on top of xstate-fsm for Espruino. Early tests are can add hierarchical states with a few functions that manipulate state value (using a full XState ID format Inc custom IDs)' , get state parents etc. Hopefully still not breaking minimal memory constraints of the Espruino micros. Or deviating from XState principals. Will publish when a little more proven. Great fun in any event, and learning loads from XState as an example of functional programming in JS and Espruino, But what to call xstate-fsmPlus-Espruino ???

  • in Pico / Wifi / Original Espruino
    Avatar for SimonGAndrews

    @allObjects , all useful stuff above Ta,. ...not to distract from @bertjerred 's build mission but Think it may be useful here to note what happens if a setWatch interrupt occurs while the previous SetWatch function is still running. Was going to test but see you comented on the subject ( 7 yrs ago :). http://forum.espruino.com/comments/11932­979/
    Is it correct still that setWatch triggered functions are queued and executed by the JS Interpreter in the order in which they occurred?
    (* in the simple case assuming the advanced IRQ' parameter features of set watch are not used )

  • in Pico / Wifi / Original Espruino
    Avatar for SimonGAndrews

    Ta, and sorry for typos above. It is an MPR 121 and not MRP!

  • in Pico / Wifi / Original Espruino
    Avatar for SimonGAndrews

    also note the interrupt fires on both the contact and release of the keypad button. In this snip Im assuming on release , mpr.touched() = 0, that is : no keys are touched so dont print the value. I imangine on a keyboard this may not be the case, so will need another way to to handle this. Good luck :).

  • in Pico / Wifi / Original Espruino
    Avatar for SimonGAndrews

    Pure coincidence but I was working with an MRP121 keyboard on an Espruino MDBT42Q using the interrupt method. The interrupt is actually active low and hence needs a falling edge detection on the setwatch() function. Also the direct connection of the interrupt to an Espruino pin needs the internal pullup resistor enabling. Here is a working snipet to see the approach.

    // Setup pins and interface to MPR121
    const sclPin = D15;
    const sdaPin = D14;
    const irqPin = D16; // interrupt from MRP121
    
    I2C1.setup({scl:sclPin,sda:sdaPin});
    
    // IRQ is Active Low, open Drain (ref datasheet) - make use of internal pullup 
    pinMode(irqPin,'input_pullup');
    
    // connect to MRP121 via Espruino MRP121 library
    function mprConnected() {console.log ("MPR121 Connected");}
    var mpr = require("MPR121").connect(I2C1, mprConnected , { address: 0x5B});
    
    // define function for interrupt (fires on touch AND release)
    function touchedIRQ() {
            //console.log ("debug - interrupt received");
            var keys = mpr.touched();
            if (keys != 0) {console.log("Touched: " + keys);}
    }
    
    // watch the irqPin and fire the interrupt function on capacitance change
    // IRQ is active low, so trigger the interrupt on a 'falling edge'
    if (setWatch(touchedIRQ,irqPin,{repeat:true­, edge: 'falling'}) === 1) {
      console.log( "MPR Interrupt Enabled" );
    } 
    else {console.log ("error - set watch on interrput pin NOT enabled"); }
    

    Also Note the MPR121 keyboard im using does not have pullup resistors for the I2C: SCL and SDA, so I have added a 4.7 K resistor on my prototype board between each of: sclPin and 3.3v and sdaPin and 3.3v , I believe some MRP121 breakout boards already have these.

  • in Pico / Wifi / Original Espruino
    Avatar for SimonGAndrews

    Sorry not trying to confuse, if polling works that's fine I'm sure. Just so you know the option.

Actions