src: implement simulation data sources

This commit is contained in:
2025-09-24 08:32:34 +02:00
parent 19875f6ae5
commit 0cd2cc94b9
32 changed files with 389785 additions and 284 deletions

View File

@@ -35,4 +35,30 @@ pub fn as_milliwatts(pixel: &Rgb<u8>) -> u32 {
let blue = (pixel.b as u32 * BLUE_MW).wrapping_shr(8);
red + green + blue + DARK_MW
}
#[derive(Debug)]
pub struct CircularBuffer<T, const SIZE: usize = 20> {
pub data: [T; SIZE],
next_index: usize
}
impl<T: Default + Copy, const SIZE: usize> Default for CircularBuffer<T, SIZE> {
fn default() -> Self {
Self {
data: [Default::default(); SIZE],
next_index: 0
}
}
}
impl<T, const SIZE: usize> CircularBuffer<T, SIZE> {
pub fn insert(&mut self, value: T) {
self.data[self.next_index] = value;
self.next_index += 1;
if self.next_index == self.data.len() {
self.next_index = 0;
}
}
}