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 feat/distance-sensor-object-size
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin-Niederman authored Mar 19, 2024
2 parents d9b2c61 + d1e9972 commit 1ea2e09
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ Before releasing:
- Added support for getting motor fault flags (e.g. over-temperature, over-current, H-bridge faults).
- Added support for internal motor PID tuning. Feature gated behind `dangerous_motor_tuning`, as this can cause hardware damage and is not recommended.
- Added various constants for convenience around `Motor` and `Gearset`.
- Added `Controller` API to the `pros::prelude` module. (#108)

- `relative_size` method on `DistanceSensor` for getting a guess at an object's relative size. (#73)

### 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 @@ -53,6 +55,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
1 change: 1 addition & 0 deletions packages/pros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub mod prelude {
AdiDevice, AdiPort,
},
color::Rgb,
controller::Controller,
peripherals::{DynamicPeripherals, Peripherals},
position::Position,
screen::{Circle, Line, Rect, Screen, Text, TextFormat, TextPosition, TouchState},
Expand Down

0 comments on commit 1ea2e09

Please sign in to comment.