diff --git a/gen/SparkFlexConfig.yml b/gen/SparkFlexConfig.yml index e7b0a5e..9cc49a7 100644 --- a/gen/SparkFlexConfig.yml +++ b/gen/SparkFlexConfig.yml @@ -1,5 +1,8 @@ --- +extra_includes: +- sparkbaseconfig_apply.h + classes: SparkFlexConfig: attributes: @@ -11,3 +14,6 @@ classes: SparkFlexConfig&: ExternalEncoderConfig&: Flatten: +inline_code: | + bind_sparkbaseconfig_apply(cls_SparkFlexConfig); + diff --git a/gen/SparkMaxConfig.yml b/gen/SparkMaxConfig.yml index 9ecd1b5..db7b596 100644 --- a/gen/SparkMaxConfig.yml +++ b/gen/SparkMaxConfig.yml @@ -1,5 +1,8 @@ --- +extra_includes: +- sparkbaseconfig_apply.h + classes: SparkMaxConfig: attributes: @@ -13,3 +16,5 @@ classes: SparkMaxConfig&: AlternateEncoderConfig&: Flatten: +inline_code: | + bind_sparkbaseconfig_apply(cls_SparkMaxConfig); diff --git a/pyproject.toml b/pyproject.toml index 3de5ab8..9e47300 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,13 +6,13 @@ author_email = "robotpy@googlegroups.com" url = "https://github.com/robotpy/robotpy-rev" license = "BSD-3-Clause" install_requires = [ - "wpilib~=2025.0.0b1", + "wpilib~=2025.0.0b2", ] [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a1", - "wpilib~=2025.0.0b1", + "robotpy-build<2025.0.0b1,~=2025.0.0a4", + "wpilib~=2025.0.0b2", ] [tool.robotpy-build] diff --git a/rev/sparkbaseconfig_apply.h b/rev/sparkbaseconfig_apply.h new file mode 100644 index 0000000..890cfa1 --- /dev/null +++ b/rev/sparkbaseconfig_apply.h @@ -0,0 +1,43 @@ +#pragma once + +template +void bind_sparkbaseconfig_apply(Cls &cls) { + using namespace rev::spark; + + auto sparkBaseConfigType = py::type::of(); + + cls + .def("apply", [=](T &self, SparkBaseConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + .def("apply", [=](T &self, AbsoluteEncoderConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + .def("apply", [=](T &self, AnalogSensorConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + .def("apply", [=](T &self, EncoderConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + .def("apply", [=](T &self, LimitSwitchConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + .def("apply", [=](T &self, SoftLimitConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + .def("apply", [=](T &self, ClosedLoopConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + .def("apply", [=](T &self, SignalsConfig &config) -> T& { + sparkBaseConfigType.attr("apply")(self, config); + return self; + }, py::arg("config")) + ; +} \ No newline at end of file diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..ca3115e --- /dev/null +++ b/tests/test_config.py @@ -0,0 +1,11 @@ +import rev + + +def test_spark_flex_config(): + config = rev.SparkFlexConfig() + config.apply(rev.EncoderConfig()).apply(rev.AbsoluteEncoderConfig()) + + +def test_spark_max_config(): + config = rev.SparkMaxConfig() + config.apply(rev.EncoderConfig()).apply(rev.AbsoluteEncoderConfig())