Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into fix/controller-in-prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin-Niederman authored Mar 13, 2024
2 parents 435cb59 + db1e06f commit 3c55d01
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Before releasing:
### Fixed

- `pros_sys` bindings to the Motors C API now takes the correct port type (`i8`) as of PROS 4 (**Breaking Change**) (#66).
- Fixed the unintended `unsafe` context present in the `sync_robot` and `async_robot` family of macros (**Breaking Change**) (#107).

### Changed

Expand All @@ -50,6 +51,7 @@ Before releasing:
- Renamed `Motor::get_state` to `Motor::status`.
- Status structs containing device bits now use the `bitflags!` crate. (**Breaking Change**) (#66)
- Renamed `InertialSensor::calibrating` to `InertialSensor::calibrating` (**Breaking CHange**) (#66)
- AdiEncoder now returns `Position` rather than just degrees (**Breaking Change**) (#106).

### Removed

Expand Down
6 changes: 4 additions & 2 deletions packages/pros-async/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ macro_rules! async_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = Default::default();
unsafe {
ROBOT = Some(Default::default());
ROBOT = Some(robot);
}
}
};
Expand All @@ -195,8 +196,9 @@ macro_rules! async_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = $init;
unsafe {
ROBOT = Some($init);
ROBOT = Some(robot);
}
}
};
Expand Down
9 changes: 5 additions & 4 deletions packages/pros-devices/src/adi/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use pros_core::bail_on;
use pros_sys::{ext_adi_encoder_t, PROS_ERR};

use super::{AdiDevice, AdiDeviceType, AdiError, AdiPort};
use crate::Position;

/// ADI encoder device.
/// Requires two adi ports.
Expand Down Expand Up @@ -49,10 +50,10 @@ impl AdiEncoder {
}

/// Gets the number of ticks recorded by the encoder.
pub fn position(&self) -> Result<i32, AdiError> {
Ok(bail_on!(PROS_ERR, unsafe {
pros_sys::adi_encoder_get(self.raw)
}))
pub fn position(&self) -> Result<Position, AdiError> {
let degrees = bail_on!(PROS_ERR, unsafe { pros_sys::adi_encoder_get(self.raw) });

Ok(Position::from_degrees(degrees as f64))
}
}

Expand Down
6 changes: 4 additions & 2 deletions packages/pros-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ macro_rules! sync_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = Default::default();
unsafe {
ROBOT = Some(Default::default());
ROBOT = Some(robot);
}
}
};
Expand All @@ -133,8 +134,9 @@ macro_rules! sync_robot {

#[no_mangle]
extern "C" fn initialize() {
let robot = $init;
unsafe {
ROBOT = Some($init);
ROBOT = Some(robot);
}
}
};
Expand Down

0 comments on commit 3c55d01

Please sign in to comment.