reflow-firmware3.0/src/profiles.rs

153 lines
3.4 KiB
Rust

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; 4] = [
ReflowProfile {
name: "Too Hot",
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: "To Cold",
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: "About Okay",
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: "Emtpy",
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,
},
],
},
];