diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..cc4decf --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,24 @@ +name: Cargo Check + +on: + push: + branches: [ master, main ] + pull_request: + branches: [ master, main ] + +env: + RUST_BACKTRACE: 1 + +jobs: + check: + name: Cargo Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Run cargo check + run: cargo check --all-targets --all-features \ No newline at end of file diff --git a/examples/jogcon.rs b/examples/jogcon.rs index 01fa0d6..061cd14 100755 --- a/examples/jogcon.rs +++ b/examples/jogcon.rs @@ -5,8 +5,6 @@ //! are represented and you can send them with square, triangle, //! circle, left, up, and right. -#![feature(duration_from_micros)] - extern crate embedded_hal; extern crate linux_embedded_hal as linux_hal; extern crate pscontroller_rs; @@ -56,7 +54,7 @@ fn main() { // We only care about the JogCon here so skip everything else let jogcon = match controller { - Device::JogCon(x) => (x), + Device::JogCon(x) => x, _ => continue, }; diff --git a/src/lib.rs b/src/lib.rs index ad885e4..b752dbf 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -499,13 +499,22 @@ where } } +#[cfg(test)] mod tests { + use super::ControllerData; + use super::MESSAGE_MAX_LENGTH; + #[test] fn union_test() { // Again, buttons are active low, hence 'fe' and '7f' - let controller = ControllerData { - data: [0xfe, 0x7f, 0x00, 0x00, 0x00, 0xff], - }; + let mut data = [0u8; MESSAGE_MAX_LENGTH]; + data[0] = 0xfe; + data[1] = 0x7f; + data[2] = 0x00; + data[3] = 0x00; + data[4] = 0x00; + data[5] = 0xff; + let controller = ControllerData { data }; unsafe { assert!(controller.ds.buttons.select() == true);