Test OR / AND operations UI?

Posted on
  • #test #operate #UI #testing #IDE #plugin

    Inspired by @JumJum 's work, I made a UI to my stepper code using Espruino IDE's testing plug-in.

    What is the benefit or convenience of using the test UI to operate your Espruino (while connected): You just click a button vs. typing a code snippet in the console pane (terminal)... and most of the time mistyping it...

    The test plug-in worked right away 'out of box' and without modifying my code (after creating a testing folder in the local sandbox folder).

    For controlling the board, I created the actionPoints (using the UI in the left hand side):

    • stop - stop() - stop the stepper
    • r3 - r(3) - run with interval of 3[ms]
    • increaseInterval - r(...) - increase the stepping interval
    • decreaseInterval - r(...) - decrease the stepping interval

    Because I wanted not just have the stepping interval graphed but also the (relative) speed, I just added a new variable stS (stepping speed) in my code that is updated when setting the interval stT variable (near setInterval() and clearInterval()) and use it in the test UI.

    For the increase and decrease details, see code below, which does the increase/decrease dependent on current stepping value. Code taken from the testing folder after saving definitions in the UI - and formatted for clarity.

    {"dataPoints":
      [ { "label":"intervalMS"
        , "expression":"stT"
        , "type":"number","points":[]
        }
      , { "label":"speed"
        , "expression":"stS"
        , "type":"number","points":[]
        }
      ]
    ,"actionPoints":
      [ { "label":"stop"
        , "expression":"stop();"
        , "type":"command"
        }
      , { "label":"r3"
        , "expression":"r(3);"
        , "type":"command"
        }
      , { "label":"decreaseInterval"
        , "expression":"r((stT >24) 
             ? stT - 24 
             : ( (stT > 3) 
               ? stT - 1 
               : 3 ));"
        , "type":"command"
        }
      , { "label":"increaseInterval"
        , "expression":"r((stT>24) 
            ? stT + 24 
            : ( (stT>2) 
              ? stT + 1 
              : 3) );"
        , "type":"command"
        }
      ]
    }
    

    In order to understand the speed value - this is the formula:

    // set Speed var stS from stepping interval Time variable stT [ms]
    var setSpeed = function() {
      stS = (stT !== 0) ? 1/stT*90 : 0; 
    };
    

    Attached is a screen shot of my operation and monitor UI for the stepper motor.


    1 Attachment

    • TestOrOpUi.png
  • I love feedback,
    at least this one ;-)

  • Never worked on a plug-in... may be you can shoe horn me a bit for that... I'd love to grow the plug-in in the direction you already started. - Btw, thanks for the feed on the message channel.

  • After doing some more work, I'll got instructed that the labels newExpression and newAction are not allowed to have spaces or other illegal characters in them. Therefore, use camel casing or replace the 'illegals' with underscores (_).

    The good thing though to know is that both actions and expression support dot-notation. For example, to set a property prop in an object obj (setup with var obj = {prop:5}; is achieved by a newAction with, for example, label set to set_obj_prop and myVariable set to obj.prop.

    Above example may soon undergo enhancements based on that.

    A very cool thing!

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

Test OR / AND operations UI?

Posted by Avatar for allObjects @allObjects

Actions