Last active
August 17, 2017 22:26
-
-
Save alevy/73d0a1e5c8784df066c86dc5da9d3107 to your computer and use it in GitHub Desktop.
Rust Tock app that periodically samples the on-board sensors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(alloc)] | |
#![no_std] | |
extern crate alloc; | |
extern crate tock; | |
use alloc::fmt::Write; | |
use tock::console::Console; | |
use tock::sensors::*; | |
#[inline(never)] | |
fn main() { | |
let mut console = Console::new(); | |
let mut humidity = HumiditySensor; | |
let mut temperature = TemperatureSensor; | |
let mut light = AmbientLightSensor; | |
let mut ninedof = unsafe { Ninedof::new() }; | |
loop { | |
write!(&mut console, "Humidity: {}\n", humidity.read()).unwrap(); | |
write!(&mut console, "Temperature: {}\n", temperature.read()).unwrap(); | |
write!(&mut console, "Light: {}\n", light.read()).unwrap(); | |
write!(&mut console, "Accel: {}\n", ninedof.read_acceleration()).unwrap(); | |
tock::timer::delay_ms(500); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment