Fix bug in serial plotter for negative values

Fix #4365
Fix #4292
This commit is contained in:
Cristian Maglie 2016-01-08 12:14:09 +01:00
parent 4fa57be5c7
commit 870171a69e
2 changed files with 11 additions and 5 deletions

View File

@ -87,12 +87,17 @@ public class SerialPlotter extends AbstractMonitor {
minY = Double.POSITIVE_INFINITY;
maxY = Double.NEGATIVE_INFINITY;
for(Graph g : graphs) {
double bMin = g.buffer.min() / 2.0;
double bMax = g.buffer.max() * 2.0;
minY = bMin < minY ? bMin : minY;
maxY = bMax > maxY ? bMax : maxY;
minY = Math.min(g.buffer.min(), minY);
maxY = Math.max(g.buffer.max(), maxY);
}
final double MIN_DELTA = 10.0;
if (maxY - minY < MIN_DELTA) {
double mid = (maxY + minY) / 2;
maxY = mid + MIN_DELTA / 2;
minY = mid - MIN_DELTA / 2;
}
Ticks ticks = new Ticks(minY, maxY, 3);
minY = Math.min(minY, ticks.getTick(0));
maxY = Math.max(maxY, ticks.getTick(ticks.getTickCount() - 1));

View File

@ -5,6 +5,7 @@ ARDUINO 1.6.8
* Fixed incorrect key bindings handling for changing tab. Thanks @matthijskooijman
* MacOSX: Fixed handling of add indent/remove indent shortcuts (CMD+[ and CMD+])
* Fixed incorrect update of available libraries in Library Manager. Thanks @vicnevicne
* Serial plotter now correctly resize graphs with negative values. Thanks @vicnevicne
[core]
* avr: fixed USB_SendControl(...) for buffer with len > 64. Thanks @NicoHood