Skip to content

Commit 870171a

Browse files
committed
Fix bug in serial plotter for negative values
Fix arduino#4365 Fix arduino#4292
1 parent 4fa57be commit 870171a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

app/src/processing/app/SerialPlotter.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,17 @@ private Ticks computeBounds() {
8787
minY = Double.POSITIVE_INFINITY;
8888
maxY = Double.NEGATIVE_INFINITY;
8989
for(Graph g : graphs) {
90-
double bMin = g.buffer.min() / 2.0;
91-
double bMax = g.buffer.max() * 2.0;
92-
minY = bMin < minY ? bMin : minY;
93-
maxY = bMax > maxY ? bMax : maxY;
90+
minY = Math.min(g.buffer.min(), minY);
91+
maxY = Math.max(g.buffer.max(), maxY);
9492
}
95-
93+
94+
final double MIN_DELTA = 10.0;
95+
if (maxY - minY < MIN_DELTA) {
96+
double mid = (maxY + minY) / 2;
97+
maxY = mid + MIN_DELTA / 2;
98+
minY = mid - MIN_DELTA / 2;
99+
}
100+
96101
Ticks ticks = new Ticks(minY, maxY, 3);
97102
minY = Math.min(minY, ticks.getTick(0));
98103
maxY = Math.max(maxY, ticks.getTick(ticks.getTickCount() - 1));

build/shared/revisions.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ARDUINO 1.6.8
55
* Fixed incorrect key bindings handling for changing tab. Thanks @matthijskooijman
66
* MacOSX: Fixed handling of add indent/remove indent shortcuts (CMD+[ and CMD+])
77
* Fixed incorrect update of available libraries in Library Manager. Thanks @vicnevicne
8+
* Serial plotter now correctly resize graphs with negative values. Thanks @vicnevicne
89

910
[core]
1011
* avr: fixed USB_SendControl(...) for buffer with len > 64. Thanks @NicoHood

0 commit comments

Comments
 (0)