Amit Aryeh Levy | f0d66d0 | 2017-08-15 11:47:46 -0700 | [diff] [blame] | 1 | #![no_std] |
| 2 | |
Alistair Francis | e5f74c3 | 2020-09-11 15:21:14 -0700 | [diff] [blame] | 3 | use libtock::println; |
torfmaster | 3d60524 | 2019-12-16 22:36:39 +0100 | [diff] [blame] | 4 | use libtock::result::TockResult; |
Woyten | b122620 | 2020-01-13 22:47:48 +0100 | [diff] [blame] | 5 | use libtock::sensors::Sensor; |
torfmaster | c84685a | 2019-02-08 19:23:22 +0100 | [diff] [blame] | 6 | use libtock::timer::Duration; |
Amit Aryeh Levy | f0d66d0 | 2017-08-15 11:47:46 -0700 | [diff] [blame] | 7 | |
Johnathan Van Why | 074fa7d | 2020-10-14 17:06:50 -0700 | [diff] [blame] | 8 | libtock_core::stack_size! {0x800} |
| 9 | |
torfmaster | b06f637 | 2019-12-17 09:20:48 +0100 | [diff] [blame] | 10 | #[libtock::main] |
torfmaster | 3d60524 | 2019-12-16 22:36:39 +0100 | [diff] [blame] | 11 | async fn main() -> TockResult<()> { |
Woyten | b122620 | 2020-01-13 22:47:48 +0100 | [diff] [blame] | 12 | let mut drivers = libtock::retrieve_drivers()?; |
Woyten | 8d517b0 | 2020-01-13 20:58:20 +0100 | [diff] [blame] | 13 | |
Woyten | b122620 | 2020-01-13 22:47:48 +0100 | [diff] [blame] | 14 | let mut timer_driver = drivers.timer.create_timer_driver(); |
Woyten | 8d517b0 | 2020-01-13 20:58:20 +0100 | [diff] [blame] | 15 | let timer_driver = timer_driver.activate()?; |
Alistair Francis | e5f74c3 | 2020-09-11 15:21:14 -0700 | [diff] [blame] | 16 | drivers.console.create_console(); |
torfmaster | f7ac7c9 | 2019-11-17 00:33:28 +0100 | [diff] [blame] | 17 | |
torfmaster | d5db030 | 2019-11-14 19:06:10 +0100 | [diff] [blame] | 18 | loop { |
Alistair Francis | e5f74c3 | 2020-09-11 15:21:14 -0700 | [diff] [blame] | 19 | println!("Humidity: {}\n", drivers.humidity_sensor.read()?); |
| 20 | println!("Temperature: {}\n", drivers.temperature_sensor.read()?); |
| 21 | println!("Light: {}\n", drivers.ambient_light_sensor.read()?); |
| 22 | println!("Accel: {}\n", drivers.ninedof.read_acceleration()?); |
torfmaster | 6ecb72f | 2019-12-18 12:17:34 +0100 | [diff] [blame] | 23 | timer_driver.sleep(Duration::from_ms(500)).await?; |
torfmaster | d5db030 | 2019-11-14 19:06:10 +0100 | [diff] [blame] | 24 | } |
Amit Aryeh Levy | f0d66d0 | 2017-08-15 11:47:46 -0700 | [diff] [blame] | 25 | } |