1
Fork 0

move recorder from example to viz

This commit is contained in:
juliangaal 2019-04-23 11:04:27 +02:00
parent b100c58da2
commit 99fc06997d
241 changed files with 607 additions and 0 deletions

10
viz/viz/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "viz"
version = "0.1.0"
authors = ["Julian Gaal <juliangaal@protonmail.com>"]
edition = "2018"
[dependencies]
mpu6050 = "0.1.0"
i2cdev = "0.4.1"
linux-embedded-hal = "0.2.2"

View file

@ -0,0 +1,62 @@
use mpu6050::*;
use mpu6050::Error as Mpu6050Error;
use linux_embedded_hal::{I2cdev, Delay};
use i2cdev::linux::LinuxI2CError;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::error::Error;
fn new_file(name: &str) -> File {
let path = Path::new(name);
let display = path.display();
let _file = match File::create(&path) {
Err(why) => panic!("couldn't create {}: {}",
display,
why.description()),
Ok(file) => return file,
};
}
fn write_x_to(file: &mut File, content: String) {
match file.write_all(content.as_bytes()) {
Err(why) => {
println!("couldn't write to file: {}", why.description());
},
Ok(_) => {},
}
}
fn main() -> Result<(), Mpu6050Error<LinuxI2CError>> {
let i2c = I2cdev::new("/dev/i2c-1")
.map_err(Mpu6050Error::I2c)?;
let delay = Delay;
let mut mpu = Mpu6050::new(i2c, delay);
mpu.init()?;
let mut acc_file = new_file("acc_data.txt");
let mut gyro_file = new_file("gyro_data.txt");
let mut temp_file = new_file("temp_data.txt");
let mut angles_file = new_file("angles_data.txt");
loop {
// get roll and pitch estimate
let acc = mpu.get_acc_angles()?;
write_x_to(&mut angles_file, format!("{},{}", acc.0, acc.1));
// get temp
let temp = mpu.get_temp()?;
write_x_to(&mut temp_file, format!("{}", temp));
// get gyro data, scaled with sensitivity
let gyro = mpu.get_gyro()?;
write_x_to(&mut gyro_file, format!("{} {} {}", gyro.0, gyro.1, gyro.2));
// get accelerometer data, scaled with sensitivity
let acc = mpu.get_acc()?;
write_x_to(&mut acc_file, format!("{} {} {}", acc.0, acc.1, acc.2));
}
}

View file

@ -0,0 +1 @@
{"rustc_fingerprint":16477849714929411750,"outputs":{"15337506775154344876":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/julian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"1164083562126845933":["rustc 1.34.0 (91856ed52 2019-04-10)\nbinary: rustc\ncommit-hash: 91856ed52c58aa5ba66a015354d1cc69e9779bdf\ncommit-date: 2019-04-10\nhost: x86_64-unknown-linux-gnu\nrelease: 1.34.0\nLLVM version: 8.0\n",""],"1617349019360157463":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/julian/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""]},"successes":{}}

