pkerspe / ESP-StepperMotor-Server

Turn your ESP32 into a complete stepper motor control server with web UI, REST API and serial control interface
MIT License
225 stars 39 forks source link

Macro functionality for switches to trigger actions #19

Open conaito opened 3 years ago

conaito commented 3 years ago

As we see into the code you started already some macro dev. may you can give a sample to use it at current status?

pkerspe commented 3 years ago

Currently macros are not supported, what you see in the code is just for future use and has never been tested so far. To be hones it is quite long ago that this has been written, not sure what the exact status is :-) It seems the persistence logic is implemented, but UI support is not yet in place. So you could try to manually modify your config.json and add macro configuration array to a switch configuration. Currently a macro action should look likes this (if I interpret it right in the code, you need to figure this our on your own currently):

...
    "switchConfigurations": [
        {
            "id": 0,
            "ioPin": 14,
            "stepperIndex": 0,
            "switchType": 64,
            "name": "Limit 1 X-Axis",
            "switchPosition": -1
            "macroActions": [
                {
                    "type": "moveBy",
                    "val1": "<id of stepper motor to move, could be different from the one the switch is linked to>",
                    "val2": "<number of steps to move>"
                }
            ]
        },

(list of all action types can be found in MacroActionType definition in the MacroAction header file. (currently: moveTo, moveBy, setSpeed, setAcceleration, setDeceleration, setHome, setLimitA, setLimitB, setOutputHigh, setOutputLow, triggerEmergencyStop, releaseEmergencyStop)

Please specify which functionality you might need for macros, how you would imagine macros could be defined (scripted) and how they could be triggered. We can work on a requirement definition together.

I thought that macros could have the following commands (in the future, not all are in the current "implementation"):

ToDos to implement the function:

Macros need to have some basic properties:

For the UI we need: