reflow-firmware3.0/src/profiles.rs

153 lines
3.4 KiB
Rust
Raw Permalink 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;
2020-12-21 15:14:08 +01:00
while pos < 6 && time > self.points[pos].time {
2020-10-04 15:39:30 +02:00
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);
2020-12-21 15:14:08 +01:00
self.points[pos - 1].temp + (time - self.points[pos - 1].time) * delta
2020-10-04 15:39:30 +02:00
}
}
}
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,
2020-12-21 15:14:08 +01:00
temp: 40f32,
2020-10-04 15:39:30 +02:00
},
ProfilePoint {
2020-12-21 15:14:08 +01:00
time: 90f32,
temp: 145f32,
2020-10-04 15:39:30 +02:00
},
ProfilePoint {
2020-12-21 15:14:08 +01:00
time: 180f32,
temp: 180f32,
2020-10-04 15:39:30 +02:00
},
ProfilePoint {
2020-12-21 15:14:08 +01:00
time: 210f32,
temp: 230f32,
2020-10-04 15:39:30 +02:00
},
ProfilePoint {
2020-12-21 15:14:08 +01:00
time: 230f32,
temp: 230f32,
2020-10-04 15:39:30 +02:00
},
ProfilePoint {
2020-12-21 15:14:08 +01:00
time: 320f32,
temp: 40f32,
2020-10-04 15:39:30 +02:00
},
],
},
ReflowProfile {
2020-10-08 22:37:14 +02:00
name: "Too 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
];