Skip to content

Commit

Permalink
Fix unused code warnings on other platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
eldruin committed Feb 5, 2025
1 parent eaba606 commit daa01ed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
4 changes: 4 additions & 0 deletions examples/nunchuck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mod nunchuck {
// TODO: Move Nunchuck code out to be an actual sensor and add tests

#[derive(Debug)]
#[allow(dead_code)]
pub struct NunchuckReading {
pub joystick_x: u8,
pub joystick_y: u8,
Expand Down Expand Up @@ -186,9 +187,12 @@ mod nunchuck {
#[cfg(any(target_os = "linux", target_os = "android"))]
use nunchuck::*;

#[cfg(any(target_os = "linux", target_os = "android"))]
use docopt::Docopt;
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::env::args;

#[cfg(any(target_os = "linux", target_os = "android"))]
const USAGE: &str = "
Reading Wii Nunchuck data via Linux i2cdev.
Expand Down
15 changes: 9 additions & 6 deletions examples/pca9956b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ extern crate docopt;
extern crate i2cdev;

#[cfg(any(target_os = "linux", target_os = "android"))]
use i2cdev::core::{I2CMessage, I2CTransfer};
#[cfg(any(target_os = "linux", target_os = "android"))]
use i2cdev::linux::{LinuxI2CBus, LinuxI2CMessage};

use docopt::Docopt;
use std::env::args;
use i2cdev::{
core::{I2CMessage, I2CTransfer},
linux::{LinuxI2CBus, LinuxI2CMessage},
};

#[cfg(any(target_os = "linux", target_os = "android"))]
const USAGE: &str = "
Reads registers from a PCA9956B IC via Linux i2cdev.
Expand All @@ -32,13 +31,17 @@ Options:
--version Show version.
";

#[cfg(any(target_os = "linux", target_os = "android"))]
const ADDR: u16 = 0x20;

#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn main() {}

#[cfg(any(target_os = "linux", target_os = "android"))]
fn main() {
use docopt::Docopt;
use std::env::args;

let args = Docopt::new(USAGE)
.and_then(|d| d.argv(args()).parse())
.unwrap_or_else(|e| e.exit());
Expand Down
14 changes: 8 additions & 6 deletions examples/sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ extern crate byteorder;
extern crate docopt;
extern crate i2cdev;

#[cfg(any(target_os = "linux", target_os = "android"))]
use docopt::Docopt;
use sensors::adxl345_accelerometer::*;
use sensors::mpl115a2_barometer::*;
use sensors::{Accelerometer, Barometer, Thermometer};
use std::env::args;
use std::thread;
use std::time::Duration;
#[cfg(any(target_os = "linux", target_os = "android"))]
use sensors::{
adxl345_accelerometer::*, mpl115a2_barometer::*, Accelerometer, Barometer, Thermometer,
};

#[cfg(any(target_os = "linux", target_os = "android"))]
use std::{env::args, thread, time::Duration};

#[cfg(any(target_os = "linux", target_os = "android"))]
use i2cdev::linux::*;
Expand Down

0 comments on commit daa01ed

Please sign in to comment.