Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions examples/jogcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};

Expand Down
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down