forked from ariel-os/ariel-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ subdirs: | |
- embassy-usb-keyboard | ||
- hello-world | ||
- minimal | ||
- random | ||
- threading |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "random" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
publish = false | ||
|
||
[dependencies] | ||
# not enabling riot-rs/hwrng even though it's currently needed -- laze takes | ||
# care of that. | ||
riot-rs = { path = "../../src/riot-rs", features = ["threading"] } | ||
riot-rs-boards = { path = "../../src/riot-rs-boards" } | ||
|
||
riot-rs-random = { version = "0.1.0", path = "../../src/riot-rs-random" } | ||
rand = { version = "0.8.5", default-features = false } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# random | ||
|
||
## About | ||
|
||
This application performs a very important role in physical computing: | ||
It produces randomness in the form of a dice roll (values 1 to 6, inclusive). | ||
It prints out a single random value via the debug console. | ||
|
||
## How to run | ||
|
||
In this folder, run | ||
|
||
laze build -b nrf52840dk run | ||
|
||
This will print different values most of the time on all boards it can be built | ||
on. If there is no way to get startup entropy on a board, the example can not | ||
be built. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apps: | ||
- name: random | ||
selects: | ||
- ?release | ||
- rng |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![no_main] | ||
#![no_std] | ||
#![feature(type_alias_impl_trait)] | ||
#![feature(used_with_arg)] | ||
|
||
use riot_rs::debug::{println}; | ||
|
||
#[riot_rs::thread(autostart)] | ||
fn main() { | ||
use rand::Rng as _; | ||
let mut rng = riot_rs_random::get_rng(); | ||
|
||
let value = rng.gen_range(1..=6); | ||
|
||
println!( | ||
"The random value of this round is {}.", | ||
value | ||
); | ||
} |