pub struct ReflowProfile { name: &'static str, points: [ProfilePoint; 6], } pub struct ProfilePoint { time: f32, temp: f32, } impl ReflowProfile { pub fn get_name(&self) -> &'static str { self.name } pub fn get_temp(&self, time: f32) -> f32 { let mut pos = 0; while time > self.points[pos].time && pos < 6 { pos += 1; } if pos == 0 { self.points[0].temp } else if pos == 6 { self.points[5].temp } else { let delta = (self.points[pos].temp - self.points[pos - 1].temp) / (self.points[pos].time - self.points[pos - 1].time); (time - self.points[pos - 1].time) * delta } } } pub const REFLOW_PROFILES: [ReflowProfile; 2] = [ ReflowProfile { name: "Profile 1", points: [ ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ], }, ReflowProfile { name: "Profile 2", points: [ ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ProfilePoint { time: 0f32, temp: 0f32, }, ], }, ];