Skip to content

Commit fa5f9c6

Browse files
AsCressmarcnause
authored andcommitted
fix: fixes scaling of axes for waveforms having negative DC components
1 parent acf39d4 commit fa5f9c6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/src/main/java/io/pslab/activity/OscilloscopeActivity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,11 @@ public void autoScale() {
12301230
yPadding = yRange * 0.1;
12311231
if (maxPeriod > 0) {
12321232
xAxisScale = Math.min((maxPeriod * 5), maxTimebase);
1233-
yAxisScale = maxY + yPadding;
1233+
if (Math.abs(maxY) >= Math.abs(minY)) {
1234+
yAxisScale = maxY + yPadding;
1235+
} else {
1236+
yAxisScale = -1 * (minY - yPadding);
1237+
}
12341238
samples = 512;
12351239
timeGap = (2 * xAxisScale * 1000.0) / samples;
12361240
} else {

0 commit comments

Comments
 (0)