change values to u128

This commit is contained in:
Andre Henriques 2023-03-15 23:14:41 +00:00
parent 100f782aea
commit 29efa6be83

View File

@ -23,7 +23,7 @@ pub struct LigthSetting {
#[derive(Clone)]
pub struct KeyFrame {
duration: u64,
duration: u128,
settings: Vec<LigthSetting>
}
@ -34,7 +34,7 @@ pub struct RenderAnimation {
name: String,
current_frame: usize,
start_time: u64,
start_time: u128,
reset: bool,
}
@ -42,7 +42,7 @@ pub struct Render {
conn: DBPool,
num_leds: u32,
last_render: u64,
last_render: u128,
ws: Option<Ws2812Rpi>,
last: Vec<RGB<f64>>,
@ -176,7 +176,7 @@ impl Render {
});
}
key_frames.push(KeyFrame { duration: frame.get_duration().into(), settings: light_settings })
key_frames.push(KeyFrame { duration: (frame.get_duration() as u128) * (1000 as u128), settings: light_settings })
}
let new_animation = RenderAnimation {
@ -236,7 +236,7 @@ impl Render {
let mut data: Vec<RGB<f64>> = vec![RGB::default(); self.num_leds.try_into().unwrap()];
let time = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards").as_secs();
let time = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards").as_millis();
if self.last_render == 0 {
self.last_render = time;
@ -331,7 +331,7 @@ pub trait Lerp {
impl Lerp for f64 {
fn lerp(self, other: &Self, diff: f64) -> Self {
let delta = diff;
let delta = diff / 1000.0;
let change = (*other - self) * 0.2 * delta;