Skip to content

Commit 9573522

Browse files
committed
docs: fixup the readme
Signed-off-by: Paul Osborne <[email protected]>
1 parent 40d96c8 commit 9573522

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ Nunchuck (which has an i2c interface).
2222

2323
Here's a real quick example showing the guts of how you create a
2424
device and start talking to it... This device only requires basic
25-
functions (read/write) which are done via the Read/Write traits.
25+
functions (read/write) which are done via the Read/Write traits (if
26+
you actually want to use the Wii Nunchuck you should use
27+
[`i2cdev::sensors::nunchuck::Nunchuck`][nunchuck]:
2628

2729
```rust
2830
extern crate i2cdev;
@@ -31,18 +33,21 @@ use std::thread;
3133

3234
const NUNCHUCK_SLAVE_ADDR: u16 = 0x52;
3335

34-
// real code should not use unwrap() so liberally
36+
// real code should probably not use unwrap()
3537
fn i2cfun() -> Result<(), I2CError> {
3638
let mut dev = try!(I2CDevice::new("/dev/i2c-1", NUNCHUCK_SLAVE_ADDR));
39+
40+
// init sequence
3741
try!(self.i2cdev.smbus_write_byte_data(0xF0, 0x55));
38-
try!(self.i2cdev-smbus_write_byte_data(0xFB, 0x00))
42+
try!(self.i2cdev.smbus_write_byte_data(0xFB, 0x00));
3943
thread::sleep_ms(100);
44+
4045
loop {
4146
let mut buf: [u8: 6] = [0: 6];
42-
self.i2cdev.write_all(&[0x00]).unwrap();
47+
self.i2cdev.smbus_write_byte(0x00).unwrap();
4348
thread::sleep_ms(10);
4449
self.i2cdev.read(&mut buf).unwrap();
45-
println!("Reading: {:?}", buf);
50+
println!("Reading: {:?}", buf);
4651
}
4752
}
4853
```
@@ -66,6 +71,8 @@ pub trait I2CSMBus {
6671
}
6772
```
6873

74+
[nunchuck]: http://rust-embedded.github.io/rust-i2cdev/i2cdev/sensors/nunchuck/struct.Nunchuck.html
75+
6976
Features
7077
--------
7178

0 commit comments

Comments
 (0)