You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • #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
About

Avatar for allObjects @allObjects started