Skip to main content

embedded_wg_display/runtime/host_api/
random.rs

1#![doc = "Implementation of the `random` WIT interface.\n\n```wit"]
2#![doc = include_str!("wit/random.wit")]
3#![doc = "```"]
4
5use crate::runtime::WidgetState;
6use crate::runtime::widget::widget::random;
7use esp_hal::rng::Rng;
8
9fn get_random() -> u64 {
10    let rng = Rng::new();
11    let low = rng.random() as u64;
12    let high = rng.random() as u64;
13    (high << 32) | low
14}
15
16impl random::Host for WidgetState {
17    fn get_random(&mut self) -> u64 {
18        get_random()
19    }
20}