From 4514c972683f5fb98e4498e188141d407ccd5e23 Mon Sep 17 00:00:00 2001 From: Tristan Rowley Date: Fri, 31 Jan 2020 21:03:15 +0000 Subject: [PATCH 1/3] example of calling actions with a value or arguments --- plugins/TestPlugin.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/TestPlugin.py b/plugins/TestPlugin.py index 78666fd..bf14a90 100644 --- a/plugins/TestPlugin.py +++ b/plugins/TestPlugin.py @@ -17,6 +17,8 @@ class TestPlugin(ActionsPlugin,SequencePlugin): ( r"^toggle_pause_automation$", self.toggle_pause_automation ), ( r"^pause_automation$", self.pause_automation ), ( r"^toggle_loop_automation$", self.toggle_loop_automation ), + ( r"^print_arguments$", self.print_arguments ), + ( r"^set_the_shader_param_([0-3])_layer_offset_([0-2])_continuous_inverted_example$", self.invert_shader_param_layer ) ] def test_plugin(self): @@ -49,3 +51,13 @@ class TestPlugin(ActionsPlugin,SequencePlugin): "set_the_shader_param_1_layer_0_continuous", position ) + def print_arguments(self, *args): + print(">>>>print_arguments ( %s )" % args) + + def invert_shader_param_layer(self, param, layer, value): + # invert the value + self.pc.actions.call_method_name( + "set_the_shader_param_%s_layer_offset_%s_continuous" % ( param, layer), 1.0 - value + # if you were calling an action with no argument, use eg: + # "toggle_automation_pause", None + ) From 8386fa8761268a88cd4e58e0a46149f03a8bf772 Mon Sep 17 00:00:00 2001 From: Tristan Rowley Date: Fri, 31 Jan 2020 21:10:40 +0000 Subject: [PATCH 2/3] Another simple plugin adding ability to append "|invert" to a mapping to invert the value. --- plugins/ManipulatePlugin.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/ManipulatePlugin.py diff --git a/plugins/ManipulatePlugin.py b/plugins/ManipulatePlugin.py new file mode 100644 index 0000000..d6c14d0 --- /dev/null +++ b/plugins/ManipulatePlugin.py @@ -0,0 +1,22 @@ +import data_centre.plugin_collection +from data_centre.plugin_collection import ActionsPlugin#, SequencePlugin + +class ManipulatePlugin(ActionsPlugin): + disabled = False + + def __init__(self, plugin_collection): + super().__init__(plugin_collection) + + @property + def parserlist(self): + return [ + ( r"(.*)\|invert$", self.invert ), + ] + + def invert(self, action, value): + # invert the value + self.pc.actions.call_method_name( + action, 1.0 - value + # if you were calling an action with no argument, use eg: + # "toggle_automation_pause", None + ) From 565c91b4cca950b0d4c07de84653f7ae1614022b Mon Sep 17 00:00:00 2001 From: Tristan Rowley Date: Fri, 31 Jan 2020 21:14:03 +0000 Subject: [PATCH 3/3] update ACTIONS docs --- ACTIONS.md | 5 ++++- dotfiles/generate-list-actions.sh | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ACTIONS.md b/ACTIONS.md index c99205b..bf5a224 100644 --- a/ACTIONS.md +++ b/ACTIONS.md @@ -1,6 +1,6 @@ # Auto-generated Actions list -Fri 31 Jan 20:19:55 UTC 2020 +Fri 31 Jan 21:13:49 UTC 2020 for branch=feature_plugins @@ -173,6 +173,7 @@ for branch=feature_plugins * set_shader_speed_layer_([0-2])_amount ### Plugin routes + * (.*)|invert (from ManipulatePlugin) * (.*)&&(.*) (from MultiActionsPlugin) * test_plugin (from TestPlugin) * cycle_shaders (from TestPlugin) @@ -181,6 +182,8 @@ for branch=feature_plugins * toggle_pause_automation (from TestPlugin) * pause_automation (from TestPlugin) * toggle_loop_automation (from TestPlugin) + * print_arguments (from TestPlugin) + * set_the_shader_param_([0-3])_layer_offset_([0-2])_continuous_inverted_example (from TestPlugin) ---- diff --git a/dotfiles/generate-list-actions.sh b/dotfiles/generate-list-actions.sh index 363c7bb..c572d31 100755 --- a/dotfiles/generate-list-actions.sh +++ b/dotfiles/generate-list-actions.sh @@ -12,11 +12,11 @@ grep " def " actions.py | grep -v "^#" | sed -e 's/ def //' | sed -e 's/self//' echo echo "## Dynamic routes" -grep '( r"' actions.py | sed -e 's/\(.*\)"\(.*\)"\(.*\)/ * \2/' | sed -e 's/\$//' | sed -e 's/\^//' +grep '( r"' actions.py | sed -e 's/\(.*\)"\(.*\)"\(.*\)/ * \2/' | sed -e 's/\$//' | sed -e 's/\^//' | sed -e 's/\\//' echo echo "### Plugin routes" -grep "( r\"" plugins/*.py | sed -e 's/plugins\/\(.*\)\.py:\(.*\)\( r\"\)\(.*\)\"\(.*\)/ * \4\t(from \1)/' | grep -v "open_serial" | sed -e 's/\$//' | sed -e 's/\^//' +grep "( r\"" plugins/*.py | sed -e 's/plugins\/\(.*\)\.py:\(.*\)\( r\"\)\(.*\)\"\(.*\)/ * \4\t(from \1)/' | grep -v "open_serial" | sed -e 's/\$//' | sed -e 's/\^//' | sed -e 's/\\//' echo echo "----"