Skip to content

Commit

Permalink
Add debug and default attributes to structs
Browse files Browse the repository at this point in the history
  • Loading branch information
9names committed Apr 25, 2024
1 parent f5c12c9 commit 894dc88
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions wii-ext/src/async_impl/classic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::core::classic::*;
use crate::core::ControllerType;
use embedded_hal_async;

#[derive(Debug, Default)]
pub struct Classic<I2C, Delay> {
interface: InterfaceAsync<I2C, Delay>,
hires: bool,
Expand Down
2 changes: 2 additions & 0 deletions wii-ext/src/async_impl/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub enum AsyncImplError {
ParseError,
}

#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
#[derive(Debug, Default)]
pub struct InterfaceAsync<I2C, Delay> {
i2cdev: I2C,
delay: Delay,
Expand Down
2 changes: 2 additions & 0 deletions wii-ext/src/blocking_impl/classic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub enum ClassicError<E> {
ParseError,
}

#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
#[derive(Debug, Default)]
pub struct Classic<I2C, DELAY> {
interface: Interface<I2C, DELAY>,
hires: bool,
Expand Down
4 changes: 3 additions & 1 deletion wii-ext/src/blocking_impl/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ use crate::core::{
};
use embedded_hal::i2c::{I2c, SevenBitAddress};

#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
#[derive(Debug, Default)]
pub struct Interface<I2C, Delay> {
i2cdev: I2C,
delay: Delay,
}

#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
/// Errors in this crate
#[derive(Debug)]
/// Errors in this crate
pub enum BlockingImplError<E> {
/// I²C bus communication error
I2C(E),
Expand Down
3 changes: 2 additions & 1 deletion wii-ext/src/core/classic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ pub(crate) fn decode_classic_hd_report(data: &[u8]) -> ClassicReading {
/// Relaxed/Center positions for each axis
///
/// These are used to calculate the relative deflection of each access from their center point
#[derive(Default)]
#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
#[derive(Debug, Default)]
pub struct CalibrationData {
pub joystick_left_x: u8,
pub joystick_left_y: u8,
Expand Down
5 changes: 3 additions & 2 deletions wii-ext/src/core/nunchuk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use defmt;

#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct NunchukReading {
pub joystick_x: u8,
pub joystick_y: u8,
Expand Down Expand Up @@ -34,7 +34,8 @@ impl NunchukReading {
/// Relaxed/Center positions for each axis
///
/// These are used to calculate the relative deflection of each access from their center point
#[derive(Default)]
#[cfg_attr(feature = "defmt_print", derive(defmt::Format))]
#[derive(Debug, Default)]
pub struct CalibrationData {
pub joystick_x: u8,
pub joystick_y: u8,
Expand Down

0 comments on commit 894dc88

Please sign in to comment.