-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from robotpy/apply-config
Add Apply overloads to Spark*Config
- Loading branch information
Showing
5 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,13 @@ author_email = "[email protected]" | |
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] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
template <typename T, typename Cls> | ||
void bind_sparkbaseconfig_apply(Cls &cls) { | ||
using namespace rev::spark; | ||
|
||
auto sparkBaseConfigType = py::type::of<SparkBaseConfig>(); | ||
|
||
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")) | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) |