Skip to content

Commit a15257c

Browse files
committed
Prevent drawing waveform above height (0-based).
1 parent 9871ba8 commit a15257c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/synthwaveform_oscilloscope.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ def update():
7575
# Draw waveform on screen
7676
display.fill(0)
7777
for i in range(data.size):
78-
y1 = int((HEIGHT - data[i] * HEIGHT) / 2)
79-
y2 = int((HEIGHT - data[(i + 1) % WIDTH] * HEIGHT) / 2)
78+
y1 = min(int((HEIGHT - data[i] * HEIGHT) / 2), HEIGHT - 1)
79+
y2 = min(int((HEIGHT - data[(i + 1) % WIDTH] * HEIGHT) / 2), HEIGHT - 1)
8080
if y1 == y2:
8181
display.pixel(i, y1, 1)
8282
else:

0 commit comments

Comments
 (0)