reflow-firmware3.0/src/profiles.rs

153 lines
3.4 KiB
Rust
Raw Normal View History

2020-10-04 15:39:30 +02:00
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
}
}
}
2020-10-06 23:40:13 +02:00
pub const REFLOW_PROFILES: [ReflowProfile; 4] = [
2020-10-04 15:39:30 +02:00
ReflowProfile {
2020-10-08 20:45:16 +02:00
name: "Too Hot",
2020-10-04 15:39:30 +02:00
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 {
2020-10-08 20:45:16 +02:00
name: "To Cold",
2020-10-04 15:39:30 +02:00
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,
},
],
},
2020-10-06 23:40:13 +02:00
ReflowProfile {
2020-10-08 20:45:16 +02:00
name: "About Okay",
2020-10-06 23:40:13 +02:00
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,
},
],
},
2020-10-04 15:39:30 +02:00
];