hacknus / serial-monitor-rust

A cross-plattform serial monitor/plotter written entirely in rust.
GNU General Public License v3.0
138 stars 16 forks source link

Feature request - Scale per channel #92

Open usbalbin opened 11 months ago

usbalbin commented 11 months ago

When having different values with completely different scales, the smaller ones turns in to flat lines close to zero

It would be useful to have individual scaling per channel like on an oscilloscope. Not shure how that would work with y-ranges etc.

image

hacknus commented 11 months ago

Indeed a very good idea, this should be implemented! We could have a drop down to select pre-defined gains/scaling factors (..., 0.1, 1, 10, ...) next to the field where you can enter a name for the dataset/curve?

usbalbin commented 11 months ago

Perhaps even a "offset" parameter. That, I, believe would be enough to allow scaling and moving around the curves above until they are all evenly spread out and with their respective variations clearly visible.

If one could dream :), there would be two buttons Autoscale and Autoscale side by side(or similar). Where the first button would scale and move all curves to occupy the hole screen. The second button would do the same but put them side by side so as to avoid any overlapping.

hacknus commented 11 months ago

Yes, we would definitely require both a scale and offset. Autoscale could also be a possibility and could be easy to implement (not sure though). I think both need to be implemented in line 333 of gui.rs:

for (i, time) in self.data.time[window..].iter().enumerate() {
    let x = *time as f64 / 1000.0;
    for (graph, data) in graphs.iter_mut().zip(&self.data.dataset) {
        if self.data.time.len() == data.len() {
            if let Some(y) = data.get(i + window) {
                graph.push(PlotPoint { x, y: *y as f64 });   // implement offset and scale here
            }
        }
    }
}

Autosacle side by side could be more difficult, there I do not have a clear picture on how one would do this.