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

🐛Fix Negative Port Rotation Sensor #618

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/devices/vdml_rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

namespace pros {
inline namespace v5 {
Rotation::Rotation(const std::int8_t port) : Device(port, DeviceType::rotation) {
if (port < 0) {
pros::c::rotation_set_reversed(abs(port), true);
} else {
pros::c::rotation_set_reversed(port, false);
}

Rotation::Rotation(const std::int8_t port) : Device(abs(port), DeviceType::rotation) {
if (port < 0) {
pros::c::rotation_set_reversed(abs(port), true);
} else {
pros::c::rotation_set_reversed(port, false);
}
}

std::int32_t Rotation::reset() {
Expand Down Expand Up @@ -77,9 +77,9 @@ std::ostream& operator<<(std::ostream& os, const pros::Rotation& rotation) {

namespace literals {
const pros::Rotation operator"" _rot(const unsigned long long int r) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we support making rotation sensors with negative ports, should this be changed to signed? Probably outside the scope of this pr

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

return pros::Rotation(r);
return pros::Rotation(r);
}
} // namespace literals
} // namespace literals

} // namespace v5
} // namespace pros