Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro functionality for switches to trigger actions #19

Open
conaito opened this issue Jan 22, 2021 · 1 comment
Open

Macro functionality for switches to trigger actions #19

conaito opened this issue Jan 22, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@conaito
Copy link

conaito commented Jan 22, 2021

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
Copy link
Owner

pkerspe commented Jan 24, 2021

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"):

  • trigger movement to a specific position
  • trigger movement by a specific amount of steps / mm / rotation
  • setSpeed, setAcceleration, setDeceleration, setHome, setLimitA, setLimitB,
  • trigger an IO pin to go low or high
  • trigger emergency stop
  • trigger regular stop
  • issue an HTTP GET request to a defined URL (maybe with providing current position as URL parameter)
  • trigger another macro

ToDos to implement the function:

  • A lightweight script language needs to be defined how macros are composed, that can be easily interpreted with the ESP
  • Adopt persistence layer to allow storing and reading macros from JSON configuration (might be in place already in class ESPStepperMotorServer_MacroAction)
  • Define and create all the commands that should be supported in a separate class (partially started in ESPStepperMotorServer_MacroAction in the enum field and the ESPStepperMotorServer_MacroAction::execute function)

Macros need to have some basic properties:

  • Name / ID
  • Maybe description text (limited length)
  • The event definition that triggers the macro (or an array of events)
  • the actual macro script code

For the UI we need:

  • a new view to manage marcodes (Add, remove, edit), or extend the config view
  • a macro editor with validation needs to be implemented (to check syntac of macros in general and to validate the used commends against the existing set of commands)
  • adopt existing views to allow linking macros to switches and stepper motors (axis)
  • a new svg icon for macros needs to be created (for consistency with the rest of the UI)

@pkerspe pkerspe changed the title Macro Macro functionality for switches to trigger actions Jan 24, 2021
@pkerspe pkerspe added the enhancement New feature or request label Jan 24, 2021
@conaito conaito closed this as completed Feb 9, 2021
@pkerspe pkerspe reopened this Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants