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 pos < 6 && time > self.points[pos].time {
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);
self.points[pos - 1].temp + (time - self.points[pos - 1].time) * delta
}
}
}
pub const REFLOW_PROFILES: [ReflowProfile; 4] = [
ReflowProfile {
name: "Too Hot",
points: [
ProfilePoint {
time: 0f32,
temp: 40f32,
},
ProfilePoint {
time: 90f32,
temp: 145f32,
},
ProfilePoint {
time: 180f32,
temp: 180f32,
},
ProfilePoint {
time: 210f32,
temp: 230f32,
},
ProfilePoint {
time: 230f32,
temp: 230f32,
},
ProfilePoint {
time: 320f32,
temp: 40f32,
},
],
},
ReflowProfile {
name: "Too 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,
},
],
},
];