|
|
@ -19,8 +19,8 @@ fn main() { |
|
|
|
// Activate the accelerometer and the gyroscope.
|
|
|
|
// Activate the accelerometer and the gyroscope.
|
|
|
|
// Because of the complex nature of the movement sensors, they aren't activated by default with the `Hid` service.
|
|
|
|
// Because of the complex nature of the movement sensors, they aren't activated by default with the `Hid` service.
|
|
|
|
// However, they can simply be turned on and off whenever necessary.
|
|
|
|
// However, they can simply be turned on and off whenever necessary.
|
|
|
|
hid.enable_accelerometer(); |
|
|
|
hid.set_accelerometer(true); |
|
|
|
hid.enable_gyroscope(); |
|
|
|
hid.set_gyroscope(true); |
|
|
|
|
|
|
|
|
|
|
|
while apt.main_loop() { |
|
|
|
while apt.main_loop() { |
|
|
|
// Scan all the controller inputs.
|
|
|
|
// Scan all the controller inputs.
|
|
|
@ -35,10 +35,12 @@ fn main() { |
|
|
|
println!( |
|
|
|
println!( |
|
|
|
"\x1b[3;0HAcceleration: {:?} ", |
|
|
|
"\x1b[3;0HAcceleration: {:?} ", |
|
|
|
hid.accelerometer_vector() |
|
|
|
hid.accelerometer_vector() |
|
|
|
|
|
|
|
.expect("could not retrieve acceleration vector") |
|
|
|
); |
|
|
|
); |
|
|
|
println!( |
|
|
|
println!( |
|
|
|
"\x1b[4;0HGyroscope angular rate: {:?} ", |
|
|
|
"\x1b[4;0HGyroscope angular rate: {:?} ", |
|
|
|
hid.gyroscope_rate() |
|
|
|
hid.gyroscope_rate() |
|
|
|
|
|
|
|
.expect("could not retrieve angular rate") |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
gfx.wait_for_vblank(); |
|
|
|
gfx.wait_for_vblank(); |
|
|
|