View file

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":7001212489759244422,"profile":9935990280773120926,"path":5943171097463195476,"deps":[],"local":[{"Precalculated":"0.3.3"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[\"default\"]","target":7001212489759244422,"profile":9935990280773120926,"path":10606878967782862455,"deps":[],"local":[{"Precalculated":"1.0.4"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":7001212489759244422,"profile":9935990280773120926,"path":17427132433695158890,"deps":[],"local":[{"Precalculated":"0.4.0"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[\"default\", \"std\"]","target":12042902509987818770,"profile":9935990280773120926,"path":9745575622455250394,"deps":[],"local":[{"Precalculated":"1.3.1"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
6175fb72752610d6

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"","target":0,"profile":0,"path":0,"deps":[],"local":[{"Precalculated":"1.3.1"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[\"default\", \"std\"]","target":10088282520713642473,"profile":9935990280773120926,"path":3314454423712832271,"deps":[],"local":[{"Precalculated":"1.3.1"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
af600dc14a4e2a31

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":6711570533623458614,"profile":9935990280773120926,"path":609780401603415449,"deps":[["byteorder v1.3.1","byteorder",10027422310704075236],["iovec v0.1.2","iovec",8678654122203341897]],"local":[{"Precalculated":"0.4.12"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
9feebf12d553838a

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":16332793819020931523,"profile":9935990280773120926,"path":9808958079356095173,"deps":[],"local":[{"Precalculated":"0.2.2"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
a82b943ddd4c3e8e

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":12396366720307268670,"profile":9935990280773120926,"path":11587077605825350744,"deps":[],"local":[{"Precalculated":"0.1.7"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[\"nb\", \"unproven\"]","target":15060166776816606055,"profile":9935990280773120926,"path":3883287070163597272,"deps":[["nb v0.1.2","nb",8728870926459469327],["void v1.0.2","void",14956605601281413493]],"local":[{"Precalculated":"0.2.2"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
db3ac0730863bc30

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":9008728495137886990,"profile":9935990280773120926,"path":12713802978200893768,"deps":[["bitflags v1.0.4","bitflags",16071688965135708908],["byteorder v1.3.1","byteorder",10027422310704075236],["libc v0.2.51","libc",15801496908623686918],["nix v0.11.0","nix",17206303661130906463]],"local":[{"Precalculated":"0.4.1"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
49e46852f1c57078

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":4267689733410618981,"profile":9935990280773120926,"path":15687680222298898475,"deps":[["libc v0.2.51","libc",15801496908623686918]],"local":[{"Precalculated":"0.1.2"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[\"default\", \"use_std\"]","target":10088282520713642473,"profile":9935990280773120926,"path":4690833009137423459,"deps":[],"local":[{"Precalculated":"0.2.51"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
06adf2edb7314adb

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[\"default\", \"use_std\"]","target":15220052048028810702,"profile":9935990280773120926,"path":17319734422051546254,"deps":[],"local":[{"Precalculated":"0.2.51"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
3c448f06011f7c11

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"","target":0,"profile":0,"path":0,"deps":[],"local":[{"Precalculated":"0.2.51"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
beaa23de3e035379

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":18263329330656510864,"profile":9935990280773120926,"path":8569163767405211548,"deps":[],"local":[{"Precalculated":"0.1.2"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":10799275729728059490,"profile":9935990280773120926,"path":8712256874598455179,"deps":[["cast v0.2.2","cast",9980913373790858911],["embedded-hal v0.2.2","embedded_hal",628776168636104478],["i2cdev v0.4.1","i2cdev",3511790697395010267],["spidev v0.3.0","spidev",13153239152922867695],["sysfs_gpio v0.5.3","sysfs_gpio",5913756594699124463]],"local":[{"Precalculated":"0.2.2"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":11491499298404797424,"profile":9935990280773120926,"path":11029159912568478635,"deps":[["embedded-hal v0.2.2","embedded_hal",628776168636104478],["libm v0.1.2","libm",8742334870205999806]],"local":[{"Precalculated":"0.1.1"}],"rustflags":[],"edition":"Edition2018"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
0ffed92ddc2d2379

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[\"unstable\"]","target":4556115220702817628,"profile":9935990280773120926,"path":530877144325903551,"deps":[],"local":[{"Precalculated":"0.1.2"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
1a060c27a1edda75

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":1565834789335428953,"profile":9935990280773120926,"path":13444546824305547783,"deps":[["bitflags v0.4.0","bitflags",11233988528749842960],["cfg-if v0.1.7","cfg_if",10249714315046431656],["libc v0.2.51","libc",15801496908623686918],["void v1.0.2","void",14956605601281413493]],"local":[{"Precalculated":"0.6.0"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":10088282520713642473,"profile":9935990280773120926,"path":15562034580861923811,"deps":[],"local":[{"Precalculated":"0.10.0"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
73f657df4290400e

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"","target":0,"profile":0,"path":0,"deps":[],"local":[{"Precalculated":"0.10.0"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":10088282520713642473,"profile":9935990280773120926,"path":9559215858396043262,"deps":[],"local":[{"Precalculated":"0.11.0"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
8a236c0bd69ebc71

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":1565834789335428953,"profile":9935990280773120926,"path":978806733795926278,"deps":[["bitflags v1.0.4","bitflags",16071688965135708908],["bytes v0.4.12","bytes",3542730139853742255],["cfg-if v0.1.7","cfg_if",10249714315046431656],["libc v0.2.51","libc",15801496908623686918],["void v1.0.2","void",14956605601281413493]],"local":[{"Precalculated":"0.10.0"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
This file has an mtime of when this was started.

View file

@ -0,0 +1 @@
5ffb35530412c9ee

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":1565834789335428953,"profile":9935990280773120926,"path":14131361263981436465,"deps":[["bitflags v1.0.4","bitflags",16071688965135708908],["cfg-if v0.1.7","cfg_if",10249714315046431656],["libc v0.2.51","libc",15801496908623686918],["void v1.0.2","void",14956605601281413493]],"local":[{"Precalculated":"0.11.0"}],"rustflags":[],"edition":"Edition2015"}

View file

@ -0,0 +1 @@
{"rustc":804226499018287853,"features":"[]","target":10088282520713642473,"profile":9935990280773120926,"path":10956874729958565536,"deps":[["rustc_version v0.1.7","rustc_version",6353640533764932271],["semver v0.1.20","semver",17528136092947719351]],"local":[{"Precalculated":"0.6.0"}],"rustflags":[],"edition":"Edition2015"}

Some files were not shown because too many files have changed in this diff Show more