Skip to content

Commit

Permalink
Tidy up to get ready for a release soon Pt2 (#17)
Browse files Browse the repository at this point in the history
* Bump version number

* Update hyperlinks in README.md to make cargo doc happy

* Add derive debug, default and defmt on structs where possible
  • Loading branch information
9names authored Apr 25, 2024
1 parent 665d034 commit 19caef2
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Wiimote extension controllers are designed to talk to a Wiimote over an I2C inte
The official controllers are capable of operating in fast-mode (400Khz) though some clones require normal-mode (100Khz).
The protocol is quite simple - it's not officially documented, but it has been reverse-engineered.

- http://wiibrew.org/wiki/Wiimote/Extension_Controllers
- http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Nunchuck
- http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Classic_Controller
- <http://wiibrew.org/wiki/Wiimote/Extension_Controllers>
- <http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Nunchuck>
- <http://wiibrew.org/wiki/Wiimote/Extension_Controllers/Classic_Controller>

High Resolution mode is a recent addition and was only discovered once the NES Classic console was released. It is described here:
- https://www.raphnet-tech.com/support/classic_controller_high_res/
- <https://www.raphnet-tech.com/support/classic_controller_high_res>


Wii Motion Plus support is planned, both in standalone and combo mode
Expand Down Expand Up @@ -66,7 +66,7 @@ fn main() {

- Nunchuk is supported
- Classic controllers supported in regular and HD mode
- Controller init is not 100% reliable, can suffer from i2c errors. This seems to affect the blocking implementation more than async
- Controller init is not 100% reliable, can suffer from i2c errors. This seems to affect the blocking implementation more than async.
Error handling around new() is strongly recommended.

## Support
Expand All @@ -77,15 +77,15 @@ For questions, issues, feature requests like compatibility with other Wiimote ex
## License

Nunchuk portions of this crate are largely derived from
https://github.com/rust-embedded/rust-i2cdev/blob/master/examples/nunchuck.rs
<https://github.com/rust-embedded/rust-i2cdev/blob/master/examples/nunchuck.rs>
Copyright 2015, Paul Osborne <[email protected]>

Licensed under either of

* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
<http://www.apache.org/licenses/LICENSE-2.0>)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)
<http://opensource.org/licenses/MIT>)

at your option.

Expand Down
2 changes: 1 addition & 1 deletion wii-ext/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "wii-ext"
description = "Wiimote Extension Controller (nunchuk, classic controller) driver for Rust embedded-hal traits"
version = "0.3.0"
version = "0.4.0"
edition = "2021"
authors = ["9names"]
repository = "https://github.com/9names/wii-ext-rs"
Expand Down
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 19caef2

Please sign in to comment